Skip to content

Instantly share code, notes, and snippets.

@aaronblohowiak
Forked from chrismatthieu/gist:945280
Created April 27, 2011 22:04
Show Gist options
  • Save aaronblohowiak/945332 to your computer and use it in GitHub Desktop.
Save aaronblohowiak/945332 to your computer and use it in GitHub Desktop.
Tropo Node.JS Transcription Example
/**
* Showing with the Express framwork http://expressjs.com/
* Express must be installed for this sample to work
* npm install express
* npm install tropo-webapi
*/
var tropoapi = require('tropo-webapi');
var express = require('express');
var app = express.createServer();
var sys = require('sys');
/**
* Required to process the HTTP body
* req.body has the Object while req.rawBody has the JSON string
*/
app.configure(function(){
app.use(express.bodyParser());
});
app.get('/', function(req, res) {
res.send('app must be called from tropo');
});
app.post('/', function(req, res){
sys.puts('answering call');
// Create a new instance of the TropoWebAPI object.
var tropo = new tropoapi.TropoWebAPI();
// Use the say method https://www.tropo.com/docs/webapi/say.htm
tropo.say("Welcome to my Tropo Web API node demo.");
// Demonstrates how to use the base Tropo action classes.
var say = {"value":"Please leave a message."};
// var choices = new tropo.Choices("[5 DIGITS]");
var choices = {"terminator":"#"};
var transcription = {"id":"1234", "url":"mailto:[email protected]"}
//function(attempts, bargein, beep, choices, format, maxSilence, maxTime, method, minConfidence, name, required, say, timeout, transcription, url, password, username)
tropo.record(null, null, null, choices, null, 7, 60, null, null, "recording", null, say, 10, transcription, "http://web1.tunnlr.com:11053/audio/filename.mp3", null, null);
res.send(tropoapi.TropoJSON(tropo));
});
app.post('/audio', function(req, res){
sys.puts('receiving transcription');
});
app.listen(8000);
// console.log('Server running on http://0.0.0.0:8000/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment