I am trying to add the option to transfer an outbound call to a task queue. I have it working just fine for inbound calls which are originally enqueued, then answered by the workers. But when I try to do the same thing on an outgoing call the call just drops.
This is what I'm using at the moment to place the call back into a queue. (C#)
Update In progress call
await CallResource.UpdateAsync(
pathSid: sid,
url: new Uri($"{_CallbackUrl}/EnqueueTransfer/{department}")
);
CallBack Response
var response = new VoiceResponse();
response.Play(new Uri("**URL**/please_wait_recording.Mp3"));
Enqueue enqueue = new Enqueue(workflowSid: _workflowSid);
enqueue.Task($"{{\"selected_department\":\"{department.ToLower()}\"}}");
response.Append(enqueue);
return new TwiMLResult(response);
Any ideas on why this only works for inbound calls and how could I get this working for outbounds?
My outbounds are created using the js client
let newCall = await device.connect({
params: {
To: formatNumber(number),
From: worker.attributes?.contact_uri,
WorkerTeam: worker.attributes?.team,
WorkerDepartment: worker.attributes?.department
}
});
#### UPDATE ####
The above code is working for both in and outbound calls HOWEVER when I transfer an already transferred outbound call. The calls drop from the customer phone and the agent gets redirected to the queue. I've tried updating the call resource using the following:
var Call2 = await CallResource.FetchAsync(pathSid: transfer.CallSid);
ResourceSet<CallResource> calls;
string sid= transfer.CallSid;
calls = await CallResource.ReadAsync(parentCallSid: transfer.CallSid);
if (Call2.Direction.ToLower() == "inbound")
{
sid = calls.FirstOrDefault().Sid;
}
await CallResource.UpdateAsync(
pathSid: sid,
url: new Uri($"{_CallbackUrl}/Transfer/{transfer.Team}")
);