Closed eric-brechemier closed 2 years ago
I'm currently writing an app (fork linphone) that will receive SMS from the Twilio API and also do the features of Linphone.
@HengYeDev Thank you for letting me know. I'll be interested to test it. Which platform are you targeting?
I'm targeting android for now, may also do linux, ubuntu touch, and sailfish
@HengYeDev It seems that you are only targeting mobile phones. I might not be able to test it then.
I am still interested to hear about how it pans out.
I'm also trying to get it to forward to email and when you respond to the email you respond to the text.
Heng Ye https://yeheng.org | Twitter https://twitter.com/HengYeDev
---- On Mon, 18 Jan 2021 13:32:45 -0500 Eric Bréchemier notifications@github.com wrote ----
https://github.com/HengYeDev It seems that you are only targeting mobile phones. I might not be able to test it then.
I am still interested to hear about how it pans out.
— You are receiving this because you were mentioned. Reply to this email directly, https://github.com/eric-brechemier/how-i-replaced-skype-with-twilio/issues/7#issuecomment-762411836, or https://github.com/notifications/unsubscribe-auth/AO5TJ6IUNU7WGYLVSDZWL2LS2R5E3ANCNFSM4HODR3RQ.
Neat!
I have compared different services to help me send and receive SMS messages by email; I have identified Pipedream as a suitable solution, which supports:
[unique-id]@upload.pipedream.net
https://[unique-id].m.pipedream.net
notifications@pipedream.com
to the email used to register the pipedream accountThe icing on the cake is that Pipedream allows to build workflows step by step, showing you how the incoming data look like at each step, and letting you select values from that data in the configuration of each following step. This is the part that allows to actually build the bridge from SMS to email and back again, where other services that I studied only provide the pillars on each end.
Note: There is a limitation in email notifications sent by Pipedream at the moment: they can only be sent to the email address that you used to sign up to the service. This limitation will be lifted in an upcoming update of the platform, but at the moment, you should sign up with the email address were you want to receive your SMS messages.
@
sign, but only alphanumerical characters and dashes are allowed.
This completes your sign up and initiates the creation of your first workflow. We will start by configuring a workflow to send SMS messages by email.
But first, you can check your email and confirm your email address. You should receive an email of the form:
Thanks for signing up to Pipedream!
Please verify your email by clicking this link: https://api.pipedream.com/verify-email?token=[long-secret-token]
Strange enough, no confirmation gets displayed.
This workflow is made of two steps:
The wizard for the creation of a new workflow invites you to select the trigger:
We'll start by naming our workflow. At the top left of the window, it is currently named Untitled workflow.
The text of the SMS will simply be the text of the email. To make things simpler at a later step, I have configured my email client to send these email messages as plain text rather than in HTML format, and to avoid including any signatures or inlining the original message in a reply.
The phone number of the recipient will be provided in international format, starting with a + and the country code, omitting any part of the number, such as a 0
, that is only used when calling local numbers. You should choose a regular mobile phone number to test the reception of SMS messages.
Your test email should contain something along these lines:
steps.trigger.event.headers.from.text
steps.trigger.event.headers.to.text
steps.trigger.event.headers.subject
steps.trigger.event.body.text
That's all we need. Let's .
A second step is added, in which we will select the action to do in response to the trigger:
Click .
The connection to Twilio API requires 3 different things, which you will find or create in your Twilio account:
Sign in to Twilio and go to your console dashboard.
Scroll down the page and you will find your Account SID in the Account Info section.
Copy it and paste it to the AccountSid field of the Pipedream configuration form.
Instead of providing your master token, which is like giving the password to your whole Twilio account, we are going to create an API key with more limited privileges.
Note: If your connection to the Twilio API fails to authenticate, you may have created the API key for a different region.
That happened to me: I had mistakenly created the API key for the Ireland region instead of the US.
We will use an expression to extract the phone number of the recipient from the subject of the email. Remember that we formatted the subject with the phone number in international format at the end: New SMS to +## ###-###-#####. We identified previously that the subject is stored at the location steps.trigger.event.headers.subject
in the event generated for the incoming email by Pipedream. We are going to use a regular expression to extract the phone number, starting with the +
sign, and keeping only the digits, discarding all other symbols such as dashes added for readability.
I used RegExr to test different regular expressions. I designed the replacement in two steps to cover some edge cases. The phone number is expected to start with the last +
sign in the subject. Everything before the last +
sign will be discarded:
+
sign found closest to the end: .replace(/^.+\+/,'+')
+
sign and digits, discarding all separators and other symbols: .replace(/[^+0-9]/g,'')
Then I tested these replacements in the JavaScript console of a browser:
"New SMS to +1202-555-0488".replace(/^.+\+/,'+').replace(/[^+0-9]/g,'')
"+12025550488"
"Re[3]: 3rd SMS +1-2-3 to +1202-555-0488".replace(/^.+\+/,'+').replace(/[^+0-9]/g,'')
"+12025550488"
send_sms
configuration:{{steps.trigger.event.headers.subject.replace(/^.+\+/,'+').replace(/[^+0-9]/g,'')}}
send_sms
configuration:{{steps.trigger.event.body.text}}
The configuration of the workflow to send SMS messages by Email is now complete, and your test SMS is ready to leave.
If your test number is in a different country than your Twilio phone number or if you plan to send SMS messages internationally, you should activate the geographic permissions for each of these countries. In the Messaging section of the Twilio dashboard, open the Settings and Geo permissions subsections. Then select each country or region that you want to allow to send and receive SMS messages from.
send_sms
step now shows the successful result.
The SMS itself may take a while to arrive. In the meantime, you can check the logs on Twilio's side in the Monitor section of your dashboard, opening the Logs and Messaging subsections to see more details about the delivery of that SMS.
Once you have successfully received the SMS, you can now the Pipedream workflow to allow it to process events automatically, instead of reviewing them step by step.
Note: When sending an SMS to a phone number in a different country, your Twilio phone number may not be displayed as the sender. The recipient may see the short code of a local service instead. This should not happen when sending messages within the same country as your Twilio phone number.
We are now going to configure a second workflow to receive SMS messages as emails. Again, this workflow will have two steps:
This second workflow does not require a connection to Twilio API. It listens on an HTTP URL, which we will configure to get triggered by new SMS messages in the Twilio dashboard.
In the left sidebar of your Pipedream dashboard, click to open the list of workflows.
Click the button to create a new workflow. We have now reached the stage where we were at the beginning of the configuration of the first workflow, which was created automatically for us just after the signup.
<?xml version="1.0" encoding="UTF-8" ?>
<Response/>
and must be served with the HTTP Content-Type
header application/xml
.
Click the button to close that part of the form.
Under the Body, click the input field and copy/paste there our static TwiML response:
<?xml version="1.0" encoding="UTF-8" ?>
<Response/>
Finally, click button to save our trigger step.
Once the trigger is saved, Pipedream generates a new URL of the form https://[unique-id].m.pipedream.net for this trigger:
Click to copy this URL. We will configure it as webhook for new SMS messages in the Twilio dashboard.
Go to your Twilio dashboard. In the Develop sidebar, open the Phone Numbers section then the Manage and Active Numbers subsections.
Click the link which displays your phone number in the list displayed on the right.
In the Messaging section, select Webhook and copy the URL of your Pipedream trigger under WHEN A MESSAGE COMES IN:
Click the button to save the webhook configuration.
Send an SMS to your Twilio phone number using a regular mobile phone. This is going to feed the Pipedream webhook which will show us what kind of data to expect from Twilio.
If all goes well, the Pipedream trigger shows that a new event has arrived:
steps.trigger.event.body.From
steps.trigger.event.body.Body
Click the button to complete the configuration of the webhook trigger.
We will now add the Send Email action step, which is available in the list displayed on the right:
In the subject, we will include the phone number of the sender, using a template message of the form:
New SMS from {{steps.trigger.event.body.From}}
For the text of the email, we will simply provide the text of the SMS, using the template below:
{{steps.trigger.event.body.Body}}
Click the button to close that part of the form.
Click the button to receive your test SMS by email.
A few seconds later, Pipedream should display that the email was sent successfully:
You should now have received an email from notifications@pipedream.com
on the email address that you used to register your Pipedream account.
Once you have successfully received the email message, you can your second Pipedream workflow.
Note: If you have not validated your email address, you may not receive any email, although testing the workflow will still pretend that the email was sent successfully.
You may leave your comments below.
@eric-brechemier you have a French number which is capable of receiving SMS, right? When searched for a French number at "buy a number", there's no support for SMS in France at all. How can it be?
@ally9335 Sorry for the late answer. I do have a French phone number with SMS support.
In my experience, the availability of Twilio Phone Numbers in different countries varies over time. If I remember correctly, I had to check a couple of days in a row to find a suitable phone number in the UK. There might be a shortage of French numbers at the moment.
Checking today, there is not a single French phone number available from Twilio:
Ideally, I would like to:
Barring that, I would like to: