Pass Variable in originate Command

How to pass variable through AMI in asterisk via single originate command

Originate Local/$Depsplit@myoutbound extension s@Dialoutco

Any help?

You can’t set variables using the originate CLI command.

For the Originate AMI action it allows setting variables[1].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+ManagerAction_Originate

I am using AMI to originate but how to pass variables using below command
Originate Local/$Depsplit@myoutbound extension s@Dialoutco

That’s a CLI command, not an AMI action. As I stated you can not set variables using the CLI command.

Can i use like this?

fputs($oSocket “Action: Originate\r\n”);
fputs($oSocket, “Channel: Local/$Depsplit\r\n”);
fputs($oSocket, “Context: myoutbound \r\n”);
fputs($oSocket, “Exten: s\r\n”);
fputs($oSocket, “Priority: 1\r\n\r\n”);
fputs($oSocket, “Variable: LANGUE=$langue\r\n”);
fputs($oSocket, “Timeout: 10000\r\n”);
fputs($oSocket, “Async: true\r\n\r\n”);

Yes, I think that would work but I haven’t used it in a long time - so you should just try it and see.

ok i will try the same … Thanks @jcolp

Actually i am using two context to originate from an local channel …

How to write via AMI?

I don’t know what “using two contexts” means. The CLI command and the AMI action act the same.

I am using like this
fputs($socket, “Action: Originate\r\n”);
fputs($socket, “Channel: Local/”.$Depsplit."\r\n");
fputs($socket, “Context: myoutbound\r\n”);
fputs($socket, “Exten: s\r\n”);
fputs($socket, “Context: Dialoutco\r\n”);
fputs($socket, “Priority: 1\r\n\r\n”);
fputs($socket, “Variable: LANGUE=$langue\r\n”);

Could i able to use two ‘Context’ …One for source and another for destination

You specify an extension and context for the Local channel, and you specify one for the Originate.

can u please correct me the syntax for using the same?

It’s the same as the originate CLI command.

fputs($socket, “Channel: Local/”.$Depsplit."@myoutbound\r\n");

Your syntax is correct. The context is contained in one of your variables.

wow great ! this one is working but variables {variable1} is empty

fputs($socket, “Action: Originate\r\n”);
fputs($socket, “Channel: Local/”.$Depsplit."@myoutbound\r\n"); fputs($socket, “Exten: s\r\n”);
fputs($socket, “Context: Dialoutco\r\n”);
fputs($socket, “Priority: 1\r\n\r\n”);
fputs($socket, “Variable: variable1=”.$conference_no.",variable2=".$Schedule_Id."\r\n");

Use different lines for the variables:

fputs($socket, “Variable: variable1=”.$conference_no."\r\n");
fputs($socket, “Variable: variable2=”.$Schedule_Id."\r\n");

As well make sure in your AMI script that the variables are set. Finally you’ll need to specify on which channel you are trying to use them. A Local channel has two.

How to check the variables are set in AMI Script Channel or How to specify variable on channel?..

You would normally add code to your AMI script/application which outputs the variables to a log file or console to confirm their existence. You could also look at the AMI traffic to verify the action that was actually sent and if it contains the expected information.

If you don’t inherit the dialplan variable then it will exist on the first Local channel I believe. Not the one doing the dialing. Within the dialplan you can also use NoOp to verify the variables.

Where to see the log files that outputs the variable through AMI?

Still i am not getting the variable in dialplan by using NoOp()

any help?

I don’t use AMI often so I don’t recall if there is such a thing. My previous comment was about doing basic troubleshooting on your AMI script side. You can also do a packet capture to see the AMI traffic itself as it flows.