No Recording by Extension when using AMI to originate call

I have a click to call app that uses AMI to originate the call. The way it works is that it originates the call and then connects it to the agent extension. I’ve set the recording to be forced at the extension level. What I have noticed is that the recording doesn’t happen. When I look at the CDR it shows the external phone number for both the destination and source. That seems to me is why it’s not recording because it never matches the extension rule to force the recording.

The existing code is as follows:
$channel = “SIP/” .$user->sip_extension; // $user->sip_extension is something like, “202”.
$context = “from-internal”;
$priority = 1;
$extension = Input::get(‘phone_number’); // Where phone_number is the user’s extension, e.g. 202.
$am->Originate($channel, $context,

-----------end snip-------

We tried the following code:

$channel = " Local /".$user->sip_extension.”@from-internal”;
----------end snip---------

In the case of the first snip, we don’t get the call recording because it shows the external number as the source and destination. In the case of the second snip it does properly record the call however, if the internal user fails to pick up the call, it will go to their voicemail and connect that to the external number, which isn’t desired at all.

We are using FreeePBX

Any suggestions?

Forced inbound or forced outbound?

The call from your AMI script is now an inbound call, even though is appears that you are initiating the call. Make sure you are forcing the recording in both directions.

You are on the right track. Instead of initiating the call to [email protected], you need to create your own context in extensions_custom.conf that calls Macro(blkvm-setifempty,) then goes to from-internal.


I have both Inbound External Calls and Outbound External calls set to force. I also have the same for Inbound Internal and Outbound Internal because I noticed previously that without the internal calls forced, a call that gets transferred to another extension will stop recording,

Would you be able to provide an example of your suggestion? Thanks in advance.

It’s extremely complex, so I hope it doesn’t look too overwhelming :slight_smile:

exten => _X.,1,Macro(blkvm-setifempty,)
exten => _X.,n,goto(from-internal,${EXTEN},1)
1 Like

I tried your code and it didn’t work at all. When the user clicks on the dial button, it should call the user but that doesn’t happen when we change the context to novm-dial from from-internal. Any suggestions?