Sip messages configuring

Hi guys

I now have freepbx running on our server and can make calls inbound and out. ( even video to video )I have IVR and dynamic routing doing our custom routing.

We are developing in Delphi and using ABTO’s SDK.

Incoming and outgoing calls are working ok but the messaging between apps fails. ( I have asked their technical support as well )

Some questions

  1. Is sip messaging the correct term.
  2. I have port forward 8003 ( is this correct)
  3. Is messaging ext to ext or user ?
  4. What settings are relevant to messaging in the GUI.

Any help appreciated

Cheers.

If you are referring to sending text messages using SIP, then I don’t believe FreePBX supports this out of the box - though can be configured to do so. There have been threads in the past.

This is not used as standard by SIP. It is more likely to be a provider specific address, using their proprietary protocol. Please see the current Flowroute and Twilio “SMS” threads.

From the SDK supplier we are using for mobile sip phones.

Our SDK send text messages using SIP SIMPLE protocol, to be specific using Page mode.

  • The Page Mode makes use of the SIP method MESSAGE, as defined in RFC 3428. This mode establishes no sessions.

Some servers does not support it directly or only after configuration.

> Any settings in FreePBX I need to enable ?
Not sure which actually. Also it depends on used backend and FreePBX version.
Some examples:

We are on ver 16.

I pasted into ext 204 & 205

[messages]
; Deliver to local 4-digit extension
exten => _XX!,1,Set(FROMUSER=${CUT(MESSAGE(from),<,2)})
same => n,Set(FROMUSER=${CUT(FROMUSER,@,1)})
same => n,Set(FROMUSER=${CUT(FROMUSER,:,2)})
same => n,Set(DIALSTRING=${DB(DEVICE/${EXTEN}/dial)})
same => n,Set(TODEVICE=${TOLOWER(${STRREPLACE(DIALSTRING,“/”,“:”)})})
same => n,MessageSend(${TODEVICE},${FROMUSER})

But the messages don’t happen.

Any ideas please

pjsip.endpoint.conf:
[204]

message_context=messages

[205]

message_context=messages

Instead of
[from-internal-custom]

message_context = messages

Extension, in the sense I believe you intended here refers to entries in pjsip.conf, but what you claim to have inserted belongs in extension.conf, and is only needed once.

You should not actually modify these files themselves, but the appropriate custom files. What amazingstories describes is the overall effect, but you actually need to use the custom file and use the "(+type=endpoint) construction in lgaetz reply in one of the quoted threads.

Basically you are doing this in pure Asterisk, but with the added constraint that you have to work within the constraints of how FreePBX manages these files. Because you are basically working directly with Asterisk, you really need to understand how Asterisk is configured to avoid the sort of confusion that is happening here.

I am getting to grips slowly with the interface etc.

The voip SDK has the following:


Method sends SIP NOTIFY request with specified body to specified
number using specified account.
Arguments:
 ‘accountId’ – account id, which account SDK has to use for this call.
app can get use ‘phone.getActiveCallId()’
 ‘body’ – text, which is required to copy as requests body.
 ‘destination’ – phone number or sip uri
When call established SDK sends notification:
OnTextMessageStatusListener::onTextMessageStatus
Example:
phone.sendTextMessage(phone.getCurrentAccountId(), “hello”,
sipNumber);

In my code I am using:

procedure TMainForm.Button3Click(Sender: TObject);
begin
      ABTOPhone.sendTextMessage(accountId, TextMessageEdit.Text, callToEdit.text);
end;
procedure TMainForm.onTextMessageReceived(&message : String; remoteContact : String; accId : String);
begin
   MessagesMemo.Lines.Insert(0, accID + ' : ' + &message + '  : ' +remoteContact);
end;

And

procedure TMainForm.onReceivedSipNotifyMsg(messageText: string);
begin
      MessagesMemo.Lines.Insert(0, 'sip message received : ' + messageText);
end;

In FreePBX I have:

extensions_custom.conf

[myMessages]
; Deliver to local 3-digit extension
exten => _X!,1,Set(FROMUSER=${CUT(MESSAGE(from),<,2)})
same => n,Set(FROMUSER=${CUT(FROMUSER,@,1)})
same => n,Set(FROMUSER=${CUT(FROMUSER,:,2)})
same => n,Set(DIALSTRING=${DB(DEVICE/${EXTEN}/dial)})
same => n,Set(TODEVICE=${TOLOWER(${STRREPLACE(DIALSTRING,"/",":")})})
same => n,MessageSend(${TODEVICE},${FROMUSER})

pjsip.endpoint_custom_post.conf
[100](+)
message_context=myMessages

When I click the button I do not get any text added to the memo button but I get a call to the extension ( But I cannot answer it )

I have nothing int GUI under Messages Context in trunk or extensions.

