RESOLVED: Notification of IVR option

Hello. Forgive me for not knowing where to put this or how to ask, but can someone help lead me in the correct direction.

I want to setup a system where when a user chooses a specific option on an IVR, I get a notification. The notification can be a variety of things, but email would be my first choice.

I want to prompt the user to opt to receive a text message link to go to our website portal instead of holding for a CSR. If I can get an email, I can have my SMS program send out a text and then I can hang up the call.

This might be the magic I need.

https://community.freepbx.org/t/email-notification-of-incoming-missed-call/29913

Testing now.

Instead of sending an email, it may be easier (and more customer friendly) to send the SMS directly from Asterisk, so the caller will usually get the text within a few seconds of pressing the option.

Most trunking providers have an API that you could call using Asterisk’s curl command.

1 Like

My astricon talk last fall has dialplan for generating SMS to the caller ID of an inbound caller.

1 Like

Very cool. I will look into it.

Will look into it using Igaetz’s comment below.

1 Like

Alright, I have been playing around with this for the last few hours and after failure after failure I whittled it down to this:

I have an Inbound Route setup to forward my CID directly to a Custom Destination, called Portal SMS, which has a target of portal-sms,sms,1

Inside etc/asterisk/extensions_custom.conf I have this added to the end of the file, saved and uploaded via WinSCP:
[portal-sms]
exten => sms,1,Hangup

I then ran this on the putty console and got Dialplan reloaded as a response:
rasterisk -x 'dialplan reload'

I then call from my cell phone and I get a dial tone. I would expect it to hang up based on the custom dialplan I wrote. Note that I tried this with various dialplan actions and finally whittled it down to a simple hangup to rule out that I was doing something wrong within the dialplan.

This is way over my head. I am a simple COO/C# developer trying to add some functionality that we came up with in a brainstorming meeting…

Current Asterisk Version: 13.38.1

answer is not intrinsic to a channel, do that before before attempting to 'hangup’ing it

Thank you. This is good to know.

I figured out what the problem was. My extensions_custom.conf file must have a syntax error or something in it because I finally found “dialplan show” and looked for the context I created… I wasn’t able to find it.

I moved my portal-sms context to the top of the document, saved, uploaded and reloaded the dialplan, checked for the context with dialplan show and it worked perfectly. Also, the call is behaving as it should.

Now to read the entire extensions_custom.conf file to find someone elses typo… Thanks for all the help!

Almost done with this project, just a few small things to workout.

I have ran into a road block and can’t figure out how to write the CURL line for this.

Here is the documentation from Twilio:
https://support.twilio.com/hc/en-us/articles/223133907-Simple-Example-for-Sending-Programmable-SMS-Text-or-Picture-Messages

I was trying to use Igaetz’s Astricon post as a base, but I can’t figure out how to translate from Twilio’s curl to Asterisk’s curl.

Any help is appreciated.

I finally figured this out. I wasn’t setting the headers properly.

Below is the final code. I put inline comments to explain what each line is doing in case someone else wants to do something similar in the future.

[sms-invite]
; First, we have to answer the call
exten => s,1,Answer
; Then we get the Caller ID from the system
exten => s,n,set(caller=${CALLERID(number)})
; Our Database API needs the Caller ID in xxx-xxx-xxxx format, so let's do that
exten => s,n,set(cid=$[${caller:0:3}~~"-"~~${caller:3:3}~~"-"~~${caller:6:4}])
; Get the client ID from API
exten => s,n,set(clientid=${URIENCODE(${CURL(https://0.0.0.0/api.php?cid=${cid})})})
; Get the case manager's phone number from API
exten => s,n,set(from=${URIENCODE(${CURL(https://0.0.0.0/api.php?cid=${cid})})})
; Set the destination as the caller ID
exten => s,n,set(to=${CALLERID(number)})
; Build the body of the message
exten => s,n,set(body=$["Blah Blah Blah: www.google.com/q?" ~~ ${clientid}])
; Set the authentication variables for Twilio
exten => s,n,set(twilio_sid=<<< Twilio SID >>>)
exten => s,n,set(twilio_token=<<< Twilio Token >>>)
; Set the headers and send the request via CURL
exten => s,n,set(CURLOPT(userpwd)=${twilio_sid}:${twilio_token})
exten => s,n,Set(response=${CURL(https://api.twilio.com/2010-04-01/Accounts/${twilio_sid}/Messages.json,To=1${to}&From=1${from}&Body=${body})})
; Analyze the result using REGEX and go to success if successful
exten => s,n,GotoIf($[${REGEX("\"status\": \"queued\"" ${response})} = 1]?success)
; If it wasn't successful, this code will be executed, call will be return to Custom Destination for further routing
exten => s,n,Playback(tt-monkeysintro)
exten => s,n,Return()

; If successful, this code will be executed and the call will be terminated
exten => s,n(success),Playback(tt-weasels)
exten => s,n,Goto(app-blackhole,hangup,1)
3 Likes

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