Home

Awesome

MyHero Tropo WebAPI Interface

This is a Tropo WebAPI for a basic microservice demo application. This provides an interactive text and voice service for a voting system where users can vote for their favorite movie superhero.

Details on deploying the entire demo to a Mantl cluster can be found at

The application was designed to provide a simple demo for Cisco Mantl. It is written as a simple Python Flask application and deployed as a docker container.

Other services are:

The docker containers are available at

Cisco Tropo Account Requirement

In order to use this service, you will need a Cisco Tropo Account deploy the service.

Creating an account is free and only requires a working email account. Visit http://www.tropo.com to signup for an account.

Developer usage of Tropo is also free and information is available at http://www.tropo.com.

In order to build the Tropo Application, this application needs the Username and Password for your Tropo Account.

Basic Application Details

EDIT NEEDED

Required

Environment Installation

pip install -r requirements.txt

Basic Usage

In order to run, the service needs several pieces of information to be provided:

These details can be provided in one of three ways.

A command line argument overrides an environment variable, and raw input is only used if neither of the other two options provide needed details.

Accessing

Interacting with the Tropo Application

The Tropo Application is a very simple interface that is designed to make it intuitive to use. Once in the room, simply say "hello", "help" (or anything else) to have the bot reply back with some instructions on how to access the features.

Start by sending a TXT (SMS) message to the phone number assigned to the application.

The Application is designed to look for key words to act on, and provide the basic help message for anything else. The key words are:

REST APIs

/

The main service API is at the root of the applciation and is what is used by the Tropo Application.

/hello/:phonenumber

There is an API call that can be leveraged to have the Tropo Bot initiate an SMS session with a user. This API responds to GET requests and then will send a SMS message to the phone number provided.

Example usage

curl http://myhero-tropo.domain.local/hello/5551234567

/health

This is an API call that can be used to test if the Tropo Bot service is functioning properly.

curl -v http://myhero-tropo.domain.local/health 

*   Trying...
* Connected to myhero-tropo.domain.local (x.x.x.x)
> GET /health HTTP/1.1
> Host: myhero-tropo.domain.local
> User-Agent: curl/7.43.0
> Accept: */*
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Connection: close
< 
* Closing connection 0
Service up. 

Local Development with Vagrant

I've included the configuration files needed to do local development with Vagrant in the repo. Vagrant will still use Docker for local development and requires the following be installed on your laptop:

Before running vagrant up you will need to finish the Vagrant file configuration by adding the Tropo Username and Password to the environment variables used by the container. You will also need to change the URL that the Tropo service will be available at when in production. You can optionally change the prefix that the myHero_tropo service will use to create a number for the application.

To do this:

To start local development run:

Tropo makes building and developing applications very straightforward, but there is a couple of aspects of the nature of the service that add a little extra complexity. For this service, I opted to use the WebAPI to build an independent Microservice rather than let Tropo host the application code and use their ScriptingAPI. In this model, the Tropo Cloud Service sends a REST API call to the registered "messagingUrl" for the application. This URL needs to be accessible from the public internet hosted Tropo cloud. This is typically not practical for a development laptop and a workaround is needed.

One way to get started is to leverage Requestb.in, which is a free service that will provide you a publicly available URL to use during testing of APIs as a target for POSTs from services like Tropo. You can then retrieve the POST data from the web site, and use CURL on your local machine to POST to the service running locally to see the output of your function. A command like this would work:

curl -X POST -H "key: DevTropo" localhost:15005/ -d @tropo_request_sample.json

The downside to this is that the response and action don't make it back to Tropo where it can send messages back to users.

More detailed suggestions on developing services like this are beyond the scope of this README.

Each of the services in the application (i.e. myhero_web, myhero_app, and myhero_data) include Vagrant support to allow working locally on all three simultaneously.