# Watcher webhook action in painless

**URL:** <https://discuss.elastic.co/t/watcher-webhook-action-in-painless/189468>\
**Category:** Elasticsearch\
**Created:** [July 9, 2019, 7:13am UTC](https://discuss.elastic.co/t/watcher-webhook-action-in-painless/189468 "2019-07-09T07:13:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NidOf3lp](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@NidOf3lp](https://discuss.elastic.co/u/NidOf3lp)\
**Post date:** [July 9, 2019, 7:13am UTC](https://discuss.elastic.co/t/watcher-webhook-action-in-painless/189468/1 "2019-07-09T07:13:29Z")

</div>

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](http://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 😰

Thanks,  
NH

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 6, 2019, 7:13am UTC](https://discuss.elastic.co/t/watcher-webhook-action-in-painless/189468/2 "2019-08-06T07:13:30Z")

</div>

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