Is it possible to originate the call from AMI and play a voice file and receive the DTMF?

Hi, a very good afternoon to all of you !!!

how can we originate outbound call by php AMI ,play voice file and store the DTMF enter by caller(call receiver) by using php AMI or by dialplan and if possible then shared the document and if you have any other idea then also shared ,b’coz i have tried so many time but didn’t get any success. I am using below mention code but i am not understanding the what should be added to do my task i.e how can i got dtmf on outgoing call ?
my testing code is given below

<?php $port = 5038; $username = "asterisk"; $context = "12345"; $socket = stream_socket_client("tcp://localhost:5038"); if($socket) { echo "Connected to socket, sending authentication request.\n"; // Prepare authentication request $authenticationRequest = "Action: Login\r\n"; $authenticationRequest .= "Username: asterisk\r\n"; $authenticationRequest .= "Secret: 12345\r\n"; $authenticationRequest .= "Events: on\r\n\r\n"; // Send authentication request $authenticate = stream_socket_sendto($socket, $authenticationRequest); if($authenticate > 0) { // Wait for server response usleep(200000); // Read server response $authenticateResponse = fread($socket, 4096); // Check if authentication was successful if(strpos($authenticateResponse, 'Success') !== false) { echo "Authenticated to Asterisk Manager Inteface. Initiating call.\n"; $originateRequest = "Action: Originate\r\n"; $originateRequest .= "Channel: SIP/tatasip/${Exten}r\n"; $originateRequest .= "Callerid: 7582963145\r\n"; $originateRequest .= "Application: Playback\r\n"; $originateRequest .= "Data: /usr/file\r\n"; $originateRequest .= "Context: amitest\r\n"; $originateRequest .= "Exten: 91111\r\n"; fputs($socket, "Account:23456\r\n" ); $originateRequest .= "Priority: 2\r\n"; $originateRequest .= "ActionID: 123\r\n"; $originateRequest .= "Async: yes\r\n\r\n"; $originate = stream_socket_sendto($socket, $originateRequest); } // Send originate request // $originate = stream_socket_sendto($socket, $originateRequest); if($originate > 0) { // Wait for server response usleep(1000); while(true) { // Read server response $originateResponse = fread($socket, 4096); echo $originateResponse . "\n"; } $responce=fgets($socket,4096); echo $responce."\n"; // Check if originate was successful if(strpos($originateResponse, 'Success') !== false) { echo "Call initiated, dialing.\n"; } else { echo "Could not initiate call.\n"; } } else { echo "Could not write call initiation request to socket.\n"; } } else { echo "Could not authenticate to Asterisk Manager Interface.\n"; } } else { echo "Could not write authentication request to socket.\n"; } //else { echo "Unable to connect to socket."; //} echo $originateResponse; ?>tttt.txt (2.9 KB)

Isn’t this a duplicate of a previous question from your company?

No this is new question,i want to get DTMF on outgoing call only by PHP AMI not from PHP AGI, Sir please guide me what should be added to store the DTMF on outgoing call buy using php AMI only.

It seems will be needed to make a youtube video or an step by step guide for this task, I dont undestand why people get stuck with this simple task

sir is it possible to store the DTMF during outgoing call by using PHP AMI? if you dont mind sir plz share the link of youtube so that i’ll get any help of those link and complete my task asap. thanks you so much for your suggestion and guidance and also thanks in advance for you valuable reply…

If you need to complete your task ASP, I suggest you hire an specialist. Because I will do that video once I have time

Related to your request use Ami Oritinate Action and local channel also use Asterisk Read() app to store the DTMF value in a variable and System() to save that variable in a DB , Text file or any other destination

This is just one of of the trillions of ways thawt exist to complete this task

Thanks you sir but sir, i want to do this, himself and don’t want to do this task to anyone …for advance learning i want to do this himself and i’ll do this …so there is a humble request to you pleas guide me if i made any mistake or stuck anywhere in coding …once again thanks and sir you know that learner make a lot of mistake like “Edison make a lot mistake and finally made the bulb”…so please guide me only and i’ll do this in such manner.

Also :
Edison read a lot books before make the bulb

Edison also was patient and took all the necessary time to learn the technologies involved for he make the bulb

So if you really want to do this for learning purposes, why you ask to do this ASP.

I already gave you a method of how to do it ,now is you work to start learning your self

1 Like

Edison couldn’t ask his local lamp filament manufacturer for advice on how to make light bulbs with their product!

1 Like