Snippet: Text to Text Forwarding
This Snippet will show you how to forward text messages to another phone number or device... Have you ever wanted a way to allow your customers to send you a quick message or wanted to take a quick note. This text to text example will allow you to do just that.
You will need a machine with Python installed, the SignalWire SDK, a provisioned SignalWire phone number, and optionaly Docker if you decide to run it in a container.
For this demo we will be using Python, but more languages may become available.
- SignalWire SDK
- SignalWire Phone Number
- Docker (Optional)
Methods and Endpoints
Endpoint: /forward-text Methods: GET OR POST Endpoint to accept incoming text messages from SignalWire space and forward them to MailGun.
Setup Your Environment File
- Copy from example.env and fill in your values
- Save new file called .env
Your file should look something like this:
## This is the full name of your SignalWire Space. e.g.: example.signalwire.com SIGNALWIRE_SPACE= # Your Project ID - you can find it on the `API` page in your Dashboard. SIGNALWIRE_PROJECT= # Your API token - you can generate one on the `API` page in your Dashboard SIGNALWIRE_TOKEN= # The phone number you'll be using for this Snippets. Must include the `+1` , e$ SIGNALWIRE_NUMBER= # The phone number to forward messages To FORWARD_TO_NUMBER=
Build and Run on Docker
Let's get started!
- Use our pre-built image from Docker Hub:
For Python: docker pull signalwire/snippets-text-to-text:python
- Or build your own image:
docker build -t snippets-text-to-text .
- Run your image:
docker run --publish 5000:5000 --env-file .env snippets-text-to-text
- The application will run on port 5000
Build and Run Natively
1. Replace environment variables 2. From command line run, python3 app.py
You can find more documentation on LaML, Relay, and all SignalWire APIs at:
If you need assistance or support with your SignalWire services please file a support ticket from your Dashboard.