Function To Get Mailbox For A PJSIP Endpoint?

Home » Asterisk Users » Function To Get Mailbox For A PJSIP Endpoint?
Asterisk Users 5 Comments

Howdy,

I’m trying to re-write my voicemail check extension.

I formerly used the SIPPEER function to get the mailbox for a peer with
${SIPPEER(${peer},mailbox)}

Is there a way to do this with PJSIP now that I’ve converted over?

I see a function PJSIP_ENDPOINT and it has a mailboxes subset but I’m not retrieving any data from it when I query it.

5 thoughts on - Function To Get Mailbox For A PJSIP Endpoint?

  • John Kiniston wrote:

    Kia ora,

    What is your pjsip.conf like for the endpoint and AOR? (Where have you configured it). If specified on the AOR then it won’t be accessible via PJSIP_ENDPOINT and there is not, as of yet, a dialplan function for querying for AOR information.

    Cheers,

  • Here’s my config, I am configuring the mailboxes as you see below in the aor.

    It looked like that was the recommended place to configure it?

    If I configure the mailboxes in the Endpoint then the PBX will be sending unsolicited MWI vs if I configure them in the AOR then my phones subscribe for MWI Correct?

    [endpoint_nat_g722_internal](!)
    type=endpoint transport=transport-udp-nat context=internal disallow=all allow=g722
    allow=ulaw direct_media=no rtp_symmetric=yes

    [auth_userpass](!)
    type=auth auth_type=userpass

    [aor_dynamic](!)
    type=aor qualify_frequency 00 ; Interval at which to qualify an AoR (default:
    “0”)
    max_contacts=2

    [0015652090cf-1]
    type=phoneprov PROFILE=yealink FIRMWARE=T28v2.72.0.80.rom MAC15652090cf endpointq02
    LINE=1
    LABELq02

    [7102](endpoint_nat_g722_internal)
    callerid=Yealink <7102>
    authq02
    aorsq02

    [7102](auth_userpass)
    usernameq02
    password=YeahRight

    [7102](aor_dynamic)
    mailboxesq02@default

  • John Kiniston wrote:

    There’s no recommendation one way or the other really – it depends on what the devices in question are expecting.

    Correct. Since you are configuring on the AOR there is no current way to grab that information in the dialplan from the AOR.

    Cheers,

  • Actually you can use the AST_SORCERY dialplan function function to retrieve any variable from any PJSIP object. AST_SORCERY(“res_pjsip”, “aor”,
    “myaor”, “mailboxes”)

  • Thank you George, That works.

    If anyone is curious here is what I’m doing for my mail checking extension.

    exten => *98,1,NoOP()
    same => n,Answer()
    same => n,Set(ENDPOINT=${CHANNEL(endpoint)}) ; Get the peer same => n,Set(MAILBOX=${PJSIP_ENDPOINT(${ENDPOINT},mailboxes)})
    same => n,ExecIf($[${ISNULL(${MAILBOX})} 1]?Set(MAILBOX=${AST_SORCERY(res_pjsip,aor,${ENDPOINT},mailboxes)}))
    same => n,ExecIf($[${ISNULL(${MAILBOX})} 0]?VoicemailMain(${MAILBOX},s))
    same => n,ExecIf($[${ISNULL(${MAILBOXCONTEXT})} 0]?VoicemailMain(@${MAILBOXCONTEXT}))
    same => n,Playtones(congestion)
    same => n,Congestion(8)
    same => n,Hangup()