This example shows how to implement an assisted transfer flow using the ruby SDK
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
public
readme_images
views
.editorconfig
.gitignore
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Gemfile
Gemfile.lock
ISSUE_TEMPLATE.md
LICENSE
PULLREQUEST.md
PULL_REQUEST_TEMPLATE.md
README.md
app.json
app.rb
config.ru

README.md

Business Grade Assisted Transfer App

This example app shows how you can use the Conference feature on the App Platform for an assisted transfer use-case. In this flow, there are 2 Agents and 1 contact. The system calls out to a contact and adds them into a conference. Then 'Agent 1' is added in, this is one of your call center agents, maybe a real-estate agent or a help desk. Once Agent 1 and the contact are connected, Agent 1 selects the number for another agent, 'Agent 2', and they are added into the conference. Agent 1 can now drop while Agent 2 and the contact continue the discussion.

Uses the:

Deploy

Prerequisites

Deploy To PaaS

Env Variables Required To Run

  • CATAPULT_USER_ID
  • CATAPULT_API_TOKEN
  • CATAPULT_API_SECRET
  • PHONE_NUMBER (your number for incoming calls)

Deploy

Demo

Screen Shot Open the app in web browser. You will see phone numbers list (you should fill it first) to make call and recorded calls (if they exist).

How it works

Basic Flow Chart

Create Call to Owner and set callback URL for events

Bandwidth::Call.create({
  from: get_service_phone_number(),
  to: ENV['PHONE_NUMBER'],
  callback_url: "#{request.base_url}/called-to-owner"
})

Speak Sentence then Create Bridge and set callbackURL for conference related events

call.speak_sentence('Welcome to the conference')
$call = call
Bandwidth::Conference.create({
 from: get_service_phone_number(),
 callback_url: "#{request.base_url}/conference-callback"
})

Add Member to conference then create new call to agent with recordingEnabled

$conference_member = $conference.create_member({call_id: $call.id})
Bandwidth::Call.create({
  from: get_service_phone_number(),
  to: $contact_phone_number,
  recording_enabled: true,
  callback_url: "#{request.base_url}/called-to-contact"
})

Add first agent to the conference

$conference.create_member({callId: params['callId']})

2nd Agent is requested to join call and callbackURL is set for events

Bandwidth::Call.create({
  from: get_service_phone_number(),
  to: phone_number,
  callback_url: "#{request.base_url}/called-to-agent"
})

After 2nd Agent Answers, create gather

call.create_gather("Agent from #{ENV['PHONE_NUMBER']} would like to join you to the conference. Press 1 to accept, Press 2 to decline.")

Run some logic on the gathered digits, hangup if press 2.

digit = params['digits'][0]
conference.create_member({callId: params['callId']}) if digit == 1 && $conference
if digit == '2'
   call.hangup()
end

At hangup, create gather to either speak Sentence or play message

digit = (params['digits'] || '')[0]
if digit == '1'
  call.speak_sentence('Leave you message after signal. Press # to complete recording.',
     'start-recording-message')
end
if digit == '2'
  puts "Play voice messages"
  play_voice_message(call)
end

Install

Before running export next environment variables :

PHONE_NUMBER - your phone number for incoming calls,

CATAPULT_USER_ID, CATAPULT_API_TOKEN, CATAPULT_API_TOKEN - auth data for Catapult API (to search and reserve a phone number, etc)

After that run bundle install to install dependencies.

You can run this demo like ruby app.rb or rackup on local machine if you have ability to handle external requests or use any external hosting.

Deploy on Heroku Manually

Create account on Heroku and install Heroku Toolbel if need.

Run heroku create to create new app on Heroku and link it with current project.

Run heroku addons:create mongolab to add mongodb support.

Configure the app by commands

 heroku config:set PHONE_NUMBER=your-number
 heroku config:set CATAPULT_USER_ID=your-user-id
 heroku config:set CATAPULT_API_TOKEN=your-token
 heroku config:set CATAPULT_API_SECRET=your-secret

Run git push heroku master to deploy this project.

Run heroku open to see home page of the app in the browser