Jump to content

Debugging Telnyx SMS and MMS


Recommended Posts

I'm trying to configure SMS with Telnyx on 68.0.26.  According to the release notes, SMS and MMS work since version 64 with Telnyx.  I know I had trouble when I was testing SMS with version 66 in 2020.  Has this has all been fixed now?

Following the blog post, I've configured Telnyx API v1 messaging with a /recvsms webhook, put the Profile Secret into System > Settings > Messaging > Notifications, set the Default ANI with a +1 prefix, and in an extension, set the ANI for SMS to the same number (although the +1 prefix gets stripped in the extension).  Testing results:

Inbound SMS:  fail
Inbound MMS:  fail
Outbound SMS:  works
Outbound MMS:  fail

On inbound SMS, when I send an SMS to the Telnyx number, I see this in the Vodia system (not tenant) log:

[9] 9:24:59.136    Accept connection 9815 from 192.76.120.139ⓘ
[9] 9:24:59.136    192.76.120.139:39066: Receive Client Hello(0303B176..00000000)ⓘ
[9] 9:24:59.136    192.76.120.139:39066: Client Hello TLS version(0303)ⓘ
[7] 9:24:59.136    192.76.120.139:39066: TLS in domain phonesystem.mydomain.com ⓘ
[6] 9:24:59.136    192.76.120.139:39066: Session 38745A3A..C9638221 not foundⓘ
[9] 9:24:59.136    192.76.120.139:39066: Matched cipher suite TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256ⓘ
[7] 9:24:59.136    192.76.120.139:39066: Received client hello for domain phonesystem.mydomain.com ⓘ
[9] 9:24:59.136    192.76.120.139:39066: Send Server Hello(03036407..AEC02F00)ⓘ
[7] 9:24:59.136    192.76.120.139:39066: Sending certificate chain phonesystem.mydomain.com  R3 ISRG Root X1ⓘ
[9] 9:24:59.136    192.76.120.139:39066: Send Certificate(000FBB00..F9DDE739)ⓘ
[9] 9:24:59.234    192.76.120.139:39066: Send Server Key Exchange(03001741..91F6415B)ⓘ
[9] 9:24:59.234    192.76.120.139:39066: Send Hello Done()ⓘ
[6] 9:24:59.299    Delete HTTP connection 9815 from 192.76.120.139:39066ⓘ
[9] 9:24:59.377    Accept connection 9816 from 192.76.120.139ⓘ
[9] 9:24:59.377    192.76.120.139:59969: Receive Client Hello(03039B08..00000000)ⓘ
[9] 9:24:59.377    192.76.120.139:59969: Client Hello TLS version(0303)ⓘ
[7] 9:24:59.377    192.76.120.139:59969: TLS in domain phonesystem.mydomain.com ⓘ
[6] 9:24:59.377    192.76.120.139:59969: Session AD136E57..D43B7ACC not foundⓘ
[9] 9:24:59.377    192.76.120.139:59969: Matched cipher suite TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256ⓘ
[7] 9:24:59.377    192.76.120.139:59969: Received client hello for domain phonesystem.mydomain.com ⓘ
[9] 9:24:59.377    192.76.120.139:59969: Send Server Hello(03036407..DCC02F00)ⓘ
[7] 9:24:59.377    192.76.120.139:59969: Sending certificate chain phonesystem.mydomain.com  R3 ISRG Root X1ⓘ
[9] 9:24:59.377    192.76.120.139:59969: Send Certificate(000FBB00..F9DDE739)ⓘ
[9] 9:24:59.475    192.76.120.139:59969: Send Server Key Exchange(03001741..5136C19F)ⓘ
[9] 9:24:59.475    192.76.120.139:59969: Send Hello Done()ⓘ
[6] 9:24:59.546    Delete HTTP connection 9816 from 192.76.120.139:59969ⓘ

192.76.120.139 belongs to Telnyx. So it looks like Telnyx connects successfully to Vodia, but what happens after that?  Where's my message?

On inbound MMS, I don't see anything in the Vodia logs, although the Telnyx Record Detail show the message as received by the appropriate messaging profile

Outbound SMS is working, so I guess the Profile Secret is correct in Vodia.

Outbound MMS:  I tried sending a small PNG and a small JPG from the Windows client.  The sent image does not appear until after I reload the message thread.  The message is not delivered; it shows "failed" in the Telnyx Record Details.  Interesting that it at least got as far as Telnyx.  I don't see a failure reason.

What am I missing for getting SMS and MMS to work with Telnyx?

Thanks,

Mark

 

Link to comment
Share on other sites

We are now at 68.0.28. There was a problem that the TLS connection was disconnected because of some TLS configuration, but I think that is definitively okay in 68.0.28 now. That would explain what you cannot receive any SMS/MMS. For outbound MMS, this might also be the problem because it cannot pull the content from the PBX — because its also TLS. TLS has become pretty important!

Link to comment
Share on other sites

Okay I updated to 68.0.28. Now when I test inbound SMS, I get this (omitting most of one 5500-character line that looks like it is listing every file in the system):

[9] 18:28:41.178	Request from 192.76.120.142:49518 for /recvsmsⓘ

POST /recvsms HTTP/1.1
Host: phonesystem.mydomain.com
X-Telnyx-Signature: t=1678328920,h=LAxBs5hfsKU23MvwD7bwAlBIYNtOWBvr4fAthk2wsxQ=
Content-Type: application/json
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Python/3.7 aiohttp/3.8.1
Content-Length: 145

[7] 18:28:41.179	Provisioning without domain contextⓘ
[9] 18:28:41.179	Tried to match recvsmsⓘ

logo-320x240.jpg logo-480x272.jpg logo-800x480.jpg aastra.cfg startup.cfg 0c1105######.cfg [over 5000 characters of file names]

[8] 18:28:41.179	Receive SMSⓘ

{"sms_id": "04d30015-0e91-40af-a439-4a174c010d63", "direction": "inbound", "from": "+16191112222", "to": "+18583334444", "body": "To check logs"}

[8] 18:28:41.179	SMS not enabled by default (setting=, default=true)ⓘ
[7] 18:28:41.179	Closing connection smtp.google.com:465ⓘ

What am I missing? Why is it searching 100+ file names for the /recvsms URL? Why does is say "SMS not enabled by default"?

I can try MMS tomorrow, but maybe we can get SMS working first.

Link to comment
Share on other sites

Okay I re-updated to 68.0.28. Now:

Inbound SMS:  works
Inbound MMS:  works
Outbound SMS:  works
Outbound MMS:  fails

So we're making progress, but outbound MMS is still failing. I'm not clear on the reason, but if I had to guess, I'd say Vodia needs to tell Telnyx the full path where it can retrieve the MMS content. It's specifying a subfolder of /recvsms, but how would Telnyx know the full URL to call back to for the content? Here is the outbound log, after stripping out a bunch of TLS negotiation traffic (and by the way, why does it keep repeating "Closing connection smtp.google.com:465" when Google is not involved here at all?).

[9] 11:47:17.685	https:sms.telnyx.com:443: Send request (269 bytes)ⓘ

POST https://sms.telnyx.com/messages HTTP/1.1
Host: sms.telnyx.com
x-profile-secret: ****************
Content-Type: application/json
Content-Length: 123

{"from":"+18581112222","to":"+16193334444","body":{"subject":"","media_urls":[{"img":"/recvsms/15/vjy1l1xdfbm61234.png"}]}}

[9] 11:47:18.185	Received 1078 bytesⓘ

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 875
Date: Thu, 09 Mar 2023 19:47:18 GMT
Server: Python/3.9 aiohttp/3.8.0
Strict-Transport-Security: max-age=15552000

[7] 11:47:18.185	https://sms.telnyx.com/messages: Return code 200 (875 bytes)ⓘ

{
  "sms_id": "403186c7-e9dd-4678-be36-...",
  "gw_sms_id": "",
  "user_id": "b5140d6d-9622-4697-a0f2-...",
  "profile_id": "09a1e465-b795-415f-bbad-...",
  "status": "queued",
  "delivery_status": "",
  "msg": {
    "body": "{\"subject\": \"\", \"media_urls\": [{\"img\": \"/recvsms/15/vjy1l1xdfbm61234.png\"}]}",
    "src": "+18581112222",
    "dst": "+16193334444",
    "is_mms": true,
    "original_body": "{\"subject\": \"\", \"media_urls\": [{\"img\": \"/recvsms/15/vjy1l1xdfbm61234.png\"}]}"
  },
  "coding": 0,
  "parts": 1,
  "created": 1678391238041,
  "updated": 1678391238041,
  "delivery_status_webhook_url": "",
  "delivery_status_failover_url": "",
  "errors": [],
  "date_created": "2023-03-09T19:47:18.041000",
  "date_updated": "2023-03-09T19:47:18.041000",
  "carrier": "BANDWIDTH.COM CLEC, LLC - CA",
  "line_type": "Wireline"
}

[8] 11:47:18.185	https://sms.telnyx.com/messages: Return headersⓘ

Content-Type: application/json; charset=utf-8
Content-Length: 875
Date: Thu, 09 Mar 2023 19:47:18 GMT
Server: Python/3.9 aiohttp/3.8.0
Strict-Transport-Security: max-age=15552000

 

Link to comment
Share on other sites

I've confirmed using curl that the missing URL prefix is the issue:

This fails:

curl --request POST 'https://sms.telnyx.com/messages' \
--header 'Accept: application/json' \
--header 'x-profile-secret: abcd1234abcd' \
--header 'Content-Type: application/json' \
--data-raw '{
  "from": "+18581112222",
  "to": "+16193334444",
  "body": {"subject":"","media_urls":[{"img":"/recvsms/15/vjy1l1xdfbm61234.png"}]}
}'

This works:

curl --request POST 'https://sms.telnyx.com/messages' \
--header 'Accept: application/json' \
--header 'x-profile-secret: abcd1234abcd' \
--header 'Content-Type: application/json' \
--data-raw '{
  "from": "+18581112222",
  "to": "+16193334444",
  "body": {"subject":"","media_urls":[{"img":"https://phonesystem.mydomain.com/recvsms/15/vjy1l1xdfbm61234.png"}]}
}'

There's also a security concern:  HTTPS is not enforced on the /recvsms folder. http://phonesystem.mydomain.com/recvsms/15/vjy1l1xdfbm61234.png should either fail or redirect to HTTPS, but it just works.

Link to comment
Share on other sites

9 hours ago, Vodia PBX said:

Did you anything in "Address for pulling MMS content" (in /reg_messages.htm)? There you should put https://phonesystem.mydomain.com.

No, because according to the documentation, that "currently" only applies to Bandwidth. I assumed that meant that other providers use a different means to transmit MMS.

Address for pulling MMS content: This is the address is used to set up the provider (it is currently used only for Bandwidth; however it may be used later for other providers as well). This is the URL that will be used to set up the provider POST address for the PBX. The address should be the HTTP or HTTPS address under which the PBX can be reached from the SMS/MMS provider.

Thanks, though, outbound MMS does work after putting in the phonesystem.domain.com URL there.

This is all pretty confusing. Why is SMS/MMS, which applies to one trunk for one tenant, set up under System > Messaging > Notifications? phonesystem.domain.com is also a tenant-level setting. What if I had a multi-tenant setup with different URLs and different API keys for each tenant? Shouldn't this be set up parallel to trunk setup?

Link to comment
Share on other sites

Another question:  trying now to get this to work at the Queue level.  I have no other need for queues at the current site, but I do want multiple people to see inbound SMS until they are handled.

I set up a Queue as account 600 with two extensions in it and ANI for SMS set. The SMS message is being received, but the log says, "Agent group 600 has no managers for missed message notitfication".

When I look at the Queue, I can't find anywhere to set a "manager for missed message notification". I tried setting up a Redirection when All agents logged out, or All agents busy, using a "Night service number" of one of the extensions, but I continue to see "Agent group 600 has no managers for missed message notitfication".

How do I set up the queue for receiving SMS? Do "agents" have to log in to the queue to get this to work? How do I set up the missed message notification?

 

Link to comment
Share on other sites

On 3/10/2023 at 4:39 PM, mcbsys said:

This is all pretty confusing. Why is SMS/MMS, which applies to one trunk for one tenant, set up under System > Messaging > Notifications? phonesystem.domain.com is also a tenant-level setting. What if I had a multi-tenant setup with different URLs and different API keys for each tenant? Shouldn't this be set up parallel to trunk setup?

Agreed. SMS has grown over the years inside the PBX, some things are hard to understand today. We need to eventually restructure the SMS similar to the trunk. This might be something on the list for version 70. 

When an inbound SMS cannot be delivered to anyone, this is a little bit like a missed call. Agents need to be registered with an app to receive the message. Someone should be aware about it — in the case of a queue the manager is the one. If there is no manager, well then the only thing the PBX does it to generate a log entry about that. 

Link to comment
Share on other sites

12 hours ago, Vodia PBX said:

in the case of a queue the manager is the one.

So how do I designate an agent as the queue manager? I can't find the word "manager" in the Call Queue UI.

Today when introducing the new system to the customer, one asked, can he have his own phone number for texting in and out? Basically a user-specific DID that would also work for texting. If I set "ANI for SMS" at the extension level using a "private" ANI for this user, does it work that way? Or does it still send outbound SM/MMS using the System-level Notification setup?

Link to comment
Share on other sites

Okay, support clued me in that queue manager is a Group permission, not set in the queue itself.

I’ve spent probably two hours testing this and I cannot get it to work as @Vodia PBX described it in this post. In the end, messages just disappear if the first queue agent is not logged in with an app (queue login doesn't matter). The manager's "chat" BLF gets turned on, but the SMS is not available. It is never delivered as email to the queue manager. Let me know if you want to see my long document of how I tested.

Really in a queue situation, all agents should see the SMS message until one agent takes ownership. Or it could follow the queue behavior, if no one takes ownership after x seconds, route to the next agent. And if no one takes ownership within x seconds, send the SMS as an email to the manager. This implies that the PBX can keep track of chat ownership, not just previous communications.

Is there any documentation on setting up SMS with queues? I need to see the flowchart of “if this, then that” for all the conditions and actions. How do we get email fallback to work?

Link to comment
Share on other sites

  • 1 month later...

From testing, it seems like a message easily gets "lost", as in delivered to an unexpected agent in the queue (two agents have an outgoing message to the same number and that number responds, it goes to one of the agents' threads, but not both of them.  

As for receiving messages, I had to upgrade from 68.0.30 to 69.0.3 to get around the default check problem Richard described. 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...