Receive txt msg after IVR Choice

I have a client who has requested the ability to have a txt msg sent to the caller when they make an IVR selection. It’s a restaurant and they want the ability for a caller to receive a link to their online ordering via text message when they select an IVR choice.

I’m sure this is possible, not sure if it already exists or how to create it if it doesn’t

You can do it with DynRoutes or by sending the IVR option to a custom destination which calls a custom dialplan.

You can write a script that uses arg1 as the destination, or you can do it all within the dialplan

${SHELL(/path/to/script ${CALLERID(num)})}

Or

${SHELL(curl -x POST https://webhook -h headers ....}

There’s some dialplan on this page that shows how to automate outbound SMS using Voip Innovations
https://wiki.freepbx.org/display/FDT/FreePBX+Dialplan+Customization+AstriCon+2020#FreePBXDialplanCustomizationAstriCon2020-CustomDestinations

Which could be used directly with VI or modified to work with a similar service.

I’ve never really written a dialplan in practice. Never really had the need so really learning it was never a priority. That said I’ve muddle through and come up with this. The API is ClearlyIP’s. I’m pretty sure I don’t have the send request properly written.

[sms-link]
; answer the call
exten => s,1,Answer

; Make CallerID the TO
exten => s,n,set(To=${CALLERID(number)})

; SMS message
exten => s,n,set(Body=$["test test test?"])

; set auth key
exten => s,n,set(authkey=$["mykey"])

; From
exten => s,n,set(From=$["18005551212"])

; CURL
exten => s,n,Set(response=${CURL(https://unity.clearlyip.com/trunking/v2/sms/message?auth=1${authkey},To=1${to},From=1${from},Body=${body},media="")})

; Finish 
exten => s,n,return

You have a GET request. Most vendors have a POST request. Can you please share their documentation so we can see what they expect?

GET for an operation that is supposed to have real side effects, and not be idempotent would certainly be a misuse of HTTP, but I think it is so common misuse, in practice, that caches had to give up caching get mode forms.

yes, you are correct, this should be a post request.

https://unity.clearlyip.com/trunking/v2/sms/message

{
  "from": "+18044772602",
  "to": [
    "string"
  ],
  "content": "Foo",
  "media": [
    {
      "filename": "bar.png",
      "ext": "png",
      "data": "string"
    }
  ]
}

So would this be more correct?

[sms-link]
; answer the call
exten => s,1,Answer

; Make CallerID the TO
exten => s,n,set(To=${CALLERID(number)})

; SMS message
exten => s,n,set(Body=$["test test test?"])

; set auth key
exten => s,n,set(authkey=$["mykey"])

; From
exten => s,n,set(From=$["18005551212"])

; CURL
exten => s,n,Set(response=${CURL(https://unity.clearlyip.com/trunking/v2/sms/message,auth=1${authkey},To=1${to},From=1${from},Body=${body},media="")})

; Finish 
exten => s,n,return

unfortunately the docs are behind a login. I have download the txt from the API docs but it’s too big to post here and I think Pastebin.freepbx.org is still down.

here’s a link to the download that should work without a login. Note that about the first half of this file are depreciated functions:

download

@ashcortech Nice to see someone utilizing our API. If you don’t mind opening a support ticket over at support.clearlyip.com, the team can work with you to come up with a solution that will make this easier for you to call via your custom dialplan. After we have something working, if it requires any module changes, we will also work on getting those changes pushed out so that others may benefits at well.

1 Like

Bryan, thanks!! will do!

Jeff
We did update our wiki here on the AGI we now include in our Trunking module to let you easily use dialplan to send a SMS from Asterisk Dial Plan. FreePBX & PBXact Automated Setup with Module

1 Like

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