This feature shows how an agent can initiate a video room from a webchat conversation within Flex. This plugin was built for Flex 2.0.
This feature is broken down into three main sections:
- Flex Plugin - starting at the root of the directory:
- The
./custom-components
folder contains the components to initiate and join the video room - The
./helpers
library contains utility functions related to updating the chat task attributes and attaching the audio/video tracks to the UI
- The
- Twilio Serverless - within the
/serverless-functions/src/functions/features/chat-to-video-escalation
directory:- This houses the Twilio Function paths which orchestrate the facilitation of access token generation, sync document management, and video room creation
- The assets are utilized to host the build output of the customer-facing web application that joins the customer into the video session, ultimately connecting them to the agent; for further details on how this application works & setup, see the application folder within the
/web-app-examples
folder at the root of this template
- Customer Facing Video App - within the
/web-app-examples/video-app-quickstart
directory:- A Next JS application built with React, TypeScript, and Twilio Paste design system
- This application is used by the customer to connect to the video session
- Twilio Serverless Functions - used to orchestrate the API requests to generate access tokens
- Twilio Serverless Assets - used to host the customer-side video room UI
- Twilio Sync - utilized as the source of truth to store information about the video room and requests
- Twilio Video JS - used for connecting and monitoring the video rooms on the client side
-
The video session can only be initiated by the Agent within Flex. Once determined a video session would be appropriate to resolve the customer's use case, the Agent clicks the
Video Icon
button in theTask Canvas Header
: -
After clicking the button, a request is sent to the Twilio function to generate a unique code, which serves as the video room name. Upon success, the unique code and full url to join the video session are returned to the Flex UI, which then auto-sends a message to the conversation with the customer:
-
Within the Flex UI, a new tab is visible to the Agent within the
Task Canvas Tabs
, labeledVideo Room
: -
After clicking
Join Video Room
, the agent is connected to the video room and can interact with the customer: -
On the customer's end, they would click the link included in the message, which would open a new browser tab to join the video room:
-
After clicking
Join Video Room
, the customer will connect to the room and interact with the Agent. The buttons below the video allow the customer to toggle their microphone and camera to on/off, share their screen, and disconnect from the video session: -
Once the video session is complete and the customer disconnects from the room, there is a Post Video UI where you could collect a CSAT or feedback:
Note: An agent will only be able to participate in one video session at a time. Additionally, an Agent must disconnect from the video session before being allowed to complete or wrap-up a task.
The following diagram demonstrates how a chat session can be escalated to video. More specifically, this flow outlines the technical details from agent initiation to connecting to the video room.
To test this feature locally:
-
Configure, build, and deploy the Customer Facing Video Application.
-
Deploy your Twilio Function - please follow the instructions laid out at the root of this repository to deploy the serverless function, specifically adding the following entries to the
.env
file within../../../../serverless-functions
:TWILIO_FLEX_SYNC_SID=ISxxxxxxxxxxxxxxxxxx VIDEO_CODE_LENGTH=7 VIDEO_CODE_TTL=3600 VIDEO_ROOM_TYPE=group VIDEO_RECORD_BY_DEFAULT=false
-
Setup Conversations Web Chat - to mock an interaction with a customer over web chat using conversations, please stand up the Twilio Flex Web Chat React Sample web app.
September 7, 2022
- Updated README and pushed code.
This plugin was created & inspired by a pre-existing solution located in this repo, for reference.
This software is to be considered "sample code", a Type B Deliverable, and is delivered "as-is" to the user. Twilio bears no responsibility to support the use or implementation of this software.