Skip to content

Bandwidth-Samples/voice-record-python

Repository files navigation

Voice Record

Voice Quick Start Guide

Table of Contents

Description

This sample app demonstrates how to record a message from an inbound call, similar to how a voicemail machine would work.

When the user calls the Bandwidth phone number associated with this application, the user will hear an audio prompt to leave a message, then a beep. Once this happens, the call will begin recording.

When the call ends, Bandwidth will start to process the recording. Once this processing is complete, Bandwidth will send a webhook to the /recordingAvailableCallback endpoint on this application. Once received, the application will download the recording via Bandwidth's voice recording API.

Pre-Requisites

In order to use the Bandwidth API users need to set up the appropriate application at the Bandwidth Dashboard and create API tokens.

To create an application log into the Bandwidth Dashboard and navigate to the Applications tab. Fill out the New Application form selecting the service (Messaging or Voice) that the application will be used for. All Bandwidth services require publicly accessible Callback URLs, for more information on how to set one up see Callback URLs.

For more information about API credentials see our Account Credentials page.

Running the Application

To install the required packages for this app, run the command:

pip install -r requirements.txt

Use the following command to run the application:

python main.py

Environmental Variables

The sample app uses the below environmental variables.

BW_ACCOUNT_ID                        # Your Bandwidth Account Id
BW_USERNAME                          # Your Bandwidth API Username
BW_PASSWORD                          # Your Bandwidth API Password
LOCAL_PORT                           # The port number you wish to run the sample on

Callback URLs

For a detailed introduction, check out our Bandwidth Voice Callbacks page.

Below are the callback paths:

  • /callbacks/callInitiatedCallback
  • /callbacks/recordingAvailableCallback

Ngrok

A simple way to set up a local callback URL for testing is to use the free tool ngrok. After you have downloaded and installed ngrok run the following command to open a public tunnel to your port ($LOCAL_PORT)

ngrok http $LOCAL_PORT

You can view your public URL at http://127.0.0.1:4040 after ngrok is running. You can also view the status of the tunnel and requests/responses here.

Once your public ngrok url has been created, you can update the voice application you created in the Pre-Requisites section to use it. Your Call-initiated callback url will be: <your-public-ngrok-url>/callbacks/callInitiatedCallback

About

Record a voice call using our Python SDK

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages