I am using Asterisk, Laravel and PAMI for this, and I wanted make something that sends out a call that does the following:
- Plays a recording:"press 1 or 2"
- waits for user input
- plays a recording: "thank you"
- call ends
What I have so far is that it plays "press 1 or 2" then waits for input then closes. How do i add another recording after the input is pressed.
Laravel Fucntion that uses PAMI
public function makeCall($number, $playback): \PAMI\Message\Response\Response
{
$client = new ClientImpl($this->managerOptions);
$action = new OriginateAction("PJSIP/{$number}@$this->trunk");
$action->setAsync(false);
$action->setCallerId($this->callerId);
$action->setExtension($number);
$action->setContext($this->context);
$action->setPriority(1);
$action->setVariable('REC', $playback);
$client->open();
$res = $client->send($action);
$client->close();
return $res;
}
Dail Plan
[robo_call]
exten => _X.,1,NoOp(Starting dial OTP)
same => n,Set(CHANNEL(language)=bykea_robo_call)
same => n,read(inputd,${REC},1,n,1,8)
same => n,Hangup()
Thats called IVR and almost any book describe it.
AMI is not correct way do it.
You should use (FastAGI) or async ARI protocol.
In AMI only thing you can do is issue some event via
application.
After that catch it in AMI and move dialplan to another entry point, but that will be crazy inefficient.
https://docs.asterisk.org/Configuration/Interfaces/Asterisk-REST-Interface-ARI/
https://phpagi.sourceforge.net/