Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Set up live agent assistance with Conversation Intelligence and Flex


This guide shows you how to set up a Flex plugin and backend service that use Conversation Intelligence to surface real-time insights and guidance to agents during live calls. You'll clone a sample application, configure Conversation Intelligence with language operators, and deploy a Flex plugin that displays the live results directly in the agent desktop.

A screenshot of the Flex plugin displaying live agent assistance

Live agent assistance use cases

live-agent-assistance-use-cases page anchor

The following are some examples of how you can use Conversation Intelligence and Flex to provide real-time assistance to agents during live calls:

  • Triggering next best actions (both conversation prompts and system actions)
  • Delivering targeted responses or actions based on sentiment, for agents and supervisors
  • Providing live coaching, either automated or with supervisor input
  • Surfacing contextual data relevant to the current issue, question, or comment
  • Identifying sales-related opportunities (upsell, cross-sell, churn risk response, competitor mention)

Sample application architecture

sample-application-architecture page anchor

In this guide, you'll learn how to build a live agent assistance solution using Twilio Flex, Conversation Intelligence, and Conversation Orchestrator. The solution provides real-time insights and guidance to agents during live calls, helping them improve customer interactions and outcomes.

There are three primary components to this solution. In this example, the components are already built for you, and you'll mainly be setting up the configuration in your Flex instance.

Backend service

backend-service page anchor

The server can run on your own desktop (using ngrok), but you'd typically deploy it to your cloud platform of choice. This guide uses Node, but you could use Python or another stack of your choice. The server is responsible for receiving webhooks from the Twilio Conversations services, processing them, and providing a standardized format for use in the Flex plugin. This standard format is then piped over to the plugin via SSE (Server-sent Events), using the Call SID as an identifier.

Use Conversation Orchestrator and Conversation Intelligence to gain insights on the active call. You can set up these services using the Twilio Console or the API.

A custom plugin receives information processed by the backend service and formats for display to the human agent directly inside the Flex agent desktop. Information is displayed based on the active Task represented by a Call SID.



To start ngrok and create a tunnel to your localhost, run:

ngrok http 3001

The ngrok console displays your forwarding URL (for example, https://your-ngrok-domain.ngrok.app).


In a terminal, clone the application repository and navigate to the project directory:

1
git clone https://github.com/skills0/flex-agentassist-cintel.git
2
cd flex-agentassist-cintel

The repository includes two main folders: /server and /plugin-cintel-rtt


In each of the /server and /plugin-cintel-rtt directories, run:

npm install

Configure environment variables

configure-environment-variables page anchor

Create .env files for both your server and your plugin:

/server/.env

serverenv page anchor
1
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2
TWILIO_AUTH_TOKEN=your_auth_token
3
TWILIO_API_KEY=SKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
4
TWILIO_API_SECRET=your_api_secret
5
TWILIO_FLEX_PHONE_NUMBER=+1xxxxxx1234
6
SERVER_URL=https://your-ngrok-domain.ngrok.app

/plugin-cintel-rtt/.env

plugin-cintel-rttenv page anchor
REACT_APP_BACKEND_URL=https://your-ngrok-domain.ngrok.app

Configure your Twilio phone number

configure-your-twilio-phone-number page anchor
  1. In the Twilio Console, go to Numbers & senders > Phone numbers(link takes you to an external page) and click your Twilio phone number.
  2. On the Configuration details tab, click Voice and emergency address.
  3. Click Edit configuration details and select the region.
  4. Under How do you want to configure this number?, select Webhook, TwiML Bin, Function, Studio Flow, Proxy Service.
  5. Under How do you want to set up your primary method, select Use Studio Flows and select Voice IVR.
  6. Under Call status change, enter https://your-ngrok-domain.ngrok.app/webhook/status and select HTTP POST.

Set up Conversation Intelligence

set-up-conversation-intelligence page anchor

Set up Conversation Intelligence with language operators. You can use Twilio-authored language operators for common tasks like sentiment analysis and summaries, or create custom language operators tailored to your business needs.

Twilio ConsoleAPI
  1. Create a conversation configuration with capture rules.

    1. In the Twilio Console, go to Products & Services > Conversation Orchestrator > Conversation configurations(link takes you to an external page).
    2. Click Create a conversation configuration and follow the steps in the UI.
      1. On the Name configuration page, set Conversation configuration name and Description. Under Webhook, enter your webhook URL (for example, https://your-ngrok-domain.ngrok.app/webhook/cor-event) and select the POST HTTP method.
      2. Skip Messaging and chat traffic.
      3. On the Voice traffic page, check the Set up automatic capture box and select your Twilio phone number.
      4. On the Configure lifecycle page, select Basic and set voice calls to close On Hangup.
      5. On the Enable Conversation Memory page, select an existing memory store or create one. Check the Turn on observations and summaries box.
      6. Review the Voice transcription page.
      7. Review the Summary page and click Create conversation configuration.
  2. Create an intelligence configuration and link it to the conversation configuration.

    1. In the Twilio Console, go to Products & Services > Conversation Intelligence > Intelligence configurations(link takes you to an external page).
    2. Click Create Intelligence configuration and follow the steps in the UI. Make sure to attach the conversation configuration you created in the previous step.
    3. Click Create rule for the intelligence configuration and follow the steps in the UI.
      • Add language operators and set parameters.
      • Apply triggers and actions.
      • Optionally, enable context.

Example: Script Adherence operator

example-script-adherence-operator page anchor

Define a rule with the Script Adherence operator to ensure agents follow a script during calls. For more information, see Script Adherence operator best practices.

This example evaluates if the agent greeted the customer, verified their identity, gathered move details, and confirmed next steps.

OperatorsParametersTriggersActions
Script AdherencescriptEvery communication ({"on":"COMMUNICATION","parameters":{"count":1}})Webhook ({"method":"POST","type":"WEBHOOK","url":"https://your-ngrok-domain.ngrok.app/webhook/cintel-action"})

Script Adherence operator script

script-adherence-operator-script page anchor
1
Category: Greeting
2
Action: Greet the customer with business name and agent name.
3
Required Phrase: "Thanks for contacting {company name}. This is {agent_name}."
4
Score weight:10%
5
6
Category: Verification
7
Goal: Confirm identity quickly
8
Action: Capture customer move date and to/from cities within first 50 seconds of conversation.
9
Score weight:20%
10
11
Category: Move Details
12
Goal: Confirm move details and answer questions
13
Action: Agent collects details about the customer's move, including special items, international moves, customs, and insurance options
14
Score weight:40%
15
16
Category: Confirmation
17
Goal: Next Steps
18
Action: Agent summarizes next steps (preferred channel, video walkthrough)
19
Score weight:30%

Example: Sentiment and Summary operator

example-sentiment-and-summary-operator page anchor

Define a rule with the Sentiment and Summary operators to evaluate the sentiment of the conversation and generate a summary. This example triggers after every 5 communications.

OperatorsParametersTriggersActions
Sentiment and SummaryN/AEvery 5 communications ({"on":"COMMUNICATION","parameters":{"count":5}})Webhook ({"method":"POST","type":"WEBHOOK","url":"https://your-ngrok-domain.ngrok.app/webhook/cintel-action"})

  1. Deploy the Flex plugin and test it locally.

    1
    cd plugin-cintel-rtt
    2
    twilio flex:plugins:start
  2. Confirm you are connected to the correct profile for your target Flex account.

    twilio profiles:list

    To switch the profile, run:

    twilio profiles:use PROFILE_ID
  3. Deploy the UI component that agents will use.

    1. Update webpack.config.js case statement to match your Twilio CLI profile name for your Flex account.

    2. Copy /plugin-cintel-rtt/.env to /plugin-cintel-rtt/.env.production with your backend URL.

    3. Run twilio flex:plugins:deploy using the example below.

      twilio flex:plugins:deploy --profile=<YOUR_PROFILE_NAME> --changelog "Initial" --description "Flex live agent assistance plugin example"
  4. When the deployment completes, the Twilio CLI prints a twilio flex:plugins:release command. Run that command to release your plugin and make it active for agents.


Test your agent assistance

test-your-agent-assistance page anchor
  1. Start your local server.

    1
    cd server
    2
    npm run dev
  2. Open your Flex instance and set your status to Available.

  3. Make a call to the phone number configured in your conversation configuration.

  4. Accept the task.

As you speak, the Agent View tab in Flex will automatically check off agent adherence steps (Greeting, Identity, and more) as the language operator detects them.


You can expand the sample application by adding a custom language operator, such as Upsell Opportunity Detection.

Regardless of which language operators you add, your plugin implementation needs to be aware of the types of language operator results it will receive. In this guide, the plugin is responsible for taking the raw output, which is normalized by the server webhook implementation, and figuring out how to display it.

Here are some examples of how you can customize the plugin to display results from your language operators:

  • To update the steps in your Script Adherence operator, change plugin-cintel-rtt/src/config/scriptDimension.json to match.
  • To show results for Summary and Sentiment operators above the transcript, update plugin-cintel-rtt/src/components/TranscriptPanel.tsx.
  • To change how operator results are processed before they're passed to other components as props, update plugin-cintel-rtt/src/components/OperatorResultLog.tsx.

Alternatively, you can also implement more logic in the backend server, with pre-defined message payloads for various types of results that your plugin knows how to display.