Watcher webhook action in painless

Hi there,

I want to use webhook type of action to send SMS to multiple recipients via our SMS gateway.

"actions": {
"create_sms": {
"webhook": {
"scheme": "https",
"host": "sms-gw.com",
"port": 443,
"method": "post",
"path": "/cgi-bin/sms.php",
"params": {},
"headers": {},
"body": "recipient=0784515151&message=Testing Elastic SMS GW&submit=Submit"
}
}
}

The challenges I have are
1 - the recipients will be dynamically returned and passed through via the watcher payload so I would need to use some variable via transform in this style: 'sms_recipients': ctx.payload.contact.hits.hits.stream().map(x -> x._source.phone).collect(Collectors.toList()).join(','), ...
2 - the SMS gateway doesn't support multiple recipient at once which lead me to scripting a loop going through the list of recipients and send an SMS request for each of them.

So my question is can someone give me a painless script that could roughly achieve the above? Painless is not really my forte :cold_sweat:

Thanks,
NH

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.