Receive SMS Messages with Nexmo

This flow lets you receive SMS messages programatically. In other words, text your Node-RED flow!

Prerequisites

Before getting started, you’ll need a few things:

  • A Nexmo account — create one for free if you haven't already
  • Optional: ngrok or similar tunnelling services - skip this if you’re running Node-RED on a public webserver instead of your local machine.

For this tutorial, you'll also need a Nexmo number—and you can purchase one under Numbers > Buy numbers.

There's a tutorial that explains this flow more in depth, check it out for more details.

[{"id":"835d23cf.67263","type":"tab","label":"Receive SMS Messages with Nexmo","disabled":false,"info":""},{"id":"35cd1184.030ede","type":"http in","z":"835d23cf.67263","name":"","url":"/inbound-sms","method":"get","upload":false,"swaggerDoc":"","x":250,"y":280,"wires":[["13ace54b.656b9b","f96525be.101f58"]]},{"id":"13ace54b.656b9b","type":"http response","z":"835d23cf.67263","name":"","statusCode":"","headers":{},"x":510,"y":280,"wires":[]},{"id":"f96525be.101f58","type":"debug","z":"835d23cf.67263","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":530,"y":180,"wires":[]},{"id":"b8eef4a4.959318","type":"comment","z":"835d23cf.67263","name":"❓About this flow","info":"In order to receive SMS messages with Nexmo, you need to associate a webhook endpoint with a virtual number that you have rented from Nexmo. Inbound Messages to that number will then be sent to your webhook endpoint.\n\n## Defining a Webhook Endpoint\n\nFirst, set up this webhook endpoint in your Node-RED editor. Connect a `http` input node to a `http response` node, as well as to a `debug` node, so that you can view your inbound messages in the debug area. \nIn the `http` input node, select `GET` as a `Method` and fill in the `URL` field with something like `/inbound-sms`.\nThe `http response` node should have `200` set as `Status code`, but don't worry about it, this is the default value.\n\n## Exposing Your Local Server to the Internet\n\nNext you'll have to expose your local server to the internet, so that Nexmo can access it. If you’re running Node-RED on a public webserver instead of your local machine, you can skip this stage. \nOtherwise, a convenient way to do this is by using a tunneling service like [ngrok](https://ngrok.com).\n\n[Download](https://ngrok.com/download) and install **ngrok**, then run it in the terminal to start a tunnel on port `1880`.\n```bash\n$ ./ngrok http 1880\n```\n\n## Setting Up the Endpoint with Nexmo\n\nThe last step is letting the Nexmo SMS API know where it should forward the inbound messages.\n\nAssociate a webhook endpoint with one of your virtual numbers by going to [Your numbers](https://dashboard.nexmo.com/your-numbers), then clicking the settings icon next to the number you'd like to configure. \nNext, fill in the _Inbound Webhook URL_ field with `YOUR_NGROK_URL/inbound-sms` and `Save changes`.\n\nNow, if you send a text message to your Nexmo number, you should see the message object appear in the debug sidebar.\nThe message payload will contain a couple of key values that should be noted:\n\n| KEY           | DESCRIPTION |\n| --------------- | --- |\n| **`msisdn`**   | The sender's number in E.164 format. For example 447401234567. |\n| **`to`**  | Your Nexmo number that the SMS was sent to, in E.164 format.    |\n| **`text`**     | The content of the received SMS message.|\n| **`type`**     | The type of the message body received (**`text`** key). Possible values are `text`, `unicode` and `binary`.| \n| **`keyword`**     | The first word in the message body. This is typically used with short codes.| \n| **`message-timestamp`**     | The time when Nexmo started to push this Delivery Receipt to your webhook endpoint.\n\nFind out more about these parameters in the [Nexmo API Reference for Inbound SMS](https://developer.nexmo.com/api/sms#inbound-sms).","x":140,"y":180,"wires":[]},{"id":"6773d04e.88cfa","type":"comment","z":"835d23cf.67263","name":"📖 Check out the tutorial","info":"🔗Go to the step-by-step [tutorial](https://www.nexmo.com/blog/2019/04/24/receive-sms-messages-node-red-dr/)","x":160,"y":60,"wires":[]}]

Flow Info

Created 2 years, 7 months ago
Updated 2 years, 4 months ago
Rating: not yet rated

Owner

Node Types

Core
  • comment (x2)
  • debug (x1)
  • http in (x1)
  • http response (x1)
  • tab (x1)

Tags

  • inbound-sms
  • messaging
  • Nexmo
  • SMS
  • input
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option