AMI Action ATXFER setting Variables not working

I’m trying to set some variables on AMI atxfer action command the following way

ami.action({
                'Action': 'Atxfer',
                'Channel': channel_id,
                'Exten': `Local/${to}@${rec.context}`,
                'Variable': {
                    'IFI_UUID': session_id,
                    'IFI_AGENT': rec.username,
                    'IFI_DID': rec.caller_id,
                }
            }

Call is being transferred correctly, but newly set variables are not working, instead it’s carry-forwarding the previous variables. Any way to set new variabless by any means?

Update: The call is not routing through rec.context valiable I passed. Instead, it’s going through internal context. I’m getting log like this Local/9999999999@from-internal-xfer-00000dc3

I also tried to inherit the variables key as @khamlichi.khalil suggested. But, no luck.

I believe a transfer is carried out on a newly created channel, so you newly set variables are set there and not in the new where the transfer is actually made, you could try to :
1/ add __ to all the vars (IFI_UUID → __IFI_UUID) to allow inheritance of those variables.
if this does not solve it you could try :

1/ set variable TRANSFER_CONTEXT = “my_attxfer_context” on the call
2/ add __ to all the vars (IFI_UUID → __IFI_UUID)
3/ inside my_attxfer_context reset the vars again or do any logic you see fit

None of these worked. I updated the question with what I tried and the update.

That AMI action[1] has no such functionality to set variables. It would need to done some other way. As well it’s exten and context, in the dialplan.

[1] Asterisk 18 ManagerAction_Atxfer - Asterisk Project - Asterisk Project Wiki

I think that error comes from the common failure to understand that an extension, in Asterisk, is only what appears to the right of “exten=>” in the dialplan. Almost everyone here uses extension to refer to devices, as does FreePBX.

after this comment :

That AMI action[1] has no such functionality to set variables. It would need to done some other way. As well it’s exten and context, in the dialplan.

you can use manager action SetVar along with TRANSFER_CONTEXT (you need to create this context in your dialplan)

1 Like

Yes, I did the same to achieve my goal, finally.

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