Handoff Dial Control To Dialplan After AMI Originate

Home » Asterisk Users » Handoff Dial Control To Dialplan After AMI Originate
Asterisk Users 8 Comments

Hello,

I’d like to use the AMI interface to originate a call to a context in a dialplan, and handoff the dial control to the context.

Whenever I execute the below action, the recipient does ring, but when I answer it dials the recipient again. I believe this is because once answered the system is going to execute the Context/Exten/Prio in the Originate action?

Action: Originate Channel: Local/outbound1@originateDialContext CallerID: 00311234567
Context: originateDialContext Exten: outbound1
Priority: 1
Variable: recipient=0031612345678
Timeout: 10000

[originateDialContext]
exten => outbound1,1,Wait(1)
exten => outbound1,n,Set(recipient=${recipient})
exten => outbound1,n,Dial(SIP/${recipient}@originateChannel)

Anyone have an idea how to fix this?

8 thoughts on - Handoff Dial Control To Dialplan After AMI Originate

  • SSBmaXhlZCBpdC4gVGhlIHByb2JsZW0gaXMganVzdCBhcyBJIGFzc3VtZWQ7IG9uY2UgdGhlIGNh bGwgaXMgYW5zd2VyZWQgdGhlIGRpYWxwbGFuIGdvZXMgaW50byB3aGF04oCZcyBkZWZpbmVkIGlu IENvbnRleHQvRXh0ZW4vUHJpbyBvZiB0aGUgT3JpZ2luYXRlIGFjdGlvbi4NCg0KSSBjaGFuZ2Vk IHRoZSBDb250ZXh0L0V4dGVuL1ByaW8gaW4gdGhlIGFjdGlvbiBhbmQgcG9pbnRlZCBpdCB0byBz b21ldGhpbmcgZWxzZS4gTm93IGl0IHdvcmtzLg0KDQpBY3Rpb246IE9yaWdpbmF0ZQ0KQ2hhbm5l bDogTG9jYWwvb3V0Ym91bmQxQG9yaWdpbmF0ZURpYWxDb250ZXh0DQpDYWxsZXJJRDogMDAzMTEy MzQ1NjcNCkNvbnRleHQ6IG9yaWdpbmF0ZURpYWxQcm9jZXNzb3INCkV4dGVuOiBvdXRib3VuZDEN
    ClByaW9yaXR5OiAxDQpWYXJpYWJsZTogcmVjaXBpZW50PTAwMzE2MTIzNDU2NzgNClRpbWVvdXQ6
    IDEwMDAwDQoNCltvcmlnaW5hdGVEaWF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18NCi0tIEJh bmR3aWR0aCBhbmQgQ29sb2NhdGlvbiBQcm92aWRlZCBieSBodHRwOi8vd3d3LmFwaS1kaWdpdGFs LmNvbSAtLQ0KTmV3IHRvIEFzdGVyaXNrPyBKb2luIHVzIGZvciBhIGxpdmUgaW50cm9kdWN0b3J5
    IHdlYmluYXIgZXZlcnkgVGh1cnM6DQogICAgICAgICAgICAgICBodHRwOi8vd3d3LmFzdGVyaXNr Lm9yZy9oZWxsbw0KDQphc3Rlcmlzay11c2VycyBtYWlsaW5nIGxpc3QNClRvIFVOU1VCU0NSSUJF
    IG9yIHVwZGF0ZSBvcHRpb25zIHZpc2l0Og0KICAgaHR0cDovL2xpc3RzLmRpZ2l1bS5jb20vbWFp bG1hbi9saXN0aW5mby9hc3Rlcmlzay11c2Vycw0KDQoNCg0KLS0NCkxvd2F5IC0gaG9tZSBvZiBR
    dWV1ZU1ldHJpY3MgLSBodHRwOi8vcXVldWVtZXRyaWNzLmNvbQ0KVGVzdC1kcml2ZSBXb21iYXRE
    aWFsZXIgYmV0YSBAIGh0dHA6Ly93b21iYXRkaWFsZXIuY29tDQo

  • You need a special extension ‘failed’ in a context originateDialProcessor to catch the control when call doesn’t get answered in first leg.

    [originateDialProcessor]

    exten => outbound1,1,Wait(1)

    exten => outbound1,n,NoOp(${DIALSTATUS})
    exten => outbound1,n,Hangup

    exten => failed,1,NoOp(—– CALL DIDN’T GET ANSWERED IN FIRST LEG —–)

    –Satish Barot

  • I used a combination of failed and the h extension to get the dialplan to do what I want.

    Thanks for the help guys!

    From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] Why can’t I execute any more dialplan after the Dial application? The scenario is when the Dial application dials the recipient but the recipient doesn’t answer. The AMI will never go into the originateDialProcessor because the call was never answered. So I expect the Dialplan to continue after the Dial application has reached its timeout.

    From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Grant Bagdasarian Sent: Wednesday, June 19, 2013 11:24 AM

    To: Asterisk Users Mailing List – Non-Commercial Discussion Subject: Re: [asterisk-users] Handoff dial control to dialplan after AMI Originate

    I fixed it. The problem is just as I assumed; once the call is answered the dialplan goes into what’s defined in Context/Exten/Prio of the Originate action.

    I changed the Context/Exten/Prio in the action and pointed it to something else. Now it works.

    Action: Originate Channel: Local/outbound1@originateDialContext CallerID: 00311234567
    Context: originateDialProcessor Exten: outbound1
    Priority: 1
    Variable: recipient=0031612345678
    Timeout: 10000

    [originateDialContext]
    exten => outbound1,1,Wait(1)
    exten => outbound1,n,Set(recipient=${recipient})
    exten => outbound1,n,Dial(SIP/${recipient}@originateChannel)

    [originateDialProcessor]
    exten => outbound1,1,Wait(1)
    exten => outbound1,n,NoOp(${DIALSTATUS})
    exten => outbound1,n,Hangup

    From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Lenz Emilitri Sent: Wednesday, June 19, 2013 10:10 AM
    To: Asterisk Users Mailing List – Non-Commercial Discussion Subject: Re: [asterisk-users] Handoff dial control to dialplan after AMI Originate

    Looks correct to me….

    2013/6/19 Grant Bagdasarian >
    Hello,

    I’d like to use the AMI interface to originate a call to a context in a dialplan, and handoff the dial control to the context.

    Whenever I execute the below action, the recipient does ring, but when I answer it dials the recipient again. I believe this is because once answered the system is going to execute the Context/Exten/Prio in the Originate action?

    Action: Originate Channel: Local/outbound1@originateDialContext CallerID: 00311234567
    Context: originateDialContext Exten: outbound1
    Priority: 1
    Variable: recipient=0031612345678
    Timeout: 10000

    [originateDialContext]
    exten => outbound1,1,Wait(1)
    exten => outbound1,n,Set(recipient=${recipient})
    exten => outbound1,n,Dial(SIP/${recipient}@originateChannel)

    Anyone have an idea how to fix this?

  • Your both channels legs are identical strings. It should be like this.

    Action: Originate****

    Channel: Local/outbound1@originateDialContext****

    CallerID: 00311234567****

    Context: originateDialContext2****

    Exten: outbound1****

    Priority: 1****

    Variable: recipient=0031612345678,callerid1=****00311234567

    Timeout: 10000

    ** **

    [originateDialContext]****

    exten => outbound1,1,Wait(1)****

    exten => outbound1,n,Set(recipient=${recipient})****

    exten => outbound1,n,Dial(SIP/${recipient}@originateChannel)****

    [originateDialContext2]****

    exten => outbound1,1,Wait(1)****

    exten => outbound1,n,Dial(SIP/${callerid1}@originateChannel)

  • B.H.

    You actually try to connect both 2 legs of the new call to the same extension. Channel attribute tells where you want to dial, and Context/Exten/Priority tell where to send the call once it is established.

    In your situation, you should probably specify in Context attribute the context where your SIP extension would get if he was to place a outgoing call normally (probably, the context value from your sip.conf record)