In Asterisk we have an API called device state. As the name implies this allows a device (such as a PJSIP endpoint) to provide notification to the system of its state. Its state may be that it is ringing, that it is on the phone, or that it is unavailable. This provides data to other aspects of the system such as app_queue (which uses it to know when it can call a queue member) or channel drivers which can turn the information into a protocol message, like a SIP NOTIFY, and send it to a phone which presents this information. Many people use this functionality every day to see if their colleagues are on the phone for example.
A module which has been present in the FreePBX distribution for quite some time has now made its way to Asterisk itself which uses this API but in a slightly different manner.
Normally when you would like to know the status of a voicemail mailbox you have to use the specific mechanisms in Asterisk, and within the VoIP protocols, to get the information. In SIP this involves either sending a SUBSCRIBE of type “application/simple-message-summary” or configuring Asterisk to send a NOTIFY unsolicited of the same type. The benefit of this is that the precise number of voicemails which are new and old can be sent to the endpoint which may display them but unfortunately many endpoints do not allow you to individually subscribe to mailboxes – so if you would like to see information about multiple mailboxes you receive a combined view instead of granular.
The res_mwi_devstate module provides functionality to help with this. It uses the device state API in Asterisk to provide a “virtual device” for each mailbox. It can be used in the form of “MWI:<mailbox>”. There is no extra configuration required. For example one would define a hint as follows:
[hints] exten => 1000,hint,MWI:1000@employees
This hint is not any different than one you would define if you would like to be able to subscribe to receive information about a device. Its information is simply fed by changes to the underlying voicemail mailbox. If the voicemail mailbox “1000@employees” has any new messages it will go to the “in use” state. If there are no new messages it will go to the “not in use” state. Using this functionality and an endpoint with multiple buttons you can then individually subscribe those buttons to different mailboxes and know if that specific mailbox has messages or not. When new voicemails are present your blinky light will go on and when there are no new ones it will cease.
While this does not provide information to the endpoint about how many new and old voicemail messages there are, it does provide a notification mechanism that was not previously available to get some per-mailbox information.
An additional fun fact! Did you know that there exists another virtual device, “confbridge:<conference bridge>”, which can be used in the same manner to know when a ConfBridge conference bridge is being used?