On SIP REGISTER Event Trigger A AGI Script

Home » Asterisk Users » On SIP REGISTER Event Trigger A AGI Script
Asterisk Users 14 Comments

Hello All,

Is there a way I can trigger a AGI script On SIP REGISTER event.

14 thoughts on - On SIP REGISTER Event Trigger A AGI Script

  • I don’t know what your goal is.

    An AGI cannot execute without a channel and a REGISTER does not create a channel.

    Are you are asking ‘Can I execute something when Asterisk receives a REGISTER request?’

    I’m just a 1.2 Luddite, but I suspect listening to events on the manager interface (AMI) from an external daemon would be the way to go.

  • Just for clarity…

    If the OP’s script does not interact with Asterisk using the AGI protocol, it is not an ‘AGI’ and does not need any channel.

    If the OP’s ‘goal’ is something like ‘when Asterisk receives a REGISTER, I
    want to update a counter in my MySQL database’ then no channel is needed.

    Hey, OP, if we know what you are trying to accomplish, maybe we can suggest a solution rather than answering a ‘feature’ question.

  • You can also consider using a proxy server such as opensips or Kamailio. They would enable you to do much more at the signalling level and many other advantages such as better security or nat traversal.

    Regards, Ali Pey

  • Well, I have a SMS dialplan and the problem is I cannot send an offline SMS
    to SIP users. Therefore, I am trying to edit the SMS dialplan to save the failed SMS to a file and deliver them when the SIP user REGISTER.

  • I see 2 parts:

    1) When the ‘send SMS’ fails, you’re going to save the details in a
    (MySQL) database using either the dialplan database applications or an AGI. (I prefer an AGI because I think the resulting dialplan is much
    ‘cleaner’ and easier to maintain.)

    2) When your ‘AMI event monitoring daemon’ receives the REGISTER event, you look for any pending SMS for this user and re-send the SMS using AMI
    — no AGI needed.

    Sound about right?

  • Valid points, but as we get clarity on what the OP wants to accomplish, I
    think he should be looking at AMI.

  • I have a related question. I need to know if a SIP peer is registered or unregistered. I try :

    CLI
    —————————-

  • Check for Status on these commands. If it comes back “OK” the peer is registered. If not, it should return “UNKNOWN”.

    —–Original Message—