Asterisk AMI – Sending MWI (Using SIPnotify)

Sending a SIP MWI (Message Waiting Indicator) using Asterisk AMI is possible, but the syntax is just really confusing (and not documented), after rummaging through the source code for a bit I worked it out.

We need to use the SIPnotify AMI Action. The tricky part is getting the syntax right:

Action: SIPnotify
ActionID: 1231541512
Channel: peername
Variable: Event=message-summary,Content-Type=application/simple-message-summary,Content=Messages-Waiting: yes,Content=Voice-Message:1/3
Notice: That that we need to set the the Variable argument “Content” in order to set the body, furthermore “Content” does not accept newlines “\n” so we have to set more than one “Content” – pretty confusing yes.

Here is a complete example of some PHP code that uses Joshua Hatfield’s very helpful flowAPI Class which makes working with the Asterisk Manager Interface very easy in PHP.

        if($unheard_messages > 0){                                                                     
         $body1="Messages-Waiting: $waiting"; 
         $body2="Voice-Message: $unheard_messages/$total_messages";
        $ami=new floAPI();                                                                           
        "Channel"=> $username,

Alternative ways of sending MWI

You could use a different SIP messaging program (besides Asterisk) to send a SIP MWI Notify.

Using SipSak

Using PHPSip

Just make sure you use the right syntax as specified here.

Note: For most Asterisk setups simply set “mailbox”in sip.conf and asterisk will send MWI behind the scene: see here. This is for those using VM outside of asterisk or have other custom needs.