Asterisk and IM, is not possible to use names with letters?

On extensions.conf I have defined those lines for IM via sip.

[sms]
exten => _XXXX,1,NoOp(SMS receiving dialplan invoked)
same => n,GotoIf($["${DEVSTATE}" = "UNAVAILABLE"]?errormsg1)
same => n,GotoIf($["${DEVSTATE}" = "INVALID"]?errormsg2)
same => n,GotoIf($["${DEVSTATE}" = "UNKNOWN"]?errormsg2)
same => n,MessageSend(sip:${EXTEN},${MESSAGE(from)})
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}))

Works perfect.
But one condition: i had to use only numeric values for sip hostnames(1001, 1009 ,3033 whatever I want, but only numeric)
If I change with hostnames or names with letter (phone1, phone2, myphone…) the field username of sip.conf, this context stop working with error

Purely numeric hostname (1008), and not a peer--rejecting

Is not possible to create an alias, or something similar to avoid this error?

You need to use general character classes in your extension pattern, not the special synonym for [0-9] that you are using.

1 Like

I have tried this line

exten => phone[12],1,NoOp(SMS receiving dialplan invoked)

phone1 and phone2 are defined in sip.conf
But don’t work

Your original dialplan used a pattern, but your current one is using a literal.

1 Like

something like this is ok?

exten => _phone[12],1,NoOp(SMS receiving dialplan invoked)

edit: tried, don’t work

Could you do a dialplan show on the context, and then on phone1@the-context.

1 Like

Some progress

exten => _XXXX,1,NoOp(blah!)
same => n,NoOp(${MESSAGE(from)})
same => n,NoOp(${MESSAGE(to)})
same => n,NoOp(${MESSAGE(body)})
same => n,NoOp(${SIPFROMUSER})
same => n,Verbose(2, The sip fromuser is SIPFROMUSER=${MESSAGE(from):5:9})
same => n,Set(SIPFROMUSER=${MESSAGE(from):5:9})
same => n,NoOp(${SIPFROMUSER})
same => n,Verbose(2, The sip to is SIPFROMUSER2=${MESSAGE(to):4:-20})
same => n,Verbose(2, The sip MESSAGE is ${MESSAGE(to)})
same => n,Set(ACTUALTO=${MESSAGE(to):4:-20)})
same => n,Verbose(2, The sip MESSAGE now is ${MESSAGE(to):4:-20})
same => n,ExecIf($["${ACTUALTO}" = "1001"]?set(ACTUALTO2=phone1))
same => n,ExecIf($["${ACTUALTO}" = "1008"]?set(ACTUALTO2=phone2))
same => n,MessageSend(sip:${ACTUALTO2},${SIPFROMUSER})

This work but only from linphone → hardphone
If I try the opposite the message arrive from “:phone”(sic!)

the real solution is how to found the two correct string(phone1, phone2) without using the substrings

With this configuration

[sms]
exten => _XXXX,1,NoOp(SMS receiving dialplan invoked)
same => n,NoOp(To ${MESSAGE(to)})
same => n,NoOp(From ${MESSAGE(from)})
same => n,NoOp(Body ${MESSAGE(body)})
same => n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
same => n,ExecIf($["${ACTUALTO}" = "sip:1001"]?set(ACTUALTO2=phone1))
same => n,ExecIf($["${ACTUALTO}" = "sip:1008"]?set(ACTUALTO2=phone2))
same => n,MessageSend(sip:${ACTUALTO2},"${CALLERID(name)}"${MESSAGE(from)})
same => n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
same => n,GotoIf($["${MESSAGE_SEND_STATUS}" != "SUCCESS"]?sendfailedmsg)
same => n,Hangup()
same => n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
same => n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
same => n,MessageSend(${ACTUALFROM},ServiceCenter)
same => n,Hangup()

The phone1 is a Grandstream Hardphone
The phone2 is a Linphone softphone

I can send message to 1001(Grandstream) from 1008(Linphone)
but
when 1001(Grandstream) send message to 1008(Linphone) I can receive, but not “chat” with 1001 :expressionless:
Using numbers instead names works as I said in first post

For what it’s worth, there were some problems around linphone messaging interoperability with Asterisk (or linphone and any B2BUA, really) a little while back that were very well documented by @brian_j_murrell here:
https://issues.asterisk.org/jira/browse/ASTERISK-28513

It looks like there has been progress since I last checked on the issue. Maybe your problem is not the same, but it sounds very similar.

Have you tried with a different free client, like Zoiper?

1 Like

No, is not a bug of linphone, I have tried another client(microsip: nice, light, works immediatly, no shareware and works with Linux using wine). Same problem, the message from hardphone(phone1), arrive to 1008 as phone1, so when I try to answer to phone1 simply return “not exist”.

My apologies; I understand the problem better now. Can you share the details that david551 requested, as well as a sample sip.conf entry for one of your peers?

1 Like

Sure

This is sip.conf

[phone1]
context=local
type=peer
defaultuser=phone1
secret=abcdefg
qualify=200
host=dynamic
directmedia=yes
description=phone Hard
transport=tls
encryption=yes
cc_agent_policy=generic
cc_monitor_policy=generic
textsupport=yes

[phone2]
context=local
type=peer
defaultuser=phone2
secret=abcdefg...
qualify=200
host=dynamic
deny=0.0.0.0/0
permit=192.168.0.0/24
description=phone Soft
directmedia=no
transport=tls
encryption=yes
textsupport=yes

this is extensions.conf

[globals]
PHONESIP1=SIP/phone1
PHONESIP2=SIP/phone2

