Page 1 of 1

Forward SMS to Slack

Posted: 27 Mar 2019 01:46
by jj05
Hello,

I'm trying to forward an SMS to Slack, via a webhook.
The following works, but I can only manage to send a static JSON.
I'm not sure how to interpolate the SMS text in the JSON, and how to deal with escaping the text in the JSON.

Trigger:
Trigger Type: SMS Received

Action:
Action Type: HTTP Request
URL: https://hooks.slack.com/services/XXX/YYY/ZZZ
Request Method: POST

Content Type:
General Text
application/json

Data:
{'{"text":"Hello, World"}'}

Any idea how to get this to work?
As a temporary workaround, I got something to work via the "Forward SMS to mail" flow in the catalog, but it's not ideal.

Re: Forward SMS to Slack

Posted: 27 Mar 2019 17:22
by Desmanto
You can create the json dynamically from the script. If you need only the sms text, you can create the json like this.

Code: Select all

text = newMapFromValues("text", sms_text);
js = toJSON(text);
where {sms_text} is the variable provided by the trigger SMS received, which contains the text messsage.

Use {js} in the Data field in the HTTP post. Any special character will be escaped properly.