How to send different strings to different hosts depending on the file that was commited. (gitlab ci/cd)

You'll propably end up using "only: changes" as explained here.

Something like this should fit:

stages:
 - trigger

service1:
 stage: trigger
 script:
   - curl http://host1:port1
 only:
  changes:
    - service1/*

service2:
 stage: trigger
 script:
   - curl http://host2:port2
 only:
  changes:
    - service2/*