Can someone give me some advice. Our clients have existing web application, in their form you can input code and hit enter and display information of customer base on the inputted code, now the client want us, if there is incoming call, they want to display automatically the code and show the information of the customer.
can someone help me on this how to achieve or please advice me what other work around.
There are probably multiple ways this could be handled, but I’ll mention one:
Create an AMI application that’s tied into the web application and listens for events. For instance, in your case you might want to listen for the dial end event. When this event is received you can check the DialStatus to see if it was answered or not. If answered then you can use one of the other fields like exten to correlate it to the customer code. Once a customer code is matched then you can display the appropriate information to the client.
I have achieved this task using AMI events specially newchannel event , Then using PHP you can save the event values in an array and fire a post back to your remote web app with the needed information, using the PHP functions file_get_contents or curl to your remote web app, the variables extacted from the AMI event will be avaiable on the global array $_POST OR $_GET depending on the method use to make the post back usually the GET method
Thank you for the reply…Yes I am using php. can you please show me simple example how to do this so that I can have some idea and guide… I haven’t used AMI events or the API ?. please help me I really need your help.
Update: So my web application browser is always open so that the in-charge or the one who answers the incoming call can see the customer information automatically.this is what I want I hope you can help me.
On the command line you run the script and the event to catch it will output the event in this case 2 events are fire are make or recive a call, one for the sip device making the call and the other for the sip trunk device used to make the call
php event_catch.php Newchannel
Event: Newchannel
Privilege: call,all
Channel: SIP/101-00000002
ChannelState: 0
ChannelStateDesc: Down
CallerIDNum: 101
CallerIDName:
ConnectedLineNum:
ConnectedLineName:
Language: en
AccountCode:
Context: home
Exten: 13052341212
Priority: 1
Uniqueid: 1493266023.6
Linkedid: 1493266023.6
Event: Newchannel
Privilege: call,all
Channel: SIP/paco-00000003
ChannelState: 0
ChannelStateDesc: Down
CallerIDNum:
CallerIDName:
ConnectedLineNum:
ConnectedLineName:
Language: en
AccountCode:
Context: from-trunk
Exten: s
Priority: 1
Uniqueid: 1493266023.7
Linkedid: 1493266023.6
NOTE: you can catch any event fired by asterisk just need to run the php script on the command line and the event name
Thank you for the reply and giving example…can I ask the php file that you use socket is that event_catch.php ? is this resides in my web app folder ?..also where should I put this Event,privilege and etc… I am confuse. please help me.
Event: Newchannel
Privilege: call,all
Channel: SIP/101-00000002
ChannelState: 0
ChannelStateDesc: Down
CallerIDNum: 101
CallerIDName:
ConnectedLineNum:
ConnectedLineName:
Language: en
AccountCode:
Context: home
Exten: 13052341212
Priority: 1
Uniqueid: 1493266023.6
Linkedid: 1493266023.6
Event: Newchannel
Privilege: call,all
Channel: SIP/paco-00000003
ChannelState: 0
ChannelStateDesc: Down
CallerIDNum:
CallerIDName:
ConnectedLineNum:
ConnectedLineName:
Language: en
AccountCode:
Context: from-trunk
Exten: s
Priority: 1
Uniqueid: 1493266023.7
Linkedid: 1493266023.6
Sorry I tried to be as clear as possible, And I was expecting at least you have the basic PHP and Asterisk knowledge. But based on your response to my last post, you re far to understand ,what I was talking about. I dont ask you to be an expert, because if so you wont be here asking for help. But at least you should have basic knowledge of the technoly involved on this process.Sorry But I cant do nothing more beyond what I did.
But Anyway I will do the google search for you , and I will post the information you need read in order to understand my approach
Thank you for the reply…I know php but asterisk I have little knowledge for this.I just started 3 days in asterisk… I am just confuse of Event, privlige, channel. is that the response in socket when we are connected in asterisk ?
Yes, that is a reponse sent from Asterisk to the PHP script , that response is an event in my example there are 2 events. You will insert that reponse into an array and you will fire the needed array values to your web app. In the other hand have if you just have 3 days using Asterisk you should learn the Asterisk basic http://www.asteriskdocs.org/ and once you can handle basic stuff you can jump to advanced contexts like AMI events. But what you are trying to do is equivalent on programming ,trying to create your own class without at least know how to at least declare a variable
Hi, Okay, I thought the php file will be put inside in the asterisk server…because when I had the test the text to speech in the tutorial if followed I put the php script inside in asterisk and I can connect to …but in your case my listener is in my web application folder.
Can I ask I’m not clear with the socket where should I run this or put this in my web server where my web app resides or in the asterisk ? because in asterisk I can also put php files.
Thank you for the reply and some steps I will try these…by the way can I ask, Is this like socket your program will connect to asterisk ?. using i.p and port ?