Skip to content

Instantly share code, notes, and snippets.

View aylarov's full-sized avatar

Alexey Aylarov aylarov

View GitHub Profile
@aylarov
aylarov / Piece of ZoomBridge.js
Created July 19, 2017 15:49
Call-Out for ZoomBridge
// Handle commands for PSTN Call-out
// To initiate call-out use the URL that looks as follows: media_session_access_url/CallOut/phonenumber
VoxEngine.addEventListener(AppEvents.HttpRequest, function (e) {
//Logger.write("HTTP REQUEST:");
//Logger.write(e.path);
var path = e.path.split("/"),
num;
if (path[path.length - 2] == "CallOut") {
num = path[path.length - 1];
handleCallOut(num);
@aylarov
aylarov / ZoomBridge.js
Created July 19, 2017 15:23
VoxEngine Scenarios of Zoom bridge. ZoomBrindge creates Voximplant conference and connect it to Zoom conference + processes Call-Ins/Call-Outs
require(Modules.Conference);
var customData,
confName,
conference,
pstnCalls = [];
/**
* Handle StartConference request
*/
@aylarov
aylarov / xwiki.js
Created June 30, 2017 16:01
X-Wiki parser for VoxEngine
/**
* X-Wiki Parser to get JSON from infobox
*/
var generate = function(length) {
if (length !== 0) {
length = Math.abs(length) || 10;
}
var output = Math.random().toString(36).slice(2).toUpperCase();
if (length === 0) {
@aylarov
aylarov / voxbot.js
Created June 30, 2017 15:58
Voximplant ASR + API.ai NLP
// Enable ASR module for speech recognition capabilities
require(Modules.ASR);
var call, asr,
baseURL = "https://api.api.ai/v1/",
accessToken = "PUT YOUR API.AI ACCESS TOKEN HERE",
nlp_result;
// Inbound call arrives
VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) {
@aylarov
aylarov / babelfish_p2p.js
Created March 24, 2017 06:43
Babelfish P2P Call
VoxEngine.forwardCallToUserDirect(null, true);
@aylarov
aylarov / babelfish_conference.js
Created March 24, 2017 06:41
Babelfish conference scenario
/**
* Require Conference module to get conferencing functionality
*/
require(Modules.Conference);
var videoconf,
calls = [],
clientType;
// Add event handler for session start event
@aylarov
aylarov / babelfish_gatekeeper.js
Last active March 24, 2017 06:30
VoxEngine scenario for Babelfish app - Gatekeeper
require(Modules.ASR);
require(Modules.Recorder);
/**
* Conference Gatekeeper
* Handle inbound calls and route them to the conference
*/
var call,
conferenceId,
conf,
API_KEY = "YOUR_GOOGLE_TRANSLATE_API_KEY",
@aylarov
aylarov / asr_voice_bot.js
Created January 9, 2017 09:27
Voximplant ASR example #4: voice bot
// Enable ASR module
require(Modules.ASR);
var call, asr;
// Answer inbound call
VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) {
call = e.call;
call.addEventListener(CallEvents.Connected, onCallConnected);
call.addEventListener(CallEvents.Disconnected, VoxEngine.terminate);
@aylarov
aylarov / asr_streaming_long.js
Created January 1, 2017 10:40
Voximplant ASR example #3: long streaming
var streaming_result = "";
asr.addEventListener(ASREvents.SpeechCaptured, function (e) {
// Don't stop sending media after SpeechCaptured event
//call.stopMediaTo(asr);
});
// Recognition results will continue arriving to the Result handler
asr.addEventListener(ASREvents.Result, function (e) {
if (e.confidence > 0) {
@aylarov
aylarov / asr_streaming_commands.js
Created December 16, 2016 15:52
Voximplant ASR example #2: streaming commands
// Enable ASR module
require(Modules.ASR);
var call, asr;
// Answer inbound call
VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) {
call = e.call;
call.addEventListener(CallEvents.Connected, onCallConnected);
call.addEventListener(CallEvents.Disconnected, VoxEngine.terminate);