Add cURL command to all outbound calls in Elastix 2.5

Hi everyone,

I wanted to post this message as a follow-up to an existing topic that I got solved on here, but the forum looks to be forcing me to make a new topic due to the age of that post. Anyway, the experience on this forum is invaluable, so once again I’m looking for some insight on a relatively simple task: Running a cURL HTTP command after all outbound calls.

I’m currently running an Elastix 2.5.0 server on CentOS 2.6.18 with Asterisk v11.17.1. In the past I was running Elastix 2.4.0 and had this running 100%, but it looks like something is different in the 2.5.0 version, or in the version of CentOS or Asterisk I’m now running. Below is the code from my old server in extensions_custom.conf:

[outbound-allroutes-custom] ; for all 4 of the main dial plans we use to call customers exten => _NXXXXXX,2,System(curl "${EXTEN}") exten => _NXXNXXXXXX,2,System(curl "${EXTEN}") exten => _1NXXNXXXXXX,2,System(curl "${EXTEN}") exten => _+1NXXNXXXXXX,2,System(curl "${EXTEN}")

With this simple code in the extensions_custom.conf file, my PBX would automatically send a CID lookup result via HTTP to my CRM software (which allows us to keep track of outgoing calls made by staff members). I made sure cURL was installed on the new PBX and copied the exact same code as before, but nothing is working.

What I’ve tried so far to get something to work (no success yet):
[ul]Using and removing the “_” in front of the dial plan.
Changing the order from “,2,” to alternatives like “,1,” and “,n,”.
Changing the usage “System” to alternatives like “Set” or “Dial”. [/ul]

I’ve watched the CLI output and it looks like the cURL command is never running. If I manually copy and paste the command, everything obviously works. I’m just not able to get the command to run on behalf of outgoing calls. Can someone please tell me what I’m missing to get outbound calls to run this command script?

If you’d like to see more details about the previously solved topic, here’s the link: viewtopic.php?f=13&t=95540

Thanks everyone!

I am guessing that asterisk doesn’t have the rights to execute the curl command.

If you want to check, ssh to your box, connect as root and run the following command

su - asterisk

Now you are connected as the asterisk user. From there try to execute the curl command and see what happens.

Also, why not use the curl dialplan function … ction_CURL

This forum doesn’t support Elastix.

If you are stabbing in the dark with priorities, you don’t understand dialplans well enough to be attempting to modify a GUIs dialplan, even if you are are modifying a user customisable file.

@david55: Thank you for your assistance on posting replies to the forum. Understood on Elastix not being supported. We internally use both FreePBX and Asterisk, but for testing we have an Elastix server. I just tried on the other machines with the same results, so maybe there’s a solution that works for all Asterisk systems :smile: You are right that I don’t understand dialplans enough.

@alx: I think your recommendation makes good sense. I do understand the concept of how dialplans work and how to make them work together, but not enough to draw one custom. Do you have any tips/insight on the following:

Where / what file do I add the custom dialplan to? In the past I was creating a new [section] in extensions_custom.conf. Does the curl dialplan function go somewhere else?

Does the dialplan need to contain anything more than what I’ve put below? And do I even need the Wait(5) command if I don’t need to do anything with a response? (just need the URL parsed):
exten => _+1NXXNXXXXXX,2,(curl “${EXTEN}”)
exten => _X.,3,Wait(5)
exten => _X.,4,NoOp(CURL-RESPONSE: ${CURL})

Thanks so much for your expertise!

It needs to include a priority 1 line that matches the extension.

The wait is not needed. If the variable is set, it will be set synchronously.

The application name goes outside the round brackets.

[quote=“david55”]It needs to include a priority 1 line that matches the extension.

The wait is not needed. If the variable is set, it will be set synchronously.

The application name goes outside the round brackets.[/quote]

Thank you for the clarification. So here’s what I’ve got:

exten => _X.,1,curl(${EXTEN}&outbound=true)
exten => _X.,2,NoOp(CURL-RESPONSE: ${CURL})

Still need clarification on where this code goes? Does it stay in extenstions_custom.conf, or does it go in a different place? Can I put in below a new [section-with-random-name]?

I’ve put it under a section called [outbound-allroutes-custom] and after saving/reloading no outbound calls work (busy signal). Removing the code restores the ability to call.

This is very interesting how fragile the system is, even with basic functions like curl :smile:

Those are FreePBX questions. It needs to be in a context reachable from the context defined for the source device and the whole needs to be in extensions.conf, or a file included from it. FreePBX will add further constraints.

FreePBX is intended to be used primarily from the GUI.

You need to provide cli output because talking without a log is not enough.

Try this, in the extensions_custom file, over the [from-internal-custom] insert you code under a new context e.g.

exten => _XXXXXX.,1,curl(${EXTEN}&outbound=true)
exten => _XXXXXX.,2,NoOp(CURL-RESPONSE: ${CURL})
exten => _XXXXXX.,3,Goto(from-internal,${EXTEN},1)

exten => _1XX,1,Goto(from-internal,${EXTEN},1)

The last line is for your local extensions, if your extensions are from 101 to 105 this will handle dialing to other extensions. If not change the pattern to match the extensions range that you have in your box.

Last change the context of the extensions that you are using from from-internal to curl-out and try again.

CLI traces from FreePBX tend to be inpenetrable, which is why FreePBX questions should be asked on where they know about their dialplan, an its limitations.

SOLVED! - (somehow?)

alx : Thank you so much for the detailed information. I made the [new-section] and defined that in my context for internal extension. I see how the last line points internal calls to the next [context-section]; very clever.

So, I added the new dialplan above the [from-internal-custom] section in extensions_custom.conf, and then updated my extension to use the context [curl-out]. It didn’t work. Soooo, I opened up extensions_additional.conf and extensions.conf, just to look at how they called custom routes. I didn’t edit anything because I know those are auto generated.

I did notice that in the outbound routes it would call them in a specific order as input into the Outbound Routes section of the PBX. So for the heck of it I re-ordered the way I had them listed in the custom dialplan. Pretty sure I didn’t do ANYTHING else, and BOOM, now it works.

To make it even more unbelievable, I then re-ordered everything back to exactly the way I originally posted it in my first post, and it’s STILL WORKING!? It’s almost like I needed to temporarily put the [outbound-allroute-custom] section above the [from-internal-custom] section and/or open up the extensions.conf and _additional.conf files in order for them to realize I made changes to _custom.conf? Very weird.

Anyways, everything is back to working. Not sure if it was some other little change I didn’t realize I made, or just the order of operations, but I really appreciate the insight from you guys. I can only imagine how many other cool application usages you all know of.