playSMS Forum

SMS inbound/outbound not workig with Telnyx

hello,

i have setup telnyx services but sms sending/receiving not working.

- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L3 outgoing_hook_sendsms_intercept # no SMSC found uid:1 parent_uid:0 from:+xxxxxxxxxxx to:xxxxxxxxxxx
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L2 recvsms_process # using default SMSC smsc:[telnyx]
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L2 sendsms_process # start
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L3 simplerate_hook_rate_getbyprefix # rate not found to:+xxxxxxxxxxx default_rate:0
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L3 simplerate_hook_rate_getcharges # uid:1 u:admin len:58 unicode:0 to:+xxxxxxxxxxx enable_credit_unicode:0 count:1 rate: charge:0
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L2 simplerate_hook_rate_cansend # allowed user uid:1 sms_to:+xxxxxxxxxxx adhoc_credit:0 count:1 rate: charge:0 adhoc_balance:0
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L2 sendsms # saving smslog_id:37 u:1 parent_uid:0 g:0 gw:telnyx smsc:telnyx s:+xxxxxxxxxxx d:+xxxxxxxxxxx type:text unicode:0 status:0
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L2 sendsms_process # saved smslog_id:37 id:37
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L3 sendsms # final smslog_id:37 gw:telnyx smsc:telnyx message:Hi sweetheart, good night and have a sweet dream :* 22 len:58
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L3 telnyx_hook_sendsms # enter smsc:telnyx smslog_id:37 uid:1 to:+xxxxxxxxxxx
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L2 3 # sendsms url:[https://sms.telnyx.com/messages] callback:[http://sms.example.tel/playsms/plugin/gateway/telnyx/callback.php
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L2 telnyx_hook_sendsms # failed smslog_id:37 message_id: error_code:400error_messageThe 'to' address should be a single valid number. smsc:telnyx
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L3 dlr # isdlrd:1 smslog_id:37 p_status:2 uid:1
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L3 telnyx_hook_sendsms # sendsms end
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L2 sendsms_process # fail no hook for sendsms
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L2 sendsms_process # end
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L2 sendsmsd # result queue_code:b476f77d72e1eb1a81c7a05ae7780ede to:+xxxxxxxxxxx flag:2 smslog_id:37
- - 2020-03-27 19:46:47 PID5e7e582765ef0 - L2 sendsmsd # finish processing queue_code:b476f77d72e1eb1a81c7a05ae7780ede uid:1 sender_id:+xxxxxxxxxxx queue_count:1 sms_count:1
- - 2020-03-27 19:46:48 PID5e7d02a840262 - L3 dlrd # id:37 smslog_id:37 p_status:2 uid:1

2020-03-27 19:46:47 PID5e7e582765ef0 - L2 telnyx_hook_sendsms # failed smslog_id:37 message_id: error_code:400error_messageThe ‘to’ address should be a single valid number. smsc:telnyx

now the message is changed

- - 2020-03-30 18:33:58 PID5e823b95e016c - L2 telnyx_hook_sendsms # failed smslog_id:48 message_id: error_code:400error_messageThe 'from' address should be string containing a valid phone number associated with the sending messaging profile or a valid alphanumeric sender ID smsc:telnyx
- - 2020-03-30 18:33:58 PID5e823b95e016c - L2 sendsmsd # result queue_code:e5dd898c2ccf4070a69b24063a4c1be7 to:+17xxxxxxxxx  flag:2 smslog_id:48
- - 2020-03-30 18:33:58 PID5e823b95e016c - L2 sendsmsd # finish processing queue_code:e5dd898c2ccf4070a69b24063a4c1be7 uid:1 sender_id:+17xxxxxxxxx queue_count:1 

already applying valid phone number in +E.164 format

please help.

I think that is the same as it happens with twillio, you have to acquire a senderid from telnyx, and put it in from (senderid) field

hi Edilson_Spessoto

thanks for your quick response i asked telnyx for providing sender id , the replied

" Sorry we are not familiar with Play SMS, you would need to contact their support to get help with setting up the client. You should just be able to supply the number you are sending from "

:frowning:

have you acquired sender ID from Telnyx ? do you have your own +17xx… in your Telnyx account ?
hav you also tried to remove the plus sign (I know they said +E164)

anton

yes , i have acquired +17xxxxxxx number in telnyx account and i am using it as sender id and the format is +E164.
yes i have tried to remove the + sign, add 00 and without 0.

ok can you edit plugin/gateway/telnyx/fn.php line 96, this line:

_log("sendsms url:[" . $url . "] callback:[" . $data['delivery_status_webhook_url'], "] smsc:[" . $smsc . "]", 3, "telnyx_hook_sendsms");

and change it to:

