- Node
- Ruby
- Python
- PHP
- .NET
- Java
- Go
Overview
This guide shows how to forward incoming SMS messages from a Plivo phone number to another number using Plivo APIs and Node.js.How it works
When Plivo receives an SMS on your Plivo number, it makes an HTTP request to the “Message URL” configured in your Plivo application. Your server receives this request and must respond with an XML document that contains instructions for Plivo. In this case, the XML instructs Plivo to send a new message containing the original text to a different destination number.Prerequisites
To get started, you need a Plivo account — sign up if you don’t have one. You’ll also need a Plivo phone number that supports SMS. If you’re new to Plivo APIs, follow our instructions to set up a Node.js development environment.Create an Express server to forward messages
Create a file namedforward_sms.js
and paste this code into it. Remember to replace the <destination_number>
placeholder with the actual number you want to forward messages to, in E.164 format (e.g., +12025551234
).Create and configure a Plivo application
- Create an Application: Go to Messaging > Applications in the Plivo console and click Add New Application.
- Configure the URL: Give the application a name (e.g.,
Forward SMS
). In theMessage URL
field, enter your server URL (e.g.,https://<yourdomain>.com/forwardsms/
) and set the method toPOST
. Click Create Application. - Assign a Number: Navigate to the Numbers page and select the phone number you want to use. In the “Application Type” dropdown, select
XML Application
, and in the “Plivo Application” dropdown, select the app you just created. Click Update Number.