[sms]
exten => _XXXX,1,NoOp(SMS receiving dialplan invoked)
same => n,NoOp(To ${MESSAGE(to)})
same => n,NoOp(From ${MESSAGE(from)})
same => n,NoOp(Body ${MESSAGE(body)})
same => n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
same => n,ExecIf($["${ACTUALTO}" = "sip:1001"]?set(ACTUALTO2=phone1))
same => n,ExecIf($["${ACTUALTO}" = "sip:1008"]?set(ACTUALTO2=phone2))
same => n,MessageSend(sip:${ACTUALTO2},"${CALLERID(name)}"${MESSAGE(from)})
same => n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
same => n,GotoIf($["${MESSAGE_SEND_STATUS}" != "SUCCESS"]?sendfailedmsg)
same => n,Hangup()
same => n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
same => n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
same => n,MessageSend(${ACTUALFROM},ServiceCenter)
same => n,Hangup()

[local]
exten => 1001,1,Dial(SIP/phone1,10,tTkK)
exten => 1001,2,Hangup

exten => 1008,1,Dial(SIP/phone2,10,tTkK)
exten => 1008,2,Hangup

OK, first it appears that you are missing the outofcall_message_context= parameter in your peers (unless this is set elsewhere?). Based on your dialplan, both peers should have: outofcall_message_context=sms

Then the sms context is set to handle digits only. The below is a duplicate of your sms dialplan, but setup for matching ‘phone’ and removing the ExecIf lines:

[sms]
...
exten => _phone.,1,NoOp(SMS receiving dialplan invoked)
same => n,NoOp(To ${MESSAGE(to)})
same => n,NoOp(From ${MESSAGE(from)})
same => n,NoOp(Body ${MESSAGE(body)})
same => n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
same => n,MessageSend(sip:${ACTUALTO2},"${CALLERID(name)}"${MESSAGE(from)})
same => n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
same => n,GotoIf($["${MESSAGE_SEND_STATUS}" != "SUCCESS"]?sendfailedmsg)
same => n,Hangup()
same => n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
same => n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
same => n,MessageSend(${ACTUALFROM},ServiceCenter)
same => n,Hangup()

With outofcall_message_context defined and both extensions _XXXX and _phone. present, I’d suspect this should work, although it will partly depend on how the peers are sending ${MESSAGE(from)}. This would support messaging to 1001 and phone1, for example).

You can check the dialplan for the extension as david551 was saying (dialplan show phone1@sms).

Which Asterisk version are you running? I did not know that you could get any messaging through without the outofcall_message_context parameter.

1 Like

I have set the option, sorry first I only forget to report it because it was in the [general] tab
I have tried your modified sms extension, it doesn’t work, in the console nothing happen, no error report, no message sent(i also tried to add an extension identical to 1008 but called phone2 to extensions.conf and nothing change).

Solution found with an awful(but working) workaround: instead of using patterns
I use one extension per peer
I define first the numeric pattern(grandstream http app can sen’t sms only to numeric)

exten => _XXXX,1,NoOp(SMS receiving dialplan invoked)
same => n,NoOp(To ${MESSAGE(to)})
same => n,NoOp(From ${MESSAGE(from)})
same => n,NoOp(Body ${MESSAGE(body)})
same => n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
same => n,ExecIf($["${ACTUALTO}" = “sip:1001”]?set(ACTUALTO2=phone1))
same => n,ExecIf($["${ACTUALTO}" = “sip:1008”]?set(ACTUALTO2=phone2))
same => n,MessageSend(sip:${ACTUALTO2},"${CALLERID(name)}"${MESSAGE(from)})
same => n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
same => n,GotoIf($["${MESSAGE_SEND_STATUS}" != “SUCCESS”]?sendfailedmsg)
same => n,Hangup()
same => n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
same => n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
same => n,MessageSend(${ACTUALFROM},ServiceCenter)
same => n,Hangup()

then (in the sms context) the exten phone2

exten => phone2,1,NoOp(SMS receiving dialplan invoked)
same => n,NoOp(To ${MESSAGE(to)})
same => n,NoOp(From ${MESSAGE(from)})
same => n,NoOp(Body ${MESSAGE(body)})
same => n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
same => n,ExecIf($["${ACTUALTO}" = “sip:phone1”]?set(ACTUALTO2=phone1))
same => n,ExecIf($["${ACTUALTO}" = “sip:phone2”]?set(ACTUALTO2=phone2))
same => n,MessageSend(sip:${ACTUALTO2},"${CALLERID(name)}"${MESSAGE(from)})
same => n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
same => n,GotoIf($["${MESSAGE_SEND_STATUS}" != “SUCCESS”]?sendfailedmsg)
same => n,Hangup()
same => n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
same => n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
same => n,MessageSend(${ACTUALFROM},ServiceCenter)
same => n,Hangup()

then (in the sms context) the exten phone1

exten => phone1,1,NoOp(SMS receiving dialplan invoked)
same => n,NoOp(To ${MESSAGE(to)})
same => n,NoOp(From ${MESSAGE(from)})
same => n,NoOp(Body ${MESSAGE(body)})
same => n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
same => n,ExecIf($["${ACTUALTO}" = “sip:phone1”]?set(ACTUALTO2=phone1))
same => n,ExecIf($["${ACTUALTO}" = “sip:phone2”]?set(ACTUALTO2=phone2))
same => n,MessageSend(sip:${ACTUALTO2},"${CALLERID(name)}"${MESSAGE(from)})
same => n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
same => n,GotoIf($["${MESSAGE_SEND_STATUS}" != “SUCCESS”]?sendfailedmsg)
same => n,Hangup()
same => n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
same => n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
same => n,MessageSend(${ACTUALFROM},ServiceCenter)
same => n,Hangup()

I had make some text and works fine, I can chat between linphone and hardphone.
I have tried the pattern _phone[12] and phone[12] but fail
Thanks to all for help

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.