I set up a Twilio Flow to collect some data from the caller, using "Gather" widgets and connect the caller to FLEX agent.
Every time someone calls and gets connected, Twilio creates two separate records in its "Calls" log:
Neither of the logs give me data points that would allow me to connect these two calls and record them as a single event.
I tried passing {{widgets.SendCallToAgent.TaskSid}}
from the Twilio Flow as a parameter to the function that posts caller's input to the database, but it returned no value.
The only reference I could find that pointed me to the original call from the second call log was in the request URL under Request Inspector section of Call Details screen. CustomerCallSid key points to the call SID of the initial call.
http://torch.taskrouter.prod.twilio.com:19610/CallEvents?WorkspaceSid=WSXXXXXXXXXX&TaskSid=WTXXXXXXXXXXd&ReservationSid=WRXXXXXXXXXX&WorkerSid=WKXXXXXXXXXX&CustomerCallSid=CAXXXXXXXXXX
Is there a way to get CustomerCallSid as a separate data point in the flow or in the logs?
Are there any other common data points to relate these two records?
Flex TSE here.
By default, Flex uses Conferences to connect calls between agents and callers. Your original assessment is correct - the inbound callSID from the Studio Flow becomes the customer leg of the resulting conference. The other callSID you are seeing is the agent leg. The Conference SID (CF####) will have the record of both callSIDs, or you could implement something like the following in a Flex Plugin.
This code adds a listener to the complete-task event, and then updates the task attributes with the participant call SIDs
init(flex, manager) {
this.registerReducers(manager);
flex.Actions.addListener("beforeCompleteTask", (payload, abortFunction) => {
console.log("Custom Code to add Call Sids to the task attributes");
let task = payload.task
if(task.channelType == "voice"){
if(task.conference && task.conference.participants.length > 0){
let current_conf = {"sid": task.conference.conferenceSid}
let participant_list = {}
task.conference.participants.forEach(participant => {
if(participant.isMyself){
participant_list.worker = participant.callSid
}
else {
participant_list.customer = participant.callSid
}
current_conf.participants = participant_list
})
task.attributes.conference = current_conf
}
else{
console.error("Conference Object Not Found")
}
}
payload.task.setAttributes(task.attributes)
});
}
If this is an approach that works for you, I do recommend testing thoroughly for compatibility with your own Flex instance.