Setting un Instant Messaging in Asterisk

Hello everyone,
I am now using Asterisk 16.19.1 since a month and I am very happy to got it working.
I am looking to install instant messaging in MicroSIP.
Currently when I send a message from 1067 to 1092, the 1092’s MicroSIP is ringing as anonymous with no sound.
Here is my extension.conf :

[Aucun] ; No plan
exten => _.,1,PlayBack(/var/lib/asterisk/sounds/custom/noforfait)

[get-callerid]
exten => 800,1,set(callerid=${CALLERID(num)})
same = n,agi(googletts.agi,"Votre numéro est le "${callerid} ". Bonne journée.",fr,any,1.5)
same = n,Hangup()

[soundtest]
exten => 802,1,Answer()
same = n,agi(googletts.agi,"Test de connexion réussi. Testez votre voix en parlant maintenant.",fr,any,1.5)
same = n,echo()
same = n,Hangup()

[get-time]
exten => 801,1,set(currentTime=${STRFTIME(${EPOCH},GMT-2,%H:%M)})
same = n,agi(googletts.agi,"Il est actuellement " ${currentTime},fr,any,1.5)
same = n,Hangup()

[ippi]
exten => s,1,PlayBack(custom/welcome)
same = n,Ringing
same = n,Dial(PJSIP/1067&PJSIP/1092,60,tTm(predecrochage))
same = n,PlayBack(custom/noagent)
same = n,HangUp()

[DialEndpoints] ; Internal calls - The extension I want to install Instant Messaging
exten => _10.,1,Ringing
same = n,Dial(PJSIP/${EXTEN},30,tTm(predecrochage))
same = n,PlayBack(custom/agentunavailable)
same = n,HangUp()

[live]
exten => 805,1,ConfBridge(confLive,live,user_live)

[unallowed]
exten => _.,1,PlayBack(/var/lib/asterisk/sounds/custom/forbidden)

[freecalls]
exten => _+1800.,1,Dial(PJSIP/${EXTEN}@voipms)
exten => _+1888.,1,Dial(PJSIP/${EXTEN}@voipms)
exten => _+1877.,1,Dial(PJSIP/${EXTEN}@voipms)
exten => _+1866.,1,Dial(PJSIP/${EXTEN}@voipms)
exten => _+1855.,1,Dial(PJSIP/${EXTEN}@voipms)
exten => _+1844.,1,Dial(PJSIP/${EXTEN}@voipms)
exten => _+1833.,1,Dial(PJSIP/${EXTEN}@voipms)

[Posteaposte]
include => DialEndpoints
include => get-time
include => soundtest
include => freecalls
include => unallowed

[Tout]
include => DialEndpoints
include => live
include => get-callerid
include => get-time
include => soundtest
exten => _+.,1,Dial(PJSIP/${EXTEN}@voipms)
exten => _00.,1,Dial(PJSIP/${EXTEN}@voipms)
include => unallowed

[Francais]
include => DialEndpoints
include => get-callerid
include => get-time
include => soundtest
exten => _+33.,1,Dial(PJSIP/${EXTEN}@voipms)
include => freecalls
include => unallowed

[FixesFrancais]
include => DialEndpoints
include => get-callerid
include => get-time
include => soundtest
include => freecalls
exten => _+33[1-59].,1,Dial(PJSIP/${EXTEN}@voipms)
include => unallowed

What should I change / install in Asterisk ?
Thanks for your help!

You’ll need a message context to be set for all users or those who will have this feature enabled.

Take a look in this context sample: https://stackoverflow.com/a/23110898/879613

Thanks!
I can’t use the sample because the author didn’t show us the chatplan.php file, which is required for this dialplan.

There is is a version of the dialplan, in that thread, with the AGI call commented out.

In any case, I think the intent was to show the use of the context, not to give you a canned solution. For example, that dialplan seems to do more than is is stricly necessary. You need understand it, not just copy it.

Thanks for your answer. Got it working! Just another interrogation, is it possible to use the same endpoint number to dial / IM ?
Here is my dialplan :

[instant-message]
exten => _#1067,1,Set(DEVSTATE=${DEVICE_STATE(PJSIP/1067)})
 same => n,GotoIf($["${DEVSTATE}" = "UNAVAILABLE"]?errormsg1)
 same => n,GotoIf($["${DEVSTATE}" = "INVALID"]?errormsg2)
 same => n,GotoIf($["${DEVSTATE}" = "UNKNOWN"]?errormsg2)
 same => n,MessageSend(pjsip:1067,${MESSAGE(from)})
 same => n,System(curl --data "from=${MESSAGE(from)}" --data "to=${EXTEN}" --data-urlencode "message=${MESSAGE(body)}" 127.0.0.1/messagelog-internal.php?)
 same => n,Hangup()
 same => n(errormsg1),Log(NOTICE,Extension is ${DEVSTATE})
 same => n,Gosub(msg-error1,s,1(${MESSAGE(from)},${EXTEN},${DEVSTATE}))
 same => n(errormsg2),Log(NOTICE,Extension is ${DEVSTATE})
 same => n,Gosub(msg-error2,s,1(${MESSAGE(from)},${EXTEN},${DEVSTATE}))

But i have also :

exten => 1067,Dial(PJSIP/${EXTEN},30,tTm(predecrochage))

I want to use the IM without putting “#”. Is it possible ?
Thanks!

Extension numbers are qualified by the context, so 1067 in the instant-message context is a completely different extension from extension 1067 in the “also” context.

Also, there is no point in having _ if there are no wild cards in the pattern.

Ok so I can’t call and send messages with the same endpoint/account registered on microsip, I have to re-create endpoints, right?

I’m not aware of any such limitation. Endpoint names are unrelated to extension names.

I am really sorry but I don’t see how I should use the dialplan for this.
I have my internal dialplan for calls :

[DialEndpoints] ; Internal calls
exten => _10.,1,set(CALLERID(num)=${CHANNEL(endpoint)})
same = n,Ringing
same = n,Dial(PJSIP/${EXTEN},30,tTm(predecrochage))
same = n,PlayBack(custom/agentunavailable)
same = n,HangUp()

And my instant message dialplan :

[instant-message] ; Internal messages 
exten => _#10.,1,Set(number=${EXTEN:1})
same = n,MessageSend(pjsip:${number},${MESSAGE(from)})
same = n,Hangup()

They are both included in my final context.

If I do :

[instant-message] ; Internal messages 
exten => _10.,1,MessageSend(pjsip:${EXTEN},${MESSAGE(from)})
same = n,Hangup()

the endpoint rings and the message fails.
I would love to keep the same endpoint number to call and to send messages.
Sorry again for my basic questions but I really don’t see how I can do that.

Found the solution : I just had to set message_context = instant-message for each endpoint, thanks for the help!