Skip to content

Instantly share code, notes, and snippets.

View aylarov's full-sized avatar

Alexey Aylarov aylarov

View GitHub Profile
@aylarov
aylarov / dialogflow_connector.js
Created October 8, 2018 16:43
DialogflowConnector
require(Modules.AI)
var dialogflow, call
// Inbound call processing
VoxEngine.addEventListener(AppEvents.CallAlerting, (e) => {
call = e.call
call.addEventListener(CallEvents.Connected, onCallConnected)
call.addEventListener(CallEvents.Disconnected, VoxEngine.terminate)
call.answer()
require(Modules.ASR);
let mycall = null;
VoxEngine.addEventListener(AppEvents.CallAlerting, (e) => {
mycall = e.call;
mycall.addEventListener(CallEvents.Connected, handleCallConnected);
mycall.answer();
});
{"coord":
{
"lon":120.99,
"lat":15.79
},
"weather":[
{
"id":802,
"main":"Clouds",
"description":"scattered clouds",
const sessionId = () => Math.floor(100000 * Math.random());
Net.httpRequest("https://api.dialogflow.com/v1/query?v=20170712&contexts=weather&query="
+ encodeURI(userSpeech)
+ "&lang=en&sessionId="
+ sessionId()
+ "&timezone=Europe/Moscow", (e) => {
// here we receive the JSON and continue our scenario execution
},
{ headers: ["Authorization: bearer 1799227ce77f446fa8d64749f70527ca"]});
{
"id": "5111e0da-5970-4a11-a458-28830f59bc73",
"timestamp": "2018-02-28T19:26:27.43Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "What is the weather in San Francisco?",
"action": "weather",
"actionIncomplete": false,
"parameters": {
curl ‘https://api.dialogflow.com/v1/query?v=20170712&query=What%20is%20the%20weather%20in%20San%20Francisco%3F&lang=en&sessionId=93882e69-fdeb-417d-9f73-7347c8e57a2f&timezone=Europe/Moscow' -H ‘Authorization:Bearer 1799227ce77f446fa8d64749f70527ca’
@aylarov
aylarov / bridge.js
Last active March 16, 2018 09:36
Zoom-WebSDK
var regions = {
"US_West": "162.255.37.11",
"US_East": "162.255.36.11",
"China": "221.122.88.195",
"India": "115.114.131.7",
"EMEA": "213.19.144.110"
};
VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) {
/**
@aylarov
aylarov / ASR_Example2.js
Created August 14, 2017 15:09
Example#2
call.record({ transcribe: true, language: ASRLanguage.ENGLISH_US, format: “json” })
@aylarov
aylarov / ASR_Example.js
Created August 14, 2017 15:08
Example#1
call.record({ transcribe: true, language: ASRLanguage.ENGLISH_US })
/**
* Make PSTN call-out
*/
function handleCallOut(num) {
var pstn = VoxEngine.callPSTN(num);
pstn.addEventListener(CallEvents.Connected, function (e) {
pstnCalls.push(e.call);
VoxEngine.sendMediaBetween(pstn, conference);
});
pstn.addEventListener(CallEvents.Disconnected, function (e) {