Getting DialStatus from the custom context

Hi, here is the context I’m using

[from-cont15]
exten => _+X.,1,Set(CALLERID(all)=+91XXXXXXXX15)
same => n,NoOp(IFI_UUID: ${IFI_UUID})
same => n,NoOp(EXTEN: ${EXTEN})
same => n,NoOp(UNIQUEID: ${UNIQUEID})
same => n,NoOp(CHANNEL: ${CHANNEL})
same => n,NoOp(IFI_AGENT: ${IFI_AGENT})
same => n,Set(CDR(userfield)=${IFI_AGENT})
same => n,Set(SPYGROUP=${IFI_AGENT})
same => n,AGI(update_session.py, ${IFI_UUID}, ${EXTEN}, ${UNIQUEID}, ${CHANNEL})
same => n,Goto(from-internal,${EXTEN},1)

How, I want to send the DIALSTATUS to update_session.py with either UNIQUEID or other custom variable. Actually, I need to update the call info like answer, hangup info through update_session.py.

Can you please guide me to achieve that.

Thanks in advance.

Can you be more specific? You seem to know how to do it with the AGI.

As you can see, I’m sending some data to update_session.py, I also need to pass the Hangup, Failed or Answer to the same script. Actually the script sends data to another server different data regarding the calls. I need to immediately when the call is answered or failed or hanged up.

I think for this I would go AMI (preference only). Review this:

https://wiki.asterisk.org/wiki/display/AST/AMI+v2+Specification

I was trying that also. However, using the script bellow, I just got hangup event, nothing else.

const AmiClient = require('asterisk-ami-client');
let client = new AmiClient({
    reconnect: true,
    keepAlive: true,
    emitEventsByTypes: true,
    emitResponsesById: true
});

client.connect('admin', 'Secret', { host: 'localhost', port: 5038 })
    .then(amiConnection => {
        client
            .on('Dial', event => console.log(event))
            .on('Hangup', event => console.log(event))
            .on('Busy', event => console.log(event))
            .on('Answer', event => console.log(event))
            .on('Hold', event => console.log(event))
            .on('Bridge', event => console.log(event))
            .on('internalError', error => console.log(error));
    })
    .catch(error => console.log(error));

At a high-level, this looks okay to me (maybe, when/where you are activating), but you might find better expertise in the Asterisk forum as this is moving away from FreePBX.

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