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.
Forward SMS to Slack
Moderator: Martin
Re: Forward SMS to Slack
You can create the json dynamically from the script. If you need only the sms text, you can create the json like this.
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.
Code: Select all
text = newMapFromValues("text", sms_text);
js = toJSON(text);
Use {js} in the Data field in the HTTP post. Any special character will be escaped properly.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.