I've seen other question for the same problem, but answers are conflicting, and none works for me
I want to transfer incoming call to mobile phone, but not immediately: only IF AND WHEN user send a DTMF 3 on a select State, so I think using AppEvents.CallAlerting
is not suitable for my case:
Then I tried the following solutions (fwdState is called from menuState select clicking 3)
function fwdCall(e)
{
Call.removeEventListener(CallEvents.PlaybackFinished, fwdCall);
const callerId=Call.callerid();
const calledId='393333333333';
call = VoxEngine.callPSTN(calledId, callerId);
call.addEventListener(CallEvents.Connected, (e) => {
VoxEngine.sendMediaBetween(e.call, Call);
});
call.addEventListener(CallEvents.Failed, VoxEngine.terminate);
call.addEventListener(CallEvents.Disconnected, VoxEngine.terminate);
}
function fwdCall2(e)
{
Call.removeEventListener(CallEvents.PlaybackFinished, fwdCall2);
const callerId=Call.callerid();
const calledId='393333333333';
call = VoxEngine.callPSTN(calledId, callerId,{ followDiversion: true });
VoxEngine.easyProcess(e.call, call);
call.addEventListener(CallEvents.Failed, VoxEngine.terminate);
call.addEventListener(CallEvents.Disconnected, VoxEngine.terminate);
}
const fwdState = new IVRState('callforward', {
type: 'noinput',
prompt: {
play: 'please_wait_while_we_transfer.mp3'
}
},
(data) =>
{
Call.addEventListener(CallEvents.PlaybackFinished, fwdCall);
},
(data) =>
{
fwdState.enter(Call);
}
);
but both with fwdCall and fwdCall2 I get following error:
JS error: Call is not a constructor in /application.js:442:23
So I tested the example proposed on voximplant website HERE
but (after commenting let Call
at line 3)
I get same error as above.
Which is the right way to do it?
Thanks
Well...
seems both solutions are correct and works..
in fact error is not in these functions but at the beginning of the scenario:
in all examples, voximplant uses Call
as default variable to designate the call:
Call = e.call
but Call
is internally used by their routine, and when need to manage more than 1 call it returns error.
the solution is quite simple, in the first listener, that usually is
VoxEngine.addEventListener(AppEvents.CallAlerting, (e) => {
use call = e.call;
instead of Call = e.call;
That's it.