It is not surprising that in many business processes, one way or another there is such a task as to call one phone number and then connect it with another number. Most often, this service is called callback or callback, sometimes - call order. Many have met him on the websites of online stores, but in most cases this is not an automated callback, but a regular application that falls to the manager by email or appears in CRM, after which the manager dials the client’s number and talks to him. Some large companies implement automated callback and even integrate it with queues in the contact center. In this post, we will look at how to create a callback script using the VoxImplant platform in just a few minutes, as well as integrate this farm with some existing backend for storing / retrieving data on a call, store pop-root and welcome under cat. 
VoxEngine.addEventListener(AppEvents.HttpRequest, handleHttpRequest); function handleHttpRequest(e) { VoxEngine.terminate(); } var call1, call2, data; const callerId = "+1234567890"; // VoxEngine.addEventListener(AppEvents.Started, handleScenarioStart); function handleScenarioStart(e) { // customData, // script_custom_data HTTP- StartScenarios // 1:2 data = VoxEngine.customData(); data = data.split(":"); // - 1 call1 = VoxEngine.callPSTN(data[0], callerId); // call1.addEventListener(CallEvents.Connected, handleCall1Connected); call1.addEventListener(CallEvents.Failed, function(e) { VoxEngine.terminate(); }); call1.addEventListener(CallEvents.Disconnected, function(e) { VoxEngine.terminate(); }); } function handleCall1Connected(e) { // , call1.say(", , ", Language.RU_RUSSIAN_FEMALE); call1.addEventListener(CallEvents.PlaybackFinished, function(e1) { // 2 call2 = VoxEngine.callPSTN(data[1], callerId); // call2.addEventListener(CallEvents.Connected, handleCall2Connected); call2.addEventListener(CallEvents.Failed, function(e2) { call1.say(" , ", Language.RU_RUSSIAN_FEMALE); call1.addEventListener(CallEvents.PlaybackFinished, function(e3) { VoxEngine.terminate(); }); }); call2.addEventListener(CallEvents.Disconnected, function(e2) { VoxEngine.terminate(); }); }); } function handleCall2Connected(e) { // - VoxEngine.sendMediaBetween(call1, call2); // VoxEngine.easyProcess(call1, call2); } call1.addEventListener(CallEvents.Failed, function(e) { VoxEngine.terminate(); }); call1.addEventListener(CallEvents.Failed, handleCall1Failed); function handleCall1Failed(e) { // var code = e.code, reason = e.reason; // HTTP- Net.httpRequest("http://somewebservice", function(e1) { // - e1.code, e1.text, e1.data, e1.headers // VoxEngine.terminate(); }); } 

https://api.voximplant.com/platform_api/StartScenarios/?account_id=1&api_key=eec36d6c-a0eb-46b5-a006-1c2b65343bac&rule_id=55033&script_custom_data=number1%3Anumber2 { "result" : 1, "media_session_access_url" : "http:\/\/1.2.3.4:12092\/request?id=93e41c6e20811b9b.1380201554.0@1.2.3.4&token=36bc7ce95edc679e32d83bb6f3ad985f" } Source: https://habr.com/ru/post/226057/
All Articles