OUTbound Caller ID lookup HTTP query

General discussions about Asterisk.

Moderators: Moderator, Support

OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Wed Jul 29, 2015 11:55 pm

Hi there everyone,

This is only my second post on here; last time you guys were super helpful. Long story short is I'm trying to get our Asterisk System to integrate with our web app CRM system for outbound calls we make. I'm not sure if what I'm looking for exists, but I figured that someone could at least point me in the right direction. Here's the details of what I'm trying to accomplish:

Our web app CRM system currently provides an HTTP caller ID look up string. Our PBX seamlessly uses this for a caller ID look up source; which pulls the "customer name" from our CRM database, to provide a caller ID for incoming phone calls. Additionally, when that caller ID look up source is queried, it makes a note in the customers account that they called in (it doesn't detect the call, it just assumes they called because the web query was accessed).

What I'm trying to accomplish is exactly the opposite. I'd like to run the same type of web query when we making outbound phone call. I'd like our PBX to run a simple HTTP command or parse a URL upon making outbound phone call. We would then be able to use a similar caller ID web query to detect when we make outbound phone calls to customers; therein automatically noting in our CRM software that we called.

This must be something that either Asterisk or a third-party plug-in can do, right? Any insight or direction would be greatly appreciated. Cheers!
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby ambiorixg12 » Sat Aug 01, 2015 12:08 am

Use curl() function in your outbound dialplan before dial()
ambiorixg12
Astmaster
 
Posts: 967
Joined: Sun Mar 04, 2007 9:32 pm
Location: Dominican Republic

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Sat Aug 01, 2015 11:07 pm

Thanks! I'll look into that function. Do you have an examples of having used this?
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby ambiorixg12 » Sun Aug 02, 2015 11:31 am

exten => *764,1,Verbose(2, Run CURL to get IP address from ifconfig.me)
same => n,Answer()
same => n,Set(MyIPAddressIs=${CURL(http://ifconfig.me/)})
same => n,SayAlpha(${MyIPAddressIs})
same => n,Hangup()



Also you can use the Linux curl command


exten =>_X.,1,System(curl https://www.edcmeals.com/voip/confirmation.tpl -G -d"ordernumber=${order}&response=4")
ambiorixg12
Astmaster
 
Posts: 967
Joined: Sun Mar 04, 2007 9:32 pm
Location: Dominican Republic

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Sun Aug 02, 2015 4:45 pm

@ambiorixg12:

I just wanted to thank you for the excellent information! cURL was exactly what I was looking for and I'm so glad that function existed. It was even built into CentOS, which was awesome.

I didn't specify it, but I don't need the cURL function to retrieve any information, I just need it to load a URL and then ignore the result. (Because simply loading the URL will add the information to my CRM system). But the other issue I'm not sure of is if I'll be able to insert a variable for "the phone number being dialed".

My questions:
What do I use to reference the variable of the number we are dialing out?
If I'm running Elastix 2.4 on CentOS, would you recommend your first or second option?
Which file do I edit to modify the master outbound dial plan?
Why did you specify *764 as the extension / feature code?
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby ambiorixg12 » Sun Aug 02, 2015 5:07 pm

1)What do I use to reference the variable of the number we are dialing out?
2)If I'm running Elastix 2.4 on CentOS, would you recommend your first or second option?
3)Which file do I edit to modify the master outbound dial plan?
4)Why did you specify *764 as the extension / feature code?



1) ${EXTEN}

2) As you will be sending jut info and not retreving info back, you can use either one of them. I prefer the Linux curl cmd

3)/etc/asterisk/extension_custom.conf do your own outbound dial plan.

4)replace *764 for the pattern that match your outbound route, you could use _x.
ambiorixg12
Astmaster
 
Posts: 967
Joined: Sun Mar 04, 2007 9:32 pm
Location: Dominican Republic

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Sun Aug 02, 2015 9:28 pm

Okay, I think I got it...

I'm going with the Linux curl cmd, added a new line at the bottom of /etc/asterisk/extension_custom.conf as a new dial plan. Replaced *764 with _x. And you said ${EXTEN} is the replacement for the phone number variable we are dialing (which will change every time), so here's what I've got:

