AMPUSER variables not populating appropriately

Can anyone tell me the requisite settings for ensuring proper AMP* lookup in the dial plan?

My specific scenario, I am initiating a call using the AMI Originate action. The function works. But, when the dialplan refers to AMPUSER variable, it returns no value where it should return the agent extension (channel) in the originate command.

– Executing [[email protected]:2] Set(“PJSIP/200-00000002”, “AMPUSER=”) in new stack

The only way I have been able to get the dialplan to return valid AMPUSER values is by setting the callerid value to “200” in the originate options.

– Executing [[email protected]:2] Set(“PJSIP/200-00000009”, “AMPUSER=200”) in new stack

In the CDR record, I see the src field as “200” (which is my end goal).

“”,“200”,“s”,“macro-dialout-trunk”,…

The problem is that the caller ID on the outbound call now becomes “200”. I need the caller ID on the outbound call to reflect the CallerID set on the trunk. So, I set the CallerID to the appropriate number and force the trunk callerID setting. But, the CDR record now records the trunk callerID.

“”,"(trunk cid)",“s”,“macro-dialout-trunk”,…

I would like to be pointed in the right direction, please.

Is your AGI run after this…

Originate is executed through the AMI instead of in an AGI script.

The first thing it does is ring pjsip/200

Once pjsip/200 answers, it calls (dialstring)@from-internal.

– Executing [(dial string)@from-internal:1] Macro(“PJSIP/200-0000000b”, “user-callerid,LIMIT,EXTERNAL,”) in new stack – Executing [[email protected]:1] Set(“PJSIP/200-0000000b”, “TOUCH_MONITOR=1436890938.176”) in new stack – Executing [[email protected]:2] Set(“PJSIP/200-0000000b”, “AMPUSER=”) in new stack

That’s when the macro-user-callerid is called.

On a working system, it does the same thing except that the lookup is successful.

Channel SIP/422-0000655b was answered.
– Executing [(dial string)@from-internal:1] Macro(“SIP/422-0000655b”, “user-callerid,LIMIT,”) in new stack
– Executing [[email protected]:1] Set(“SIP/422-0000655b”, “AMPUSER=422”) in new stack

The difference is that the non working system is FreePBX 12 and Asterisk 12 and the working system is using FreePBX 10 and Asterisk 10.

instead of calling pjsip/200 what happens if you call local/[email protected]?

When I call using local/200 it does make a difference. The AMPUSER value is correct even without the callerid assigned when the originate command is sent in to the AMI.

-- Executing [[email protected]:1] Set("Local/[email protected];1", "TOUCH_MONITOR=1436931440.347") in new stack
-- Executing [[email protected]:2] Set("Local/[email protected];1", "AMPUSER=200") in new stack

In order to achieve what I need to in the CDR, I still need to pass the callerid in with the originate command.

“”,“200”,“s”,“macro-dial-one”,…

Can you explain why local/200 is treated differently than pjsip/200 ?

Now, I need to resolve an issue with the dst field (always returns “s”). But, I will open another topic for that.