What am I doing wrong here please.

Please provide the full log. I’m having to make too many guesses as to what you are actually doing and the references to NOTIFY look to be irrelevant.

(It sounds as though the message context isn’t being recognized on the incoming endpoint.)

www.toolfolks.com/voip/full.txt

Can you make it so it is just a call/message in question and not 10,000 lines of everything else, including dialplan reloads, for us to look at? The debug is filled with garbage to sort through.

Looking at this one:

[2023-03-04 11:14:26] VERBOSE[2277][C-0000008f] pbx.c: Executing [202@from-internal:1] GotoIf("Message/ast_msg_queue", "0?ext-local,*202,1") in new stack

It has definitely failed to recognize the message context. Unfortunately, the endpoint from which the message arrived hasn’t been logged, so I think “pjsip set logger on” will be needed to establish that.

According to

you can’t omit the type=endpoint parameter in the template names field, even though there seem to be a lot example on the web doing exactly that.

The CLI command “pjsip show endpoint …” should show what message_context value is in use. See the IAD thread for example output.

I see the filter in the gui logs. What’s the syntax to filter on 2 types please.

Is
“pjsip set logger on” Available in the gui ?

https://wiki.freepbx.org/display/FPG/Asterisk+CLI+Module

So much to learn with so little brain…

Thanks for that. I have turned on sip logging thanks.

What is the filter I need for the info you need please.

Hi guys,

I now have this working as follows:

On each extention goto edit - Advanced - Messages Context - Add myMessages
save
apply Config

goto Admin - Config Edit
edit extensions_custom.conf

Add the following


[myMessages] ; myMessages is the name of the dialplan and can be changed to whatever you want ( also change in extensions )
exten => _.,1,NoOp(mymessage receiving dialplan invoked)
exten => _.,n,NoOp(To ${MESSAGE(to)})
exten => _.,n,NoOp(From ${MESSAGE(from)})
exten => _.,n,NoOp(Body ${MESSAGE(body)})
exten => _.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
exten => _.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})
exten => _.,n,NoOp(mymessage Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,GotoIf($["${MESSAGE_SEND_STATUS}" != "SUCCESS"]?sendfailedmsg)
exten => _.,n,Hangup()
;
; Handle failed messaging
exten => _.,n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
exten => _.,n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
exten => _.,n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
exten => _.,n,MessageSend(${ACTUALFROM},ServiceCenter) ; ServiceCenter is just a name for the sender of the message
exten => _.,n,Hangup()
exten => _.,n,Hangup() 

In my mobile app I send and device messages okay. I also noticed that a Grandstream GPX1628 we use for testing also gets messages.

I also had
;100
message_context=myMessages added in pjsip.endpoint_custom_post.conf ( not sure what this does ) I removed it and the messaging still works.

One anomaly if the extension does not have Advanced - Messages Context = myMessages when you send a message to that extension it rings. You can answer the call but nothing happens and you can end the call. ( Any ideas ?)
Hope this helps…

Any better ways to achieve this please add to post.

1 Like

I think you actually had:

 ;[100](+type=endpoint)
message_context=myMessages

Which adds a message_context parameter to the last section above this, as the ; comments out the first line. I guess it ends up with a duplicate parameter.

I think you mean when you send a message from that extension, not to it.

This could be avoided by custom dialplan, but the easiest change, which is to replace from_internal for all extensions, is probably as much work as setting up the message_context for all of them. (You would need messge_context, because you could make the custom dialplan jump to MyMessges, if invoked on the special channel Asterisk uses for messages.

To clarify.
ext 201 has message_context= ‘blank’ ( I must have saved this one )
ext 206 has message_context= myMessages in advanced

If I send a message from ext 201 to ext 206 ext 206 rings.

ext 202 has message_context= myMessages in advanced

messaging works.

PS

what does 100 syntax mean ?

Asterisk configurations are broken up into sections, whose names are given in square brackets. For chan_sip, there is one section for each FreePBX “extension”, together with one or two for each “trunk” (so called inbound and outbound ones). For typical FreePBX extensions, the name in square brackets, is the name used to register the extension, and included in the From header.

chan_pjsip uses more than one section for each “extension”, and distinguishes them by a type parameter. Typically several of them share the same name, although there is an element of degeneracy there, and there are valid cases where, in a general Asterisk configuration, more than one name could be used.

The part in parentheses allows previously defined sections to be included, by reference in the current section (giving their names, separated by commas), but can also have “!”, which means that that section is not itself used to create an extension, but can be included into another section which may create one, and + which means the contents of that section are treated as though they were immediately at the end of the a previous section with the same name. The type parameter makes this be the last section with both name and type matching.

Thus the example here, means add the following lines to the end of the type=endpoint section for extension 100.

I assume these were both supposed to be 201 or both supposed to be 202.