Skip to content

Latest commit

 

History

History
152 lines (102 loc) · 6.18 KB

README.md

File metadata and controls

152 lines (102 loc) · 6.18 KB

phonebot

Slackbot that lets users make phone calls within a Slack channel. Users can dial a phone number, with the phone call audio converted to text and sent to the channel. Channel message replies are converted to speech and sent over the phone call.

Twilio is used to make phone calls and capture call audio. IBM Watson's "Speech To Text" service is used to translate the audio into text. NodeJS web application handles incoming messages from Slack, IBM Watson and Twilio.

Bluemix button

Build Status js-standard-style

Phonebot

Usage

Once the Phonebot application is registered for a Slack channel, the following commands are available:

@phonebot call PHONE_NUMBER <-- Dials the phone number
@phonebot say TEXT <-- Sends text as speech to the call 
@phonebot hangup <-- Ends the active call
@phonebot verbose {on|off}<-- Toggle verbose mode
@phonebot duration NUMBER <-- Set recording duration
@phonebot help <-- Show all commands usage information 

Deployment Instructions

Phonebot is a NodeJS application designed for deployment to IBM Bluemix, a Cloud Foundry Platform-as-a-Service instance.

Before deploying the application, we need to...

Slack Webhooks

Phonebot can be registered on multiple channels.

Every channel you want Phonebot to join needs both an outgoing incoming and outgoing webhook.

Set up Outgoing Slack Webhooks

Outgoing Webhooks are used to notify Phonebot when messages for the bot (@phonebot command) are sent to the channel. Visiting the Service Integration page will allow you to create a new webhooks that posts all messages starting with a keyword to an external URL.

The following parameters must be configured:

  • Channel - Channel for Phonebot to listen on
  • Trigger Words - @phonebot
  • URL - http://<INSERT_APP_NAME>.mybluemix.net/slackbot

Outgoing Webhooks

Set up Incoming Slack Webhooks

Incoming Webhooks are used by Phonebot to post the translated call audio as channel messages. We need an incoming webhook for each channel with a registered outgoing webhook. Visiting the Service Integration page will allow you to create a new incoming webhook URL to post channel messages.

Incoming Webhooks

Copy the generated URL that exposes the webhook, you will need to pass this into the application as explained in the section below.

Deploy to IBM Bluemix

Before we can deploy the application, we need to create the service credentials the application relies on within IBM Bluemix.

These credentials will be bound to the application at runtime.

Twilio

Register for a developer account at Twilio.

Connect an external phone number to the account, this will be used as the caller id when making phone calls.

Authentication credentials for Phonebot will be available here.

Run the following CF CLI command to expose your developer account credentials to the platform. Replace the ACCOUNT_SID and TOKEN values with credentials from your account settings page.

$ cf cups twilio -p '{"accountSID":"ACCOUNT_SID","authToken":"TOKEN", "url": "https://api.twilio.com"}'

Note: Phonebot will work with a Twilio trial account, however outgoing calls are only allowed to verified numbers. See here for more details.

IBM Watson

This "Speech To Text" service will be automatically created using the "Free Plan" when the application is deployed. To change the service instance the application uses, modify the manifest.yml.

Slack channels

Run the following CF CLI command to register your Slack channel webhooks within Phonebot.

$ cf cups slack_webhooks -p '{"channel_name":"incoming_webhook_url",...}'

Replace the channel_name and incoming_webhook_url with the actual values for the channel name and incoming webhooks found at your Slack integrations page.

You have to register each channel as a separate property.

Deploy!

Phew, you're now got everything configured! Deploying the application is easy, just run this command:

$ cf push --name your_random_identifier 

Modify your_random_identifier to a name relevant for your Phonebot instance.

Once the application has finished deploying, Phonebot will be listening to requests at http://your_random_identifier.mybluemix.net.

This address must match the URL registered with the outgoing webhooks.

... and you're done! Phonebot should post a message to each registered channel to confirm it's ready for action.

Development Mode

Running Phonebot on your development machine is possible provided you follow these steps...

  • Copy VCAP_SERVICES and VCAP_APPLICATION to local development environment.
  • Run node app.js to start application
  • Ensure application running on localhost is available at external URL, e.g. ngrok
  • Modify Slack outgoing webhooks to point to new URL