Skip to content

About

Redirect a voice call using our Ruby SDK

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voice Redirect Loop

Voice Quick Start Guide

Table of Contents

Description

This sample app indefinitely redirects an inbound call to itself until an interruption is sent to end the call.

In the Bandwidth Dashboard, set the Application's Call initiated callback URL to <BASE_CALLBACK_URL>/callbacks/inbound/voice. Also set the Call status callback URL to <BASE_CALLBACK_URL>/callbacks/inbound/voice/disconnect so calls that hang up on their own are removed from the active list. These can also be done via the Dashboard API by setting CallInitiatedCallbackUrl and CallStatusCallbackUrl. Once configured, inbound calls to a number associated with that application will be redirected every 30 seconds and ring indefinitely. The callId of the inbound call is saved to a list of active calls, which can be accessed via a GET request to the /calls endpoint provided by the app.

To stop a call, make a DELETE request to the /calls/{callId} endpoint, replacing {callId} with that of the call you wish to end. This endpoint will redirect the call to the /callbacks/inbound/voice/callEnded endpoint, which breaks the redirect loop and speaks a sentence to let you know the call has been ended before hanging up.

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:

bundle install

Use the following command to run the application:

ruby app.rb

Environmental Variables

The sample app uses the below environmental variables.

BW_ACCOUNT_ID                        # Your Bandwidth Account Id
BW_CLIENT_ID                         # Your Bandwidth API OAuth Client Id
BW_CLIENT_SECRET                     # Your Bandwidth API OAuth Client Secret
BASE_CALLBACK_URL                    # Your public base url to receive Bandwidth Webhooks. No trailing '/'
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/inbound/voice
  • /callbacks/inbound/voice/callEnded
  • /callbacks/inbound/voice/disconnect

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 use it as the BASE_CALLBACK_URL environmental variable and set it in the voice application created in the Pre-Requisites section.

About

Redirect a voice call using our Ruby SDK

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages