Get Channel Variables In AMI Event NewExten

Home » Asterisk Users » Get Channel Variables In AMI Event NewExten
Asterisk Users 3 Comments

Hi, I’m stucked in situation, and look for a work around if possible in Asterisk. I have a dialplan,

[default]
exten => 111222,n,Set(fu_callerid=141688xyxzz)
exten => _X.,n,NoOp(Callerid ${fu_callerid})
exten => _X.,n,wait(2)
exten => _X.,n,Answer()

3 thoughts on - Get Channel Variables In AMI Event NewExten

  • I believe you will have to monitor for the Newexten event, then send an AMI Getvar command.

    It doesn’t make sense to pass all the possible channel variables along with a Newexten event. There may be a ton of extra variables that someone may not want or need on the AMI. Better to have them ask for specific variables that are not standard.

    Action: Getvar ActionID: ValueYouCanIdentify Channel: IAX2/X.X.X.X:4572-5011
    Variable: fu_callerid

    This will result in a response from AMI…

    Response: Success ActionID: ValueYouCanIdentify Variable: fu_callerid Value: 141688xyxzz

    The ActionID is very important if you want to watch for an exact response to your request.

    Dan

  • If you know the names of the channel variables, you can also configure manager to send them with every channel event.

    From manager.conf:

    ;
    ; Display certain channel variables every time a channel-oriented
    ; event is emitted:
    ;
    ;channelvars = var1,var2,var3

    So if you want fu_callerid, set:

    channelvars = fu_callerid

    And, once that variable is set, you should get a NewExten event, you should see the following key/value pair:

    ChanVariable(SIP/1234-00000001): fu_callerid=foobar