_log("sendsms url:[" . $url . "] data:[" . $data_string . "] callback:[" . $data['delivery_status_webhook_url'], "] smsc:[" . $smsc . "]", 3, "telnyx_hook_sendsms");

send test message, see the log and paste here
need to see whats the data json looks like

anton

hi,

after changes in fn.php
below was the log.

- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L2 sendsmsd # start processing queue_code:4c36aa2157257965b0c64eeb2b2be364 chunk:0 queue_count:1 sms_count:1 scheduled:2020-04-03 07:30:07 uid:1 gpid:0 sender_id:+17xxxxxxxxx
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L2 sendsmsd # sending queue_code:4c36aa2157257965b0c64eeb2b2be364 smslog_id:58 to:+17xxxxxxxxx sms_count:1 counter:1
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L3 sendsms_intercept # msgtemplate modified sms_sender:[+17xxxxxxxxx] sms_footer:[compy] sms_to:[+17xxxxxxxxx] sms_msg:[Hi u there, good morning!!] uid:[1] gpid:[0] sms_type:[text] unicode:[0] queue_code:[4c36aa2157257965b0c64eeb2b2be364] smsc:[]
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L3 outgoing_hook_sendsms_intercept # no SMSC found uid:1 parent_uid:0 from:+17xxxxxxxxx to:+17xxxxxxxxx
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L2 recvsms_process # using default SMSC smsc:[telnyx]
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L2 sendsms_process # start
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L3 simplerate_hook_rate_getbyprefix # rate not found to:+17xxxxxxxxx default_rate:0
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L3 simplerate_hook_rate_getcharges # uid:1 u:admin len:33 unicode:0 to:+17xxxxxxxxx enable_credit_unicode:0 count:1 rate: charge:0
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L2 simplerate_hook_rate_cansend # allowed user uid:1 sms_to:+17xxxxxxxxx adhoc_credit:0 count:1 rate: charge:0 adhoc_balance:0
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L2 sendsms # saving smslog_id:58 u:1 parent_uid:0 g:0 gw:telnyx smsc:telnyx s:+17xxxxxxxxx d:+17xxxxxxxxx type:text unicode:0 status:0
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L2 sendsms_process # saved smslog_id:58 id:58
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L3 sendsms # final smslog_id:58 gw:telnyx smsc:telnyx message:Hi u there, good morning!! compy len:33
- - 2020-04-03 07:30:08 PID5e86e6008ae0b - L3 telnyx_hook_sendsms # enter smsc: telnyx smslog_id:58 uid:1 to:++17xxxxxxxxx
- - 2020-04-03 07:30:09 PID5e86e6008ae0b - L2 3 # sendsms url:[https :// sms.telnyx.com/messages] data:[{"to":"+17xxxxxxxxx","from":"400xxxx17-7f46-xxxx-bc87-54ab60fxxxx4","body":"Hi u there, good morning!! compy","delivery_status_webhook_url":"http :/sms.compy. tel/playsms/plugin/gateway/telnyx/callback.php"}] callback:[http ://sms. compy.tel/playsms/plugin/gateway/telnyx/callback.php
- - 2020-04-03 07:30:09 PID5e86e6008ae0b - L2 telnyx_hook_sendsms # failed smslog_id:58 message_id: error_code:400error_messageThe 'from' address should be string containing a valid phone number associated with the sending messaging profile or a valid alphanumeric sender ID smsc:telnyx
- - 2020-04-03 07:30:09 PID5e86e6008ae0b - L3 dlr # isdlrd:1 smslog_id:58 p_status:2 uid:1
- - 2020-04-03 07:30:09 PID5e86e6008ae0b - L3 telnyx_hook_sendsms # sendsms end
- - 2020-04-03 07:30:09 PID5e86e6008ae0b - L2 sendsms_process # fail no hook for sendsms
- - 2020-04-03 07:30:09 PID5e86e6008ae0b - L2 sendsms_process # end
- - 2020-04-03 07:30:09 PID5e86e6008ae0b - L2 sendsmsd # result queue_code:4c36aa2157257965b0cxxxxb2b2be364 to:+17xxxxxxxxx flag:2 smslog_id:58
- - 2020-04-03 07:30:09 PID5e86e6008ae0b - L2 sendsmsd # finish processing queue_code:4c36aa21572579xxxxc64eeb2b2be364 uid:1 sender_id:+17xxxxxxxxx queue_count:1 sms_count:1
- - 2020-04-03 07:30:09 PID5e8334420b4bb - L3 dlrd # id:64 smslog_id:58 p_status:2 uid:1

======================
and this is after i have some changes made, have deleted the telnyx gateway and insert information again

