Stassen
(My Hobby)
December 27, 2021, 9:43am
1
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
david55
(david55)
December 27, 2021, 10:19am
2
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.
Stassen
(My Hobby)
December 27, 2021, 11:39am
3
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…
david55
(david55)
December 27, 2021, 12:01pm
4
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.)
Stassen
(My Hobby)
December 27, 2021, 12:40pm
5
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 &)
lgaetz
(Lorne Gaetz)
December 27, 2021, 1:09pm
6
You’re misusing the asterisk curl function. See this page for some curl sms examples
https://wiki.freepbx.org/pages/viewpage.action?pageId=191141136
Stassen
(My Hobby)
December 27, 2021, 3:45pm
7
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 )
lgaetz
(Lorne Gaetz)
December 27, 2021, 4:20pm
8
It’s the difference between:
set(CURL(“https
and
set(result=${CURL(https
Stassen
(My Hobby)
December 27, 2021, 5:01pm
9
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)
billsimon
(Bill Simon)
December 27, 2021, 5:08pm
10
Use NoOp
since you don’t care about the result of the CURL call.
exten => 5,n,NoOp(CURL...
1 Like
PitzKey
(Itzik)
December 27, 2021, 5:09pm
11
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
Stassen
(My Hobby)
December 27, 2021, 5:14pm
12
@ BillSimon
I’ll give it try and let you know!
Stassen
(My Hobby)
December 27, 2021, 5:15pm
13
I’ll give this try also !
Stassen
(My Hobby)
December 27, 2021, 5:44pm
14
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)})
system
(system)
Closed
January 3, 2022, 5:44pm
15
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.