This file contains hidden or 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
var maxBackoff = 5000; | |
var expBackoffLogs = []; | |
function tryWithTimeout(testFunction, argument, timeout) { | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
resolve(); | |
}, timeout); | |
}).then(() => { | |
expBackoffLogs.push( |
This file contains hidden or 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
const accountSid = process.env.ACCOUNT_SID; | |
const authToken = process.env.AUTH_TOKEN; | |
const client = require('twilio')(accountSid, authToken); | |
client | |
.conferences('test-conference') | |
.participants.create({ | |
from: '+447723487719', | |
to: 'client:worker_client', | |
waitUrl: 'https://my.website.com/dialtone.mp3', // Link to dialtone mp3 |
This file contains hidden or 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
class StudioResponsesParser { | |
constructor(twilioAccountSid, twilioAuthToken, studioFlowSid) { | |
this.twilioClient = require('twilio')(twilioAccountSid, twilioAuthToken); | |
this.setFlowSid(studioFlowSid); | |
} | |
setFlowSid(studioFlowSid) { | |
this.studioFlowSid = studioFlowSid; | |
this.studioFlow = this.twilioClient.studio.v1.flows(studioFlowSid); | |
} |
This file contains hidden or 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
const fetch = require('node-fetch'); | |
const dialogflow = require('dialogflow'); | |
const projectId = '<Dialogflow JSON project_id>'; | |
const dfConfig = { | |
credentials: { | |
private_key: '<Dialogflow JSON private_key>', | |
client_email: '<Dialogflow JSON client_email>' | |
} | |
} |
This file contains hidden or 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
const accountSid = '<your account sid>'; | |
const authToken = '<your auth token>'; | |
const client = require('twilio')(accountSid, authToken); | |
client.messages | |
.create({body: 'Hi there!', from: 'leitha', to: '<your destination number>'}) | |
.then(message => console.log(message.sid)); |
This file contains hidden or 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
const accountSid = '<your account sid>'; | |
const authToken = '<your auth token>'; | |
const client = require('twilio')(accountSid, authToken); | |
client.messages | |
.create({body: 'Hi there!', from: 'leitha', to: '<your destination number>'}) | |
.then(message => console.log(message.sid)); |
This file contains hidden or 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
function (request, response) { | |
// Check if the event is `onConvesrationAdd`. This is the event that fires when a new conversation is created | |
if (event.EventType === 'onConversationAdd') { | |
// Creating a POST to Salesforce case API | |
fetch("https://um1.salesforce.com/services/data/v39.0/sobjects/Case", { | |
method: 'POST', | |
headers: { | |
"Content-Type": "application/json", | |
"Authorization": "<Your SF token>" | |
}, |