Skip to content

Latest commit

 

History

History
75 lines (51 loc) · 3.18 KB

README.md

File metadata and controls

75 lines (51 loc) · 3.18 KB

Voice Gather

Voice Quick Start Guide

Table of Contents

Description

This sample app creates an outbound call to the supplied phone number, which if answered will prompt the user using Gather BXML to select between a list of options to hear different messages played back.

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:

npm i

Use the following command to run the application:

npm start

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
BW_NUMBER                            # The Bandwidth phone number involved with this application
USER_NUMBER                          # The user's phone number involved with this application
BW_VOICE_APPLICATION_ID              # Your Voice Application Id created in the dashboard
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:

  • /calls
  • /callbacks/outbound/voice
  • /callbacks/outbound/gather

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.