Freepbx and Curl

Hi,

Sorry to ask but i would like to add a http command to my ring group.
I’ve got a IP door bell linked to Freepbx by SIP and i would like when somebody press the bell button it do an action on my domotic system

At the moment, when my door bell is ringing i’m using a ring group.
i would like to add a http query, and i’ve seen it is possible to add a curl action like :
curl --user login:password “http://ip/api/callAction?deviceID=245&name=pressButton&arg1=1

can you help me setting that in freepbx?

as i’m a poor newbie in asterisk thanks a lot.

I am using curl as follows without User and password

same => n,Set(mysystem=${CURL(http://127.0.0.1/recording?call=${CALLFILENAME}.${MON_FMT})})

Maybe it will help you

Hi
thanks but in which screen and which field of freepbx do you define that?

I manage to create a curl command in the extensions_custom.conf file

exten => 9002,1,answer()
exten => 9002,n,Set(result=${CURL(http://url/jeeApi.php?apikey=toto&type=cmd&id=394&title=untestsmsCURL&message=curl9002)})
exten => 9002,n,NoOp(Results: ${result})
exten => 9002,n,Hangup()

when i dial 9002 with a SIP phone, the command is successfully executed.
but i would like to add this into a ring group…
I’ve got a exisintg ring group that ring all my phone, and i would like when the ring group is “called” that the curl action is done.

any clue how i can had a custom extension in ring group interface?

thanks

Try to find ring group that you create in extensions_additional.conf

See code of my ring group with number 600 in my extensions_additional.conf

[ext-group]
exten => 600,1,Macro(user-callerid,)
exten => 600,n,Macro(blkvm-setifempty,)
exten => 600,n,GotoIf($["${GOSUB_RETVAL}" = “TRUE”]?skipov)
exten => 600,n,Macro(blkvm-set,reset)
exten => 600,n,Set(__NODEST=)
exten => 600,n(skipov),Set(RRNODEST=${NODEST})
exten => 600,n(skipvmblk),Set(__NODEST=${EXTEN})
exten => 600,n,GosubIf($[${DB_EXISTS(RINGGROUP/600/changecid)} = 1 & “${DB(RINGGROUP/600/changecid)}” != “default” & “${DB(RINGGROUP/600/changecid)}” != “”]?sub-rgsetcid,s,1())
exten => 600,n,Gosub(sub-record-check,s,1(rg,600,dontcare))
exten => 600,n,Set(RingGroupMethod=ringall)
exten => 600,n(DIALGRP),Macro(dial,20,${DIAL_OPTIONS},10010-10020)
exten => 600,n,Gosub(sub-record-cancel,s,1())
exten => 600,n,Set(RingGroupMethod=)
exten => 600,n,GotoIf($[“foo${RRNODEST}” != “foo”]?nodest)
exten => 600,n,Set(__NODEST=)
exten => 600,n,Macro(blkvm-clr,)
exten => 600,n,Goto(ext-queues,1,1)
exten => 600,n(nodest),Noop(SKIPPING DEST, CALL CAME FROM Q/RG: ${RRNODEST})

exten => h,1,Macro(hangupcall,)

Thanks but when i check i’ve got exactly the same thing for my extension 6000 (my ring group)

[ext-group]
include => ext-group-custom
exten => 6000,1,Macro(user-callerid,)
exten => 6000,n,Macro(blkvm-setifempty,)
exten => 6000,n,GotoIf($["${GOSUB_RETVAL}" = “TRUE”]?skipov)
exten => 6000,n,Macro(blkvm-set,reset)
exten => 6000,n,Set(__NODEST=)
exten => 6000,n(skipov),Set(RRNODEST=${NODEST})
exten => 6000,n(skipvmblk),Set(__NODEST=${EXTEN})
exten => 6000,n,GosubIf($[${DB_EXISTS(RINGGROUP/6000/changecid)} = 1 & “${DB(RINGGROUP/6000/changecid)}” != “default” & “${DB(RINGGROUP/6000/changecid)}” != “”]?sub-rgsetcid,s,1())
exten => 6000,n,Gosub(sub-record-check,s,1(rg,6000,dontcare))
exten => 6000,n,Set(RingGroupMethod=ringall)
exten => 6000,n(DIALGRP),Macro(dial,20,${DIAL_OPTIONS},1001-1002-1004-9002)
exten => 6000,n,Gosub(sub-record-cancel,s,1())
exten => 6000,n,Set(RingGroupMethod=)
exten => 6000,n,GotoIf($[“foo${RRNODEST}” != “foo”]?nodest)
exten => 6000,n,Set(__NODEST=)
exten => 6000,n,Macro(blkvm-clr,)
exten => 6000,n,Goto(ext-local,vmu1004,1)
exten => 6000,n(nodest),Noop(SKIPPING DEST, CALL CAME FROM Q/RG: ${RRNODEST})

the only thing that change is my ext (1001-1002-1004-9002) instead of yours (10010-10020)

1001-1002-1004 are extension define in freepbx
9002 is the one i’ve create manually in extensions_custom.conf

so when i dial 6000 i don’t understand why my action 9000 is not executed whereas all my phone extension are ringing…

thanks for your help

Try running your code inside the ring group:

Like this:
This code in extensions_override_freepbx.conf

[ext-group]
exten => 600,1,Macro(user-callerid,)
exten => 600,n,Macro(blkvm-setifempty,)
exten => 600,n,GotoIf($["${GOSUB_RETVAL}" = “TRUE”]?skipov)
exten => 600,n,Macro(blkvm-set,reset)
exten => 600,n,Set(__NODEST=)
exten => 600,n(skipov),Set(RRNODEST=${NODEST})
exten => 600,n(skipvmblk),Set(__NODEST=${EXTEN})
exten
=> 600,n,GosubIf($[${DB_EXISTS(RINGGROUP/600/changecid)} = 1 &
"${DB(RINGGROUP/600/changecid)}" != “default” &
"${DB(RINGGROUP/600/changecid)}" != “”]?sub-rgsetcid,s,1())
exten => 600,n,Gosub(sub-record-check,s,1(rg,600,dontcare))
exten => 600,n,Set(RingGroupMethod=ringall)
exten => 600,n(DIALGRP),Macro(dial,20,${DIAL_OPTIONS},10010-10020)
exten => 600,n,Gosub(sub-record-cancel,s,1())
exten => 600,n,Set(RingGroupMethod=)
exten => 600,n,GotoIf($[“foo${RRNODEST}” != “foo”]?nodest)
exten => 600,n,Set(__NODEST=)
exten => 600,n,Macro(blkvm-clr,)
exten => 600,n,Set(result=${CURL(http://url/jeeApi.php?apikey=toto&type=cmd&id=394&title=untestsmsCURL&message=curl9002)})
exten => 600,n,NoOp(Results: ${result})
exten => 600,n,Goto(ext-queues,1,1)
exten => 600,n(nodest),Noop(SKIPPING DEST, CALL CAME FROM Q/RG: ${RRNODEST})

:smile:

This code in extensions_override_freepbx.conf

You… ROCKS!!!

thank so much!!!

i’ve just modify the order by putting the CURL before the ringall
because else the curl is executed after the call (so wait for the hangup)

exten => 600,n,Gosub(sub-record-check,s,1(rg,600,dontcare))
exten => 600,n,Set(result=${CURL(http://url/jeeApi.php?apikey=toto&type=cmd&id=394&title=untestsmsCURL&message=curl9002)})
exten => 600,n,NoOp(Results: ${result})
exten => 600,n,Set(RingGroupMethod=ringall)
exten => 600,n(DIALGRP),Macro(dial,20,${DIAL_OPTIONS},10010-10020)
exten => 600,n,Gosub(sub-record-cancel,s,1())
exten => 600,n,Set(RingGroupMethod=)
exten => 600,n,GotoIf($[“foo${RRNODEST}” != “foo”]?nodest)
exten => 600,n,Set(__NODEST=)
exten => 600,n,Macro(blkvm-clr,)
exten => 600,n,Goto(ext-queues,1,1)

thanks very much

1 Like