exten =>_X.,1,System(curl http://cidlookup.mywebsite.com/api/callerid/?did=${EXTEN})

So, ${EXTEN} will correlate to the DID that I am dialing when making an outbound call? I'm just confused why it's called EXTEN rather than DID...

Lastly, what is this part (below) for? I don't have an order number. And I don't need to get a response from the web query. So do I just leave this part off?:

-G -d"ordernumber=${order}&response=4"
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Sun Aug 02, 2015 9:41 pm

WOW! IT WORKS! AMAZING!

Adding this to the bottom of our extensions_custom.conf parses the website and replaces ${EXTEN} with the phone number we are calling. Exactly what I needed:

exten =>_X.,1,System(curl http://cidlookup.mywebsite.com/api/callerid/?did=${EXTEN})

Thank you, Thank you, Thank you :)
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Tue Aug 04, 2015 2:50 pm

Okay DARN it! Ran into a small issue,

Now when making outbound phone calls, our CID is always displaying our "main/default" CID every time; regardless of what we have set for the extension's individual CID mask.

Scenario:
Ext 101 should have CID 7275551111
Ext 201 should have CID 7275552222
Ext 301 should have CID 7275553333
But, now all extensions are showing the same CID (7275551111)

Removing the new cURL lookup from our extensions_custom.conf restores everything to working order, but obviously we still want that.
cURL we are using:
exten =>_X.,1,System(curl http://impact.repairshopr.com/api/callerid/?did=${EXTEN})

Question: What did I do wrong with the custom cURL that causes the PBX to ignore extension specific CID, and uses our "main" CID set in general?

Thanks!
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Tue Aug 04, 2015 4:29 pm

BLAH. Another issue found :(

With that custom outbound route added, we're unable to answer calls using the "call confirm" option. The message plays saying "You have an incoming call. Press 1 to accept..." but it doesn't detect us pressing 1 or 2 or anything.

It sounds like I either need to ADD this code into an existing dial route, I need to add MORE lines of instructions to the route to utilize CID and Call Confirm options.

Advise?
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Wed Aug 05, 2015 4:25 pm

@ambiorixg12: Any ideas? Maybe we should try using the first dial plan option you mentioned? But not sure what needs to be edited/added to get the same result... It was nice how simple the Linux command was; it's just missing something...

exten => _X.,1,Verbose(2, Run CURL to get IP address from ifconfig.me)
exten => 2,Answer()
exten => 3,System(curl http://cidlookup.mywebsite.com/api/callerid/?did=${EXTEN})
exten => 4,Hangup()

Something like that ^ ? Would it be better/easier to ADD a line with cURL into an existing dial plan? So close! Hoping you can help :)
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby ambiorixg12 » Wed Aug 05, 2015 10:55 pm

The 2 issues that you have mentioned are not related to the curl command. It happens because are missing necessary steps to make the system works as you are expecting.

the callerid issue could be easily solved using like this

exten=>_x.,1,Noop(${CALLERID(NUM)})
same=> n,ExecIf($["${CALLERID(NUM)}"= "101"]?Set(CALLERID(all)=MY-COMPANY-NAME< 7275551111>))
same=>n,Dial(SIP/${EXTEN}@${mytrunk})

the other issue I dont really understand what you mean,
ambiorixg12
Astmaster
 
Posts: 967
Joined: Sun Mar 04, 2007 9:32 pm
Location: Dominican Republic

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Thu Aug 06, 2015 11:15 am

ambiorixg12 wrote:The 2 issues that you have mentioned are not related to the curl command. It happens because are missing necessary steps to make the system works as you are expecting.

the callerid issue could be easily solved using like this

exten=>_x.,1,Noop(${CALLERID(NUM)})
same=> n,ExecIf($["${CALLERID(NUM)}"= "101"]?Set(CALLERID(all)=MY-COMPANY-NAME< 7275551111>))
same=>n,Dial(SIP/${EXTEN}@${mytrunk})

the other issue I dont really understand what you mean,



Thanks for the reply @ambiorixg12.

So originally I was using the one-line Linux curl command, which was really simple and easy. At this point (to get CID working properly) do I need to use a multi-line dial plan?

And I'm having a hard time understanding the second line in the above dial plan. I don't want to specify a CID for each extension; I was the dial plan to reference whatever the extension's CID is set to. Does what you have set specific CID's for specific extensions, or am I just not understanding?

Thank you again for your assistance.
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Thu Aug 06, 2015 1:06 pm

Ok, quick update. I've fixed one of the two problems (extension specific CID for outgoing calls).

When dialing out, our CID was showing as the "default global" CID because the dial plan did not specify to use the default macro which is normally in front of outgoing calls per extension. Adding this line as the first line fixed that:

exten => _X.,1,Macro(user-callerid)

Also found that using "same" in place of "exten" accomplished this, but then it's appending to the proceeding dial plan, and I think this should be separate? So, here's where I'm at now:

exten => _X.,1,Macro(user-callerid)
exten => _X.,n,System(curl http://impact.repairshopr.com/api/callerid/?did=${EXTEN})
exten => _X.,n,Answer

So, now we're back to working, but I still cannot answer calls sent to followme numbers with call confirm. It must be something to do with another line allowing me to input an answer for followme. Working on that now. :)
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Thu Aug 06, 2015 3:58 pm

Now I'm even more unsure of how to get this to function. It looks like the best way might be to add this code to an existing dial plan on behalf of the "include -custom" line. That will preserve all the normal rules/settings. But, which existing dial plan should I add these line to?

[ext-local-custom] OR [outbound-allroutes-custom]

I've tried adding it to [outbound-allroutes-custom] but it doesn't seem to work there. Tried all of these combinations:
exten => _X.,n,System(curl http://impact.repairshopr.com/api/callerid/?did=${EXTEN})
exten => _X!,n,System(curl http://impact.repairshopr.com/api/callerid/?did=${EXTEN})
exten => _X.,1,System(curl http://impact.repairshopr.com/api/callerid/?did=${EXTEN})
exten => _X!,1,System(curl http://impact.repairshopr.com/api/callerid/?did=${EXTEN})
same => _X.,n,System(curl http://impact.repairshopr.com/api/callerid/?did=${EXTEN})
same => _X!,n,System(curl http://impact.repairshopr.com/api/callerid/?did=${EXTEN})
same => _X.,1,System(curl http://impact.repairshopr.com/api/callerid/?did=${EXTEN})
same => _X!,1,System(curl http://impact.repairshopr.com/api/callerid/?did=${EXTEN})

PS. The issue with call-confirm appears to be a bug. Sometimes I can answer the call-confirm, other times I cannot; with and without this curl command. Blah :/
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby navaismo » Thu Aug 06, 2015 6:55 pm

Using FreepBX based systems is kind tricky when it is about editing files. So if you are not sure how things are working you have to do 2 things at least.

The first one is take a deep look in your asterisk cli to see what is happenning when you call out or call in or whatever, after following line by line you will be able to edit the proper portion of code.

The second one is to decide if you want to add things in the extensions_custom.conf file by including your code in the the *_custom contexts or editing the extensions_override.conf file. If you choose the override method you will able to add lines to the existing code in the extensions.conf file(the additional) where lays all the dailplan. You only need to copy the wholecontext and add/remove the desired lines and put into the override file. In that way you preserve the changes even after updated or reload.

So my advice is to stoip guessing and start to look at your cli and your outgoing dialplan once you have the location use one of those files(override or custom) and make your changes.
navaismo
Salt of the Asterisk
 
Posts: 1610
Joined: Mon Dec 07, 2009 1:30 pm
Location: Mexico City, Mexico

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Fri Aug 07, 2015 4:08 pm

navaismo wrote:Using FreepBX based systems is kind tricky when it is about editing files. So if you are not sure how things are working you have to do 2 things at least.

The first one is take a deep look in your asterisk cli to see what is happenning when you call out or call in or whatever, after following line by line you will be able to edit the proper portion of code.

The second one is to decide if you want to add things in the extensions_custom.conf file by including your code in the the *_custom contexts or editing the extensions_override.conf file. If you choose the override method you will able to add lines to the existing code in the extensions.conf file(the additional) where lays all the dailplan. You only need to copy the wholecontext and add/remove the desired lines and put into the override file. In that way you preserve the changes even after updated or reload.

So my advice is to stoip guessing and start to look at your cli and your outgoing dialplan once you have the location use one of those files(override or custom) and make your changes.


Thanks @navaismo! That makes a lot of sense. Fortunately, I lucked out and (with hours of guessing and checking) was able to find a combination that did all of the following:

- Works with all existing dial plans
- Doesn't perform curl lookups from incomplete numbers
- Preserves the plan's order of operations
- Preserves the extension specific CIDs
- Doesn't break 2-way audio

It all came down to misuse of the order of "n" or "1", and the use of "same" instead of "exten". Here is the end result that does everything we needed (in the extensions_custom.conf file):

[outbound-allroutes-custom]
exten => _NXXXXXX,2,System(curl http://outcid.mywebsite.com/api/callerid/?did=${EXTEN})
exten => _NXXNXXXXXX,2,System(curl http://outcid.mywebsite.com/api/callerid/?did=${EXTEN})
exten => _1NXXNXXXXXX,2,System(curl http://outcid.mywebsite.com/api/callerid/?did=${EXTEN})
exten => _+1NXXNXXXXXX,2,System(curl http://outcid.mywebsite.com/api/callerid/?did=${EXTEN})

Also, at one point when it was necessary, I found the macro object to reference to fix extension specific CID:

exten => _X.,1,Macro(user-callerid)

Bottom line, it WORKS and I appreciate everyone's help. So nice to have this!
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Fri Jan 15, 2016 12:26 pm

Hi again everyone! Just wanted everyone to know this is still working 100% AWESOME for us with our CRM system. It's helped our communication SO much to have outbound calls automatically logged and tracked inside of support tickets. Being able to see the play-by-play of emails/calls in order is a lifesaver. Thanks again for all of the help! Now, a small follow-up to this topic:

Just to recap, our final working code we're using in our dial plan is this:
Code: Select all
exten => _+1NXXNXXXXXX,2,System(curl http://cid.mywebsite.com/api/callerid/?did=${EXTEN})&outbound=true


And after receiving the curl data from our PBX, the output that our CRM system provides this:
Code: Select all
Technician called out to phone number 17275551234


The CRM also works as a CID Lookup Source in the PBX, using the same HTTP string:
Code: Select all
http://cid.mywebsite.com/api/callerid/?did=${EXTEN})


Which posts similar output to our CRM system, related to incoming calls:
Code: Select all
Customer called in from phone number 17275551234


Sooo, what I'd like to know is what are some other "variables" we can have the PBX send via the curl command? Like, is there something like ${DID} or ${DATE/TIME} or some other useful data we can send to our CRM? Most urgently, we'd like it to send the data about which DID the customer is calling into. We have several different DIDs for each location, but they all report to the same CRM. It would be helpful to know which number the customer is calling so we know where their call connected to. Effectively, we'd like our CRM to output something like this:

Code: Select all
Customer called in from phone number 17275551234 using line 18009995000


Thanks again for everyone's knowledge and insight!
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby ambiorixg12 » Sat Jan 16, 2016 1:10 am

There are variables that are automatically set by Asterisk. For example, the called number is always stored in the Asterisk system variable ${EXTEN}

check this list for a full reference http://www.voip-info.org/wiki/view/Aste ... iable+List
ambiorixg12
Astmaster
 
Posts: 967
Joined: Sun Mar 04, 2007 9:32 pm
Location: Dominican Republic

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Sat Jan 16, 2016 11:37 am

Thanks again @ambiorixg12. I've come across that wiki in the past and was unsure if all of those were available. I'm a little confused and could use some clarification between the following 3 variables, as they don't seem to be what I'm accustom to:

${EXTEN} : As you said, this is the dialed number for outbound calls, so what will give me the actual user extension number that initiated the call? (eg. Extension 119)

${DNID} : This says "dialed number identifier". Is this what I'm looking for to show the number the customer is dialing when calling into us? I figured it would just say ${DID} or something...

${CALLERID} : Isn't this the customers phone number on incoming phone calls?
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby ambiorixg12 » Sat Jan 16, 2016 1:39 pm

Here is a graphical example :

device extensions 102 dialed the number 56699 on context myvars, check below the values for each variable.

[myvars]
exten=>_x.,1,Noop( /${EXTEN}/ /${CALLERID(num)}/ /${CALLERID(dnid)}/)
same=>n,Hangup()



-- Executing [56699@myvars:1] NoOp("SIP/102-0000014e", " /56699/ /102/ /56699/") in new stack
-- Executing [56699@myvars:2] Hangup("SIP/102-0000014e", "") in new stack
ambiorixg12
Astmaster
 
Posts: 967
Joined: Sun Mar 04, 2007 9:32 pm
Location: Dominican Republic

Re: OUTbound Caller ID lookup HTTP query

Postby pinellascompute » Mon Jan 18, 2016 8:34 am

-- Executing [56699@myvars:1] NoOp("SIP/102-0000014e", " /56699/ /102/ /56699/") in new stack
-- Executing [56699@myvars:2] Hangup("SIP/102-0000014e", "") in new stack


So basically, you were dialing the number 56699 from your internet extension 102? But what variable can I use to show the outside-facing DID (masked as CID) that a customer sees? Like, internally, you're extension 102, but externally you'd be a number like 18005551234. How can I return that for use in our CRM?
pinellascompute
Newsterisk
 
Posts: 20
Joined: Tue May 28, 2013 10:59 am

Re: OUTbound Caller ID lookup HTTP query

Postby ambiorixg12 » Mon Jan 18, 2016 9:09 pm

On FreePBX you have 2 commun ways to set up the outbound caller id ,On the outbound route you have the field called Route CID and on the extensions you have the field (Outbound CID). I would need to to spend a few minutes watching the FreePBX logs to catch the variables holding those values. We don't support FreePBX or any other third party GUI on this forum, but with this information you are good to go.
ambiorixg12
Astmaster
 
Posts: 967
Joined: Sun Mar 04, 2007 9:32 pm
Location: Dominican Republic


Return to Asterisk General

Who is online

Users browsing this forum: Google [Bot] and 3 guests