Skip to content

Instantly share code, notes, and snippets.

View ObjectIsAdvantag's full-sized avatar

Stève Sfartz ObjectIsAdvantag

View GitHub Profile
@ObjectIsAdvantag
ObjectIsAdvantag / tropo-ivr-sample.js
Created March 24, 2017 10:05
Tropo Welcome IVR sample
wait(1000);
say("Welcome to DevNet: Cisco Developer Program");
wait(1000);
say("bye bye");
@ObjectIsAdvantag
ObjectIsAdvantag / tropo-signal.js
Last active March 17, 2017 11:45
Tropo script skeleton to create a Signaling Service
// Constructor for the Cisco Spark Logging Library
// - token: we recommend to leverage a Cisco Spark Bot Account
// - roomId: add your bot to the room you want to chat to
function SparkLog(token, roomId) {
this.token = token;
this.roomId = roomId;
}
SparkLog.prototype.log = function(newLogEntry) {
var result;
try {
say("Hello world")
say("Thank you for calling the random message hotline");
function pickRandomQuote() {
var quotes = [
"Speech was given to man to disguise his thoughts.",
"The adjective is the banana peel of the parts of speech."
];
return quotes[Math.floor(Math.random() * quotes.length)];
}
ask("Please enter your phone number followed by the pound sign", {
@ObjectIsAdvantag
ObjectIsAdvantag / sip-headers.js
Last active February 6, 2017 14:12
a Tropo script to learn SIP and SIP headers: on incoming call, speak the username of the calling SIP address; on outgoing call, speaks a basic text
// New incoming call
if (currentCall) {
answer();
say("Welcome to Tropo SIP demo");
wait(500);
say("Let's guess your username !");
wait(500);
@ObjectIsAdvantag
ObjectIsAdvantag / test-github-caching.js
Last active February 8, 2017 05:48
Github caching options
if (currentCall) {
say("Welcome to the caching service");
}
else {
call(phonenumber, { network:"SMS"});
say(msg);
}
@ObjectIsAdvantag
ObjectIsAdvantag / outbound-dialer.js
Last active January 28, 2017 15:19
Debug Dial outbound
var csvFile = loadFile("http://hosting.tropo.com/5075556/www/data/numbers.csv");
var numbersToDial = csvJSON(csvFile);
for (var i = 0; i<numbersToDial.length-1; i++){
var callee = numbersToDial[i];
call(callee.number, { network: "SMS" });
say("Hi, " + callee.name);
hangup();
}
@ObjectIsAdvantag
ObjectIsAdvantag / tropo-log2spark-bot.js
Last active January 5, 2017 11:52
Tropo ChatOps library that logs to Cisco Spark (javascript)
// QUICK START GUIDE
//
// 1. Create a Cisco Spark bot account dedicated to 'ChatOps', and store its token in a safe place
// 2. Create a Group room named "Tropo ChatOps", store its identifier in a safe place
// 3. Add your ChatOps bot as a member of the "Tropo ChatOps room"
// 4. Clone this gists, make it secret, and edit it
// 5. Replace the ChatOps bot token and ChatOps room identifier
// 6. Save your gists (keep it secret as it contains your bot's token), and click Raw
// 7. Create a Tropo application, with 'Scripting' type, pointing to your gist raw URL
function requestJSONviaGET(url) {
try {
var connection = new java.net.URL(url).openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(false);
connection.setDoInput(true);
connection.connect();
if (connection.getResponseCode() != 200) return undefined;
// POST https://api.recast.ai/v2/request?Authorization=Token XXXXX
// {
// "text": "I need somone speaks swedish",
// "language" : "en"
//
function invoke(phonenumber, text) {
try {
// Open Connection
var url = "https://vertkawaa.localtunnel.me/tropo";
var connection = new java.net.URL(url).openConnection();