Twilio Flex direction:outbound Attribute
What is the direction:outbound task attribute and why is it significant?
Twilio Flex is callcenter software. It takes incoming communications and supports outgoing communications. It takes these communications and creates tasks and assigns them to callcenter workers.
Twilio gives you APIs and docs but sometimes not all the answers.
Here are a couple facts about this important task attribute,
direction, that I had to learn and here record my own answers.
It's Already Added Automatically
Case 1: In a Twilio callcenter implementation I helped write, when we set up the account, there is a Twilio Studio flow (another related product -- Twilio has tons of these) that adds task attributes on the last step when the Studio Flow passes the task to Flex. The default task attributes included
"direction": "inbound". Turns out, however, this is unneeded. Twilio will add this automatically.
Case 2: If you enable the Flex voice dialer, you can make ad hoc outbound voice calls.
direction: "outbound" is added to the task attributes created by such a method, automatically.
Case 3: If you want to create an outbound SMS task, you have to do so programmatically. You can do this with
twilioClient.flexApi.v1.interactions.create(). You can pass task attributes. We would usually add
direction: "outbound" to these attributes, but it turns out that Twilio will add this attribute automatically.
We now never set the
direction attribute. Where we need it, it happens automatically.
It Auto-accepts and Selects Tasks
We were getting tasks in the task list that were coming in and getting auto-accepted and auto-selected. This was messing up our callcenter workers' process by switching tasks (seen in
withTaskContext higher-order React component and
CRMContainer.uriCallback invocation) without the worker asking. But it took us a long time to find the culprit: the task attributes had
direction: "outbound" on them. That it was that attribute with that value that caused the issue was a surprising discovery.
There is something special about this exact key/value of
direction: "outbound". It's probably related to the fact the the ad hoc voice dialer uses it, as well as the
flexApi.v1.interaction.create api. But nothing in today's documentation alerted my mind to that fact.
We now never set the
direction attribute. And then all the tasks do as expected by default and require worker manual acceptance.
Powerful little attribute. A single grain of rice can tip the scale.