How to send differentiated MWI notifications to ISDN gateway?

Dear Asterisk community,

I currently try to replace legacy Asterisk boxes running with old PCI ISDN cards by virtualized machines with ISDN gateways to connect existing ISDN PBXes to SIP and provide services like voicemail.

What I am struggling at the moment is getting MWI notification from Asterisk voicemail (chan_sip) to ISDN via the gateway working. The gateway (Audiocodes Mediant 800B) is able to directly translate SIP NOTIFY messages into ISDN MWI supplementary service messages.
The gateway can recognize the extension number of the affected mailbox either by the


part of the NOTIFY message:

At another place in the manual, it also says: “If the Message-Account parameter is missing, the gateway uses the SIP URI User Part from the To header, as the Account number.”

And that is where my problem begins. Of course, the gateway is registered at the Asterisk server as a single peer. In my tests, the Message-Account parameter is always populated like

As I understand from the documentation, it is possible to define the part before the @ with the peer’s vmexten parameter in the sip.conf and via the mailboxes= parameter, it is possible to “subscribe” a peer to multiple mailboxes.
But vmexten is a static parameter that can only be set once per peer. This does not help me because then every NOTIFY would have the same extension in its Message-Account parameter, regardless of which mailbox status has changed.

So my question is: how can I achieve that NOTIFY messages from Asterisk provide information to differentiate between the different mailboxes?
Maybe it would work to set up one “dummy peer” in sip.conf for each voicemail-enabled extension of the PBX which would introduce additional overhead and having each voicemail-enabled extension to be adminstered at three places then (in the PBX itself, in voicemail.conf and in sip.conf)

You might have to us an external notification script to do what you want.

You could write a script that uses something like ‘sipp’ to send a notify packet that you craft to your gateway.