Greetings!
I have a system with FreePBX 16.0.40.7 and Asterisk 20.5.2.
I’m originating an AMI call with PHP via sockets, but it seems both macro-dialout-trunk-predial-hook (which is supposed to be called by FreePBX core automatically?) and the Asterisk AMI Originate parameter PreDialGoSub are failing to execute. We are using SIP (yes, I know it should be PJSIP and we’ll get around to that soon.)
Here is the core of the PHP:
I have confirmed all variables a populated correctly. Here is the sub dialouttrunkpredialhook which is just renamed from [macro-dialout-trunk-predial-hook] and modified to be a sub routine:
[dialouttrunkpredialhook]
With AGI debug on in the CLI and verbosity at 30 I do not see the NoOp or the AGI script being called. The call goes through with no issues. Can someone tell me what I am doing wrong?
If you’re expecting to use the FreePBX internals on your calls, then you need to use local channels for both legs of the originate. Not only will this ensure that the dialplan hooks get called, the calls will show up in CDRs, they will follow the recording rules you have set, etc.
For the outbound leg, you want to use Local/$DID@from-internal and for the inbound you would use Local/$EXT@originate-skipvm. More generally this would be Local/${dialed-digits}@${Context} where the priority is always 1.
As opposed to the way the AMI is configured above, it’s conventional to originate the call first to the local extension, ensure they answer, that the channel is up and only then dial the outbound leg of the call. This will ensure that any early media audio is not missed, and also ensures that the caller is not left with dead air if nobody is answering on the local side.
For those unfamiliar with the originate-skipvm context noted above, it’s a somewhat new context in FreePBX Core that allows you to originate to a local extension and prevent the call from being answered by the user’s voicemail, which you almost always want to avoid. When originating calls automatically, you need to anticipate whenever a call might be answered by a non-human and try to avoid that.
But the AMI response is “Error originating call. Check Asterisk logs for details.” But sadly, there is nothing in "/var/log/asterisk/full except “Successful Auth” that occurs when I login to AMI. Can you help me a little more?
This is incorrect. If the goal is to all the local extension and then dialout to the PSTN then this is completely backwards, plus the Exten setting is completely wrong. This is what it should look like:
Remember Exten, Context, Priority are used together. So the original originate would end up looking like when tryng to connect to Exten/Context/Priority…from-internal,$ext@originate-skipvm,1 < this is how Asterisk would put it together and it would fail.