Sending a local chat through fs_cli chat api

I am trying to send a simple sms chat through fs_cli using the chat api. This chat is intended to stay local within the same domain from one registered extension to another registered extension. I intend to be delivering a message on the phone. The end result really is desiring a dialplan which will be executed if, for example, ext 101 calls 102, then extension 103 will receive a message “101 is busy calling 102” as a simple example. Determining how to do this from fs_cli is my natural progression on trying to understand and use the most simple (hopefully) of methods.

If I use the messaging/chat functionality on a phone (yealink or gs wave softphone for example) or from the phone’s embedded web server, the chats are sent and received successfully. However, if I try to send via fs_cli’s chat API it does not work.

  1. enter fs command line
fs_cli
  1. view the chat api method
show api chat

This displays:

name,description,syntax,ikey
chat,chat,<proto>|<from>|<to>|<message>|[<content-type>],mod_dptools
  1. send a chat
chat global|4015@customer1.domain.tld|4015@customer1.domain.tld|hello, did this message send and receive?

This results in the error: Error! Message Not Sent

If I use “sip”, “internal”, or similar as the field then I receive the error message that the ‘customer1.domain.tld’ is an invalid profile.

2023-01-03 19:23:28.726341 [ERR] sofia_presence.c:200 Chat proto [global]
from [4015@customer1.domain.tld]
to [4015@customer1.domain.tld]
hello, did this message send and receive?
Invalid Profile customer1.domain.tld

customer1.domain.tld is substituted herein for a valid domain.

If I send an sms message through gs wave softphone and watch sngrep the message is sent and received. Here is the sngrep raw data

2023/01/03 20:14:07.653170 <my_ip_address>:28607 -> <server_ip_address>:5070
MESSAGE sip:4015@customer1.domain.tld SIP/2.0
Via: SIP/2.0/UDP <my_ip_address>:28607;branch=z9hG4bK1052834227;rport
From: <sip:101@customer1.domain.tld>;tag=1222145213
To: <sip:4015@customer1.domain.tld>
Call-ID: 801578727-28607-17@<server_ip_address>
CSeq: 160 MESSAGE
Contact: <sip:101@<my_ip_address>:28607>
Max-Forwards: 70
User-Agent: Grandstream Wave 1.0.3.34
Supported: replaces, path, timer, eventlist
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Type: text/plain; charset=UTF-8
Content-Length:    37

this message was sent through gs wave softphone
2023/01/03 20:14:07.675282 <server_ip_address>:5070 -> <my_ip_address>:28607
SIP/2.0 202 Accepted
Via: SIP/2.0/UDP <my_ip_address>:28607;branch=z9hG4bK1052834227;rport=28607
From: <sip:101@customer1.domain.tld>;tag=1222145213
To: <sip:4015@customer1.domain.tld>;tag=7p3grZSU7Fa6m
Call-ID: 801578727-28607-17@<server_ip_address>
CSeq: 160 MESSAGE
Contact: <sip:<server_ip_address>:5070>
User-Agent: FreeSWITCH
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Content-Length: 0

From here I have been able to run the show chat fs_cli command and result in:

type,name,ikey
chat,GLOBAL_SMS,mod_sms
chat,api,mod_dptools
chat,conf,mod_conference
chat,event,mod_dptools
chat,sip,mod_sofia

If I change my chat .... command to chat api|...... or chat event|..... from the show chat results above, then I receive a Sent message but I do not receive the message on the softphone application. GLOBAL_SMS, conf, sip do not work.

Many thanks in advance for input!

Hello @notthedroids,
The command syntax is chat <proto>|<from>|<to>|<message>|[<content-type>]

To verify the format in the ‘from’ and ‘to’ users, you can take a look at the User param in sofia status profile <profile_name> reg. Copy and paste those values in their entirety.

Example:
chat sip|1001@172.17.0.2|1002@172.17.0.2|THIS IS A MESSAGE

MESSAGE sip:1002@172.17.0.1:55296;transport=TCP;rinstance=354eb6094c357c10 SIP/2.0
Via: SIP/2.0/TCP 24.239.215.106:3000;branch=z9hG4bKX4Hj4vvD0cH2B
Max-Forwards: 70
From: “1001” sip:1001@172.17.0.2;tag=DmX26Qv5Qr4BF
To: “” sip:1002@172.17.0.1:55296;transport=TCP;rinstance=354eb6094c357c10
Call-ID: 03dd3173-180f-427a-9a25-340aa84eaace
CSeq: 61879225 MESSAGE
User-Agent: FreeSWITCH
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Content-Type: text/html
Content-Length: 17
X-FS-Sending-Message: cb4d88e6-fb64-4ef2-be65-622a68924ccc

THIS IS A MESSAGE

Hi @ShaneHarrell-SW ,

Thanks for the reply. I have been trying to send the chats just as you have show with chat sip|1001@172.17.0.2|1002@172.17.0.2|THIS IS A MESSAGE This fails when using sip. It says the message is sent if I use event or api instead of sip. But the message is not ever received. I see you are using the IP address where I am using the subdomain.domain.tld. I have also tried using the IP address as you have and still the error remains.

Per your “Copy and paste those values in their entirety.” from the sofia status profile <profile_name> reg command’s output, I am assuming you mean “copy the User key’s value”. Is this what you meant? There are these 13 keys/fields. (values redacted)

Call-ID:
User:
Contact:
Agent:
Status:
Ping-Status:
Ping-Time:
Host:
IP:
Port:
Auth-User:
Auth-Realm:
MWI-Account:

Modules mod_dptools and mod_sms are both enabled and running.

Any other thoughts on why the messages are not being received and how to fix?

Thank you!

@notthedroids Correct. Copy/Paste the value of the User field. That is how sofia will know where to send the MESSAGE packet.

Thanks for the confirmation, @ShaneHarrell-SW. Unfortunately my messages are not being received. I do not yet know how and why it is failing. I have tried it on 3 different servers to see if it was an issue with the original server and the issue persists on all of them. If you have additional ideas to help overcome this challenge I would appreciate it.

Thanks!