Menu

Park an Interaction

Flex Conversations requires Flex UI 2.0. If you are on Flex UI 1.x, please refer to Messaging in Flex pages.

Unlike voice channels, digital channels like SMS and chat are asynchronous and last indefinitely, with no clear event indicating the end of a conversation.

Due to this open-ended nature of digital channels, a customer contact or inquiry could stall, and an agent may need to wait for the customer or a back-office personnel to reply in order to continue the conversation. This scenario could persist over several days, or even weeks.

The Interactions API allows you to remove the agent from the channel while leaving the customer in the interaction. In order to follow along, please review the Interactions Resource and the Interaction Channel Participants page for detailed examples.

A channel is deleted after 180 days of inactivity regardless of state. Retrieving the channel after 180 days from deletion returns a 404 Not Found. Note that the initial TTL (Time to Live) period resets every time there is an update to the channel (e.g. adding and removing a participant, or updating the channel status).

Make sure to include the original task attributes in your subsequent POST /Invites requests since these attributes are not carried over to the new Task created as a result of sending the Invite.

Remove an agent but keep the interaction open

To remove an agent, send a POST (update) request to the Participants endpoint.

curl -X POST https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants/UTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
--data-urlencode "Status=closed" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

When a "closed" status is passed, the associated task is completed but the channel, Conversation in this case, remains active.

To re-add an agent, or “unpark/pick up” the interaction, you can use the Invites endpoint to reroute the new task to a specific agent or to specify a workflow for evaluating a suitable queue or agent.

Create a new task and have a workflow evaluate it for routing

To create a new task for workflow evaluation, send a POST (create) request to the Invites endpoint.

ROUTING=$(cat << EOF
{
    "properties": {
        "attributes": {
            "from": "+13115552368"
        },
        "workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
}
EOF
)

curl -X POST https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Invites \
--data-urlencode "Routing=$ROUTING" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

Example response

{
   "url": "https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Invites/KGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
   "interaction_sid": "KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
   "channel_sid": "UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
   "routing": {
       "reservation": null,
       "properties": {
           "date_updated": 1636401979,
           "age_in_queue": 0,
           "task_channel_unique_name": "default",
           "assignment_status": "pending",
           "queue_name": "Sample Queue",
           "assignmentCounter": 0,
           "priority": 0,
           "sid": "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
           "task_queue_entered_date": 1636401979,
           "workflow_name": "Default Fifo Workflow",
           "workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
           "routing_target": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
           "reason": null,
           "attributes": "{\"flexChannelInviteSid\":\"KGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\"conversationSid\":\"UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\"channelType\":\"email\",\"conversations\":{\"communication_channel\":\"Email\",\"conversation_id\":\"KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\"media\":[{\"conversation_sid\":\"UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\"media\":[{\"type\":\"ChatTranscript\",\"sid\":\"CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}],\"customers\":{\"phone\":\"+13115552368\",\"name\":null,\"email\":null}},\"flexInteractionChannelSid\":\"UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\"flexInteractionSid\":\"KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}",
           "task_channel_sid": "TCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
           "age": 0,
           "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
           "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
           "timeout": 86400,
           "date_created": 1636401979,
           "addons": "{}",
           "queue_sid": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
       }
   },
   "sid": "KGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

Add a specific agent back to the interaction

Alternatively, you can include a queue SID and a Worker SID in your POST Invites request to add a specific agent back to the Interaction:

ROUTING=$(cat << EOF
{
    "properties": {
        "attributes": {
            "from": "+13115552368"
        },
        "workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        "queue_sid": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        "worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
}
EOF
)

curl -X POST https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Invites \
--data-urlencode "Routing=$ROUTING" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

Close the interaction channel

Once the customer issue has been solved, you can set the status of the interaction channel to closed by sending a POST (update) Interaction Channel request like so:

curl -X POST https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
--data-urlencode "Status=closed" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

This will set any reservations to the "wrapping" status.

Example Park Application

example park application

To try out a working implementation of an interaction park feature, check out the source code in this sample plugin repository.

Agent Parks an Interaction Channel

agent parks an interaction channel

Customer Sends Message to a Parked Interaction

customer sends message to a parked interaction

Agent Picks up a Parked Interaction Channel

agent picks up a parked interaction channel

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

Thank you for your feedback!

Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

thanks-feedback-gif