Trigger Curl event in dailplan does not work

In my dialplan I use an IVR which I want to enrich with an SMS notification if a voicemail has been created. Via the commandline on my FreePBX machine I can call successfully

root$curl “https://www.megavoip.com/myaccount/sendsms.php?username=user&password=passw&from=number&to=gsm&text=Someone called your voicemail”

Part of the dailplan where I try to call the same sms trigger

exten => 5,1,Playback(custom/aaa)
exten => 5,n,VoiceMail(777,s)
exten => 5,n,set(CURL(“https://www.megavoip.com/myaccount/sendsms.php?username=user&password=passw&from=number&to=gsm&text=Someone called the voicemail”))
exten => 5,n,Playback(custom/bbb)
exten => 5,n,WaitExten(1.5)
exten => 5,n,Hangup()

But so far no success. Anyone any ideas ?

Kind regards

You should be using CURL in a read context, not a write one. Your set command has a syntax error, as a result.

I’m also not sure what error recovery the CURL function applies for spaces in URLs; it would be safer to make the URL valid with % escapes.

I’m also assuming any necessary escapes have been used in the password.

If I call this on the command line, everything works as expected. User/Passw is not an issue because these items don’t contain spaces. I eliminated the spaces in the Curl statement earlier, but no improvement, although your remark with % makes sense and will be an improvement.

In my opinion I use the Curl as a read statement otherwise it wouldn’t work on the command line either. I’m just calling an API on that URL…

Read and write are relative to Asterisk functions, not relative to web resources. They the senses in which “read” and “written” are used in Asterisk 16 Function_CURL - Asterisk Project - Asterisk Project Wiki

(However GET is not an appropriate HTTP method for an operation that has essential side effects, as it is cacheable.)

I’ve created a workaround which seems to work by calling a script with that content via System()

exten => 5,n,System(/install/sent_sms.sh &)

You’re misusing the asterisk curl function. See this page for some curl sms examples
https://wiki.freepbx.org/pages/viewpage.action?pageId=191141136

I’m not sure if we are at the same wave… In one of the examples I see this line

exten => s,n,set(result=${CURL(https://api.apidaze.io/${apidaze_key}/sms/send?api_secret=${apidaze_secret},from=${from_DID}&to=${destination}&body=${joke})})

Except from using variables, I do see a similar approach (although I’m not an asterisk expert at all :wink: )

It’s the difference between:

set(CURL(“https

and

set(result=${CURL(https

I saw that, but I’m already far out my comfort zone to understand the difference without reading more. I simply want to call the URL within my dial plan without calling an external script (my current work around)

Use NoOp since you don’t care about the result of the CURL call.

exten => 5,n,NoOp(CURL...

1 Like

Change

exten => 5,1,Playback(custom/aaa)
exten => 5,n,VoiceMail(777,s)
exten => 5,n,set(CURL(“https://www.megavoip.com/myaccount/sendsms.php?username=user&password=passw&from=number&to=gsm&text=Someone called the voicemail”))
exten => 5,n,Playback(custom/bbb)
exten => 5,n,WaitExten(1.5)
exten => 5,n,Hangup()

To

exten => 5,1,Playback(custom/aaa)
exten => 5,n,VoiceMail(777,s)
exten => 5,n,Set(result=${CURL(https://www.megavoip.com/myaccount/sendsms.php?username=user&password=passw&from=number&to=gsm&text=Someone called the voicemail)})
exten => 5,n,Playback(custom/bbb)
exten => 5,n,WaitExten(1.5)
exten => 5,n,Hangup()
1 Like

@ BillSimon
I’ll give it try and let you know!

I’ll give this try also !

Although PitzKey’s solution also works, the NoOp(Curl) call is for me better than the set(Curl) because I still have a playback(custom/bbb) in the next line, so I don’t have a wait-for-response delay.

Thank you all for your input & help. My challenge is resolved and I have learned again today.

My current solution

exten => s,n,Set(number=${CALLERID(number)})
exten => s,n,Set(name=${CALLERID(name)})
exten => s,n,NoOp(result=${CURL(https://www.megavoip.com/myaccount/sendsms.php?username=<>&password=<>&from=<>&to=<>&text=${number} ${name} called)})

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