- - 2020-04-03 07:36:25 PID5e86e7794deed - L2 sendsmsd # start processing queue_code:dc992b802d25a456edafcf52fd61a495 chunk:0 queue_count:1 sms_count:1 scheduled:2020-04-03 07:36:25 uid:1 gpid:0 sender_id:+17xxxxxxxxx
- - 2020-04-03 07:36:25 PID5e86e7794deed - L2 sendsmsd # sending queue_code:dc992b802d25a456edafcf52fd61a495 smslog_id:59 to:+17xxxxxxxxx sms_count:1 counter:1
- - 2020-04-03 07:36:25 PID5e86e7794deed - L3 sendsms_intercept # msgtemplate modified sms_sender:[+17xxxxxxxxx] sms_footer:[compy] sms_to:[+17xxxxxxxxx] sms_msg:[Hi u there, good morning!!] uid:[1] gpid:[0] sms_type:[text] unicode:[0] queue_code:[dc992b802d25a456edafcf52fd61a495] smsc:[]
- - 2020-04-03 07:36:25 PID5e86e7794deed - L3 outgoing_hook_sendsms_intercept # no SMSC found uid:1 parent_uid:0 from:+17xxxxxxxxx to:+17xxxxxxxxx
- - 2020-04-03 07:36:25 PID5e86e7794deed - L2 recvsms_process # using default SMSC smsc:[telnyx]
- - 2020-04-03 07:36:25 PID5e86e7794deed - L2 sendsms_process # start
- - 2020-04-03 07:36:25 PID5e86e7794deed - L3 simplerate_hook_rate_getbyprefix # rate not found to:+17xxxxxxxxx default_rate:0
- - 2020-04-03 07:36:25 PID5e86e7794deed - L3 simplerate_hook_rate_getcharges # uid:1 u:admin len:33 unicode:0 to:+17xxxxxxxxx enable_credit_unicode:0 count:1 rate: charge:0
- - 2020-04-03 07:36:25 PID5e86e7794deed - L2 simplerate_hook_rate_cansend # allowed user uid:1 sms_to:+17xxxxxxxxx adhoc_credit:0 count:1 rate: charge:0 adhoc_balance:0
- - 2020-04-03 07:36:25 PID5e86e7794deed - L2 sendsms # saving smslog_id:59 u:1 parent_uid:0 g:0 gw:telnyx smsc:telnyx s:+17xxxxxxxxx d:+17xxxxxxxxx type:text unicode:0 status:0
- - 2020-04-03 07:36:25 PID5e86e7794deed - L2 sendsms_process # saved smslog_id:59 id:59
- - 2020-04-03 07:36:25 PID5e86e7794deed - L3 sendsms # final smslog_id:59 gw:telnyx smsc:telnyx message:Hi u there, good morning!! compy len:33
- - 2020-04-03 07:36:25 PID5e86e7794deed - L3 telnyx_hook_sendsms # enter smsc:telnyx smslog_id:59 uid:1 to:+17xxxxxxxxx
- - 2020-04-03 07:36:26 PID5e86e7794deed - L2 3 # sendsms url:[https://sms.telnyx.com/messages] data:[{"to":"+17xxxxxxxxx","from":"+17xxxxxxxxx","body":"Hi u there, good morning!! compy","delivery_status_webhook_url":"http ://sms. compy.tel/playsms/plugin/gateway/telnyx/callback.php"}] callback:[http :// sms.compy. tel/playsms/plugin/gateway/telnyx/callback.php
- - 2020-04-03 07:36:26 PID5e86e7794deed - L2 telnyx_hook_sendsms # sent smslog_id:59 message_id:403xxxxe-f83f-4b27-xxxx-854710c2091e smsc:telnyx
- - 2020-04-03 07:36:26 PID5e86e7794deed - L3 dlr # isdlrd:1 smslog_id:59 p_status:2 uid:1
- - 2020-04-03 07:36:26 PID5e86e7794deed - L3 dlr # isdlrd:1 smslog_id:59 p_status:2 uid:1
- - 2020-04-03 07:36:26 PID5e86e7794deed - L3 telnyx_hook_sendsms # sendsms end
- - 2020-04-03 07:36:26 PID5e86e7794deed - L2 sendsms_process # fail no hook for sendsms
- - 2020-04-03 07:36:26 PID5e86e7794deed - L2 sendsms_process # end
- - 2020-04-03 07:36:26 PID5e86e7794deed - L2 sendsmsd # result queue_code:dc992b802d25a456edafcf52fd61a495 to:+17xxxxxxxxx flag:2 smslog_id:59
- - 2020-04-03 07:36:26 PID5e86e7794deed - L2 sendsmsd # finish processing queue_code:dc992b802d25a456edafcf52fd61a495 uid:1 sender_id:+17xxxxxxxxx queue_count:1 sms_count:1
- - 2020-04-03 07:36:27 PID5e8334420b4bb - L3 dlrd # id:65 smslog_id:59 p_status:2 uid:1
- - 2020-04-03 07:36:27 PID5e8334420b4bb - L3 dlrd # id:66 smslog_id:59 p_status:2 uid:1
- - 2020-04-03 07:36:27 PID5e8334420b4bb - L3 dlrd # id:67 smslog_id:59 p_status:3 uid:1

========================

i have found this message has been changed.

- - 2020-04-03 07:36:26 PID5e86e7794deed - L2 3 # sendsms url:[https :/ sms.telnyx com/messages] data:[{"to":"+17xxxxxxxxx","from":"+17xxxxxxxxx","body":"Hi u there, good morning!! compy","delivery_status_webhook_url":"http :// sms.compy.tel/playsms/plugin/gateway/telnyx/callback.php"}] callback:[http :// sms.compy.tel/playsms/plugin/gateway/telnyx/callback.php

i have forwarded sms to same number from playsms , the status is blue now in sent message page. message not received.

blue status in playSMS means playSMS successfuly submitted the SMS to the gateway and the gateway have responded that the message was delivered

check on Telnyx what happen, see their log

anton

thanks Anton,

after changing the secret and sender id in telnyx gateways setting. i have checked sms was sent but actually i was trying to receive it in playsms inbox but haven’t received in inbox or sandbox.

tried to forward sms with simple text also with @user @admin etc.

in log i observed below line also

- - 2020-04-03 16:05:14 PID5e875eb98a645 - L2 sendsms_process # fail no hook for sendsms

thanks again for helping me

Ghani

so, can you send SMS now ? lets fix things one by one.

anton

yes, outbound is now working

now struggling for inbound with telnyx

when i run below script with ( ngrok service setting) its working receiving sms but not in playsms.
Code:

import os
from flask import Flask, request

app = Flask(__name__)

@app.route('/webhooks', methods=['POST'])
def webhooks():
    body = request.json

    print(body)

    return '', 200


if __name__ == "__main__":
    app.run(port=5000)

received text :-

{
  "sms_id":"834f3d53-8a3c-4aa0-a733-7f2d682a72df",
  "direction": "inbound",
  "from": "+13129450002",
  "to": "+13125550001",
  "body": "Hello!"
}

are you using your own script to receive inbound or playSMS ? if using playSMS you have to point callback URL to callback.php inside telnyx plugin, something like https://example.com/plugin/gateway/telnyx/callback.php

if your playSMS is not accessible from Internet (thus using ngrok) you have to test first that you can access callback.php, just browse callback.php with some random query string (eg: https://example.com/plugin/gateway/telnyx/callback.php?query=test) from the internet, you’ll see something indicating that callback.php is accessed in playsms log

anton

oh I just saw the v1 API in telnyx website, the current gateway is not expecting JSON body, so perhaps some customization required

anton

Used manual receiving script just for checking. yes i can use site from internet, i tested https://example.com/plugin/gateway/telnyx/callback.php?query=test in browser (blank screen) nothing happened in playsms log.

callback.php


// incoming message

$sms_datetime = core_get_datetime();
$sms_sender = $requests[‘from’];
$message = htmlspecialchars_decode(urldecode($requests[‘body’]));
$sms_receiver = $requests[‘to’];
$smsc = $requests[‘smsc’];
if ($remote_smslog_id && $message) {
_log(“incoming smsc:” . $smsc . " message_id:" . $remote_smslog_id . " from:" . $sms_sender . " to:" . $sms_receiver . " message:[" . $message . “]”, 2, “telnyx callback”);
$sms_sender = addslashes($sms_sender);
$message = addslashes($message);
recvsms($sms_datetime, $sms_sender, $message, $sms_receiver, $smsc);
ob_end_clean();
echo “ACK/Telnyx”;
exit();
}


sorry made mistake, it does accept JSON, so everything should work

just to be sure, you do change the example.com right ? with your server address, and ports if not 443, is your playSMS accessible from internet ?

anton

http://example.com/playsms/plugin/gateway/telnyx/callback.php?query=test

link checked, no response in browser blank screen also nothing in playsms log.

yes playsms site is accessible through internet via domain/public ip

No I made a mistake earlier by saying playSMS didn’t handle JSON from Telnyx, it actualy does.

Try using postman (or similar tools) to submit JSON (the received text above, the one with sms_id) to your callback.php

or, maybe a test tool in Telnyx to simulate incoming SMS, if any

anton

Hi, I am also attempting to use playSMS with Telnyx but I am not getting as far as Sher_Ghani

I have successfully sent and received with Twilio.

Telnyx terminology is: “API V1 Profile Secret” which I believe matches the expected value in Settings>Manage Gateway>Manage telnyx “Secret” field.

However, I am uncertain what value matches the “Module sender ID” field. Is it the Telnyx Profile ID or the assigned telephone number?