This code snippet uses recording status callbacks in order to send a transcription of the created recording via SMS. When a recording is created with the recording status callback pointing to this script, a SignalWire client object will be created and used to send the message to the end destination cell phone.
You can learn more about recording status callbacks, all of the possible parameters you can learn, and how to set them up in our status callback mega guide!
You can read the guide below, or use our recipe to quickly copy the code!
This script is short and simple. There is only one route in this application which we will call
We need to use
request.form.get('ParameterName') in order to gather the
RecordingUrl parameters and store them in their own variables. If you want to include more parameters either to print to console or include in the message, you can gather them using the same format here.
We then create a SignalWire client object with our project details and authentication. All that's left there is to create a message object and send all of the necessary information within the
Body with the
To number being the end destination number and the
From number being a SignalWire number.
from flask import Flask, request from signalwire.rest import Client as signalwire_client app = Flask(__name__) @app.route("/sendRecording", methods=["POST"]) def message(): # accept incoming parameters and store them. Feel free to add any extra parameters that you would like to print to # to console or add to your message. This example will show CallSID and recording URL. call_sid = request.form.get('CallSid') recording_url = request.form.get('RecordingUrl') # create a client object connected to our account & project client = signalwire_client("ProjectID", "AuthToken", signalwire_space_url = 'YOURSPACE.signalwire.com') # create a text message and send ourselves the text m = client.messages.create( body='You have received a voicemail. Listen to the recording here: "' + recording_url + '". The Call SID is ' + call_sid, from_='+1xxxxxxxxxx', to='+1xxxxxxxxxx' ) return recording_url
You will need the Flask framework and the SignalWire Python SDK downloaded.
To run the application, execute
export FLASK_APP=your_file_name.py then run
Updated 14 days ago