FreePBX | Register | Issues | Wiki | Portal | Support

Execute AGI on AMI Originated Call

asterisk
Tags: #<Tag:0x00007f74a235d9f0>

(Jerry Riggin) #1

I need to use AMI (or maybe should be using ARI) to place outbound call and connect it to agent stations. It works, but I have 2 issues:

  1. The agent hears nothing until the call is answered, then asterisk blind transfers it to extension. I would like agent to hear dialing, ringing, etc.
  2. It does not seem that macro-dialout-trunk-predial-hook is being called so my AGI is not running.

Here’s the originate PHP code:

$call=array();
$call['Channel']="SIP/switch-out/0777$did';
$call['Exten']=$exten;
$call['Context']='from-internal';
$call['Priority']='1';
$call['ChannelId']=$uid;
$call['callerid']=$callerid;
$res=$astman->Originate($call);

Here’s my exensions_custom.conf entry:

[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(CUSTOM: Outbound ${EXTEN}  ${CALLERID(num)})
exten => s,n,AGI(cid-did.php)
exten => s,n,MacroExit()

I also tried the same in from-internal-custom and the AGI does not run. It runs fine on inbound with

[from-pstn-custom]
exten =>  _.,1,NoOp(Getting DID-CID)
exten =>  _.,n,AGI(cid-did.php)

So, how to get the AGI to run with an AMI originated call?

And, is there anyway to immediately connect the outbound call to the agent instead of waiting for connect?


(Lorne Gaetz) #2

The outbound leg should be to channel local@0777$did@from-internal, then it will use your outbound routes

Looks okay, assuming the AGI file works

Never (ever!) use from-pstn-custom. Use your own context that ends with a goto to from-pstn, and direct trunk calls to this new context. Every line you put in from-pstn-custom overwrites a line of generated FreePBX dialplan, and there is an early line that is critical for system security. Do not be lulled into this habit because it’s working in your tests.


[Solved] Keep Certain Extensions from Receiving Caller ID Completely?
(Jerry Riggin) #3

Thanks, Lorne. I did not know that from-pstn-custom was bad. I will change that and use your suggestions. I assume that will fix the AGI not running. Any suggestion on connecting the extension to the outbound call before the call is answered?


(system) closed #4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.