Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
116 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
var express = require('express'); | |||
var app = express.createServer(); | |||
var sys = require('sys'); | |||
var tropowebapi = require('tropo-webapi'); | |||
|
|||
// 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.post('/', function(req, res) { | |||
|
|||
var tropo = new tropowebapi.TropoWebAPI(); | |||
|
|||
mc = new MachineDetection("This is a test. Please hold while I determine if you are a Machine or Human. Processing. Finished. THank you for your patience.", "Victor") | |||
tropo.call("+14071234321", null, null, "14075559090", null, "call", null, null, true, 60, null, mc); | |||
tropo.on("continue", null, "/call", true); | |||
|
|||
res.send(tropowebapi.TropoJSON(tropo)); | |||
}); | |||
|
|||
app.post('/call', function(req, res){ | |||
|
|||
var tropo = new tropowebapi.TropoWebAPI(); | |||
|
|||
var userType = req.body['result']['userType']; | |||
tropo.say("You are a " + userType); | |||
|
|||
res.send(tropowebapi.TropoJSON(tropo)); | |||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,25 @@ | |||
var http = require('http'); | |||
var tropo_webapi = require('tropo-webapi'); | |||
|
|||
var server = http.createServer(function (request, response) { | |||
|
|||
request.addListener('data', function(data){ | |||
json = data.toString(); | |||
}); | |||
|
|||
request.addListener('end', function() { | |||
|
|||
var session = JSON.parse(json); | |||
var tropo = new TropoWebAPI(); | |||
var callerID = session.session.from.id; | |||
|
|||
var join = new JoinPrompt("Please welcome " + callerID + " to the party!", null); | |||
var leave = new LeavePrompt(callerID + " has just decided to depart.", null); | |||
|
|||
tropo.conference("1234", false, null, null, true, null, null, null, join, leave); | |||
|
|||
response.end(TropoJSON(tropo)); | |||
}); | |||
|
|||
}).listen(8000); | |||
console.log('Server running on port :8000'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,48 @@ | |||
var express = require('express'); | |||
var app = express.createServer(); | |||
var sys = require('sys'); | |||
var tropowebapi = require('tropo-webapi'); | |||
|
|||
// 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.post('/', function(req, res) { | |||
|
|||
console.log('In the first resource'); | |||
var tropo = new tropowebapi.TropoWebAPI(); | |||
console.log('1'); | |||
|
|||
var say = new Say("Press 1 to accept this call or any other number to reject"); | |||
var choices = new Choices("1", "dtmf", null); | |||
|
|||
var whisper = new Array(); | |||
console.log('3'); | |||
// | |||
var ask = new Ask(choices, null, null, null, "color", null, null, say, 60, null); | |||
whisper[0] = new On("connect", null, null, null, null, ask, null, null); | |||
console.log('4'); | |||
|
|||
var say = new Say("You are now being connected"); | |||
whisper[1]= new On("connect", null, null, null, say, null, null, null); | |||
console.log('5'); | |||
|
|||
tropo.say("Please hold while you are being transferred"); | |||
tropo.transfer("+14071234321", null, null, null, null, "foo", whisper, true, "*", null, null, null, null); | |||
console.log('6'); | |||
|
|||
var incompleteSay = new Say("You are now being disconnected"); | |||
tropo.on("incomplete", null, "/hangup", null, incompleteSay, null, null, null); | |||
|
|||
|
|||
res.send(tropowebapi.TropoJSON(tropo)); | |||
|
|||
|
|||
}); | |||
app.post('/hangup', function(req, res){ | |||
var tropo = new tropowebapi.TropoWebAPI(); | |||
tropo.hangup(); | |||
res.send(tropowebapi.TropoJSON(tropo)); | |||
}); |