The full documentation and tutorial is available on developers.telnyx.com
You will need to set up:
-
Telnyx Phone Number enabled with:
-
Ability to receive webhooks (with something like ngrok)
-
Gmail Account You will want to setup a new gmail account specifically for this demo
- This app will take all recieved SMS messages and send them to the email address you have provided in
DESTINATION_MAILBOX
using the NodeMailer Module
The following environmental variables need to be set
Variable | Description |
---|---|
USER_EMAIL |
Your Sending, SMTP User Email |
USER_PASS |
Your Sending, SMTP User Password |
DESTINATION_MAILBOX |
The DID associated with the call control connection to be used for initating calls |
APP_PORT |
Defaults to 8000 The port the app will be served |
TELNYX_PUBLIC_KEY |
Your Telnyx Public Key Found in My Account Section of Telnyx Portal |
TELNYX_API_KEY |
Your Telnyx API Key Found in your Telnyx Portal |
This app uses the excellent dotenv package to manage environment variables.
Make a copy of .env.sample
and save as .env
and update the variables to match your creds.
DESTINATION_MAILBOX=youremail@domain.com
SMTP_USER=yoursendinguser@gmail.com
SMTP_PASS=yoursendinguserpassowrd
PORT=8081
TELNYX_PUBLIC_KEY=KEYGOESHERE
TELNYX_API_KEY=KEYGOESHERE
Callback Type | URL |
---|---|
Inbound SMS Callback | {ngrok-url}/sms/telnyx-webhook |
Run the following commands to get started
$ git clone https://github.com/team-telnyx/demo-sms2Email-node.git
$ npm install
This application is served on the port defined in the runtime environment (or in the .env
file). Be sure to launch ngrok for that port
./ngrok http 8000
Terminal should look something like
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Account Little Bobby Tables (Plan: Free)
Version 2.3.35
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://your-url.ngrok.io -> http://localhost:8000
Forwarding https://your-url.ngrok.io -> http://localhost:8000
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
At this point you will need to login to your Mission Control Account and Update your Message Profile Inbound Webhook URL to the generated ngrok URL + path (Example: http://ngrok.io/telnyx-webhook
).
Run the app with the express servering on port 8000
node server.js
You should setup a new gmail account for the specific purpose of using this Application. Be sure to use a very complex password of 20+ charaters with upper, lower, number, and special characters. After you have setup this new gmail account, you will need to enable LESS SECURE ACCESS
. Go to https://myaccount.google.com/lesssecureapps, and set to Yes.
You can Deploy this App directly to heroku if you do not have the capacity to host it yourself.
- Click the Deploy to Heroku Button Above
- Add in your appropriate config variables as outlined above in the Usage Section and Click Deploy App
- Click the Open App Button to view your server's address, copy it.
- Update Your Messaging Profile Inbound Webhook url to
https://your-apps-url.herokuapp.com/sms/telnyx-webhook
- Click Save, Send yourself a test message