I create a variable to treat a dialplan event via AMI and getting a strange issue because the same contexts are used for AMI calls and directly, but when I use via AMI a variable is defined and without AMI this variable didn’t exist the name of it is newCallerId the problem is that this variable is caching the last value and is getting a wrong path with a call make directly.
The question is: Asterisk save the value of the variable with different calls? Any tip how I can solve it?
Looks like the setVar from AMI define a global… anyone can confirm that?
Well. Basically I have this line in my PHP AGI script, this script uses libraries from PAMI on github project:
new SetVarAction(‘newCallerId’,‘’.$strCallerId.‘’,‘’.$canalDest.‘’)
This line define a variable called newCallerId that is used in my dialplan to validate and define a new callerId (only if is was defined), the issue is that sometimes this value should be empty and I noticed that is always with some value because it holds the last variable value.
I use a general context called [macro-user-callerid] that has this line:
I’m pretty sure your problem is because you don’t understand how things are supposed to work, but you haven’t provided enough detail to be able to work out exactly what you false assumption is.
Well, let me try to provide more information about my whole scenario.
Basically, I use AMI in 2 points and different situations:
1 - Use to start the first call that will call for one extension as an example we can suppose 1004 extension; When it attend the call automatically start a call for an external number XXXXXXXXX; When it attended a execute a second PHP script for transfer the call for another channel/extension, as example exten 1005; This is the script that is having problems.
2- The script for transfer use PAMI project and implements 2 methods: SetVarAction and RedirectAction transfer it’s working well, the issue is SetVarAction that is caching the last value defined, looing that defined it globally and then how I reuse the same context it’s causing trouble.
Can you understand the scenario? Is it a better description?
More information about the PAMI project can consult here: