Skip to contentSkip to navigationSkip to topbar
On this page
Looking for more inspiration?Visit the
(information)
You're in the right place! Segment documentation is now part of Twilio Docs. The content you are used to is still here—just in a new home with a refreshed look.

Spec: AI Copilot


This page is a guide for developers who want to track interactions with AI copilots using Segment. It explains what data to send to Segment, letting you understand customer interactions with AI copilots.


Overview

overview page anchor

AI copilots are like virtual assistants that help customers in conversations.

Each conversation starts when a customer sends their first message or question. Throughout the conversation, Segment can track various events that capture key moments, like messages sent and received, tools invoked, and media generated.

While some copilot conversations have clear ending points, which occur when the customer explicitly indicates that the conversation is over, the tracked events provide valuable insights into the entire conversation flow.


In this section, you'll find the tracked semantic events that serve as a starting point for AI copilot events. You can extend them based on your own requirements.

This table lists the events that you can track from any conversation:

EventDefinitionFields
Conversation StartedWhen a new conversation beginsconversationId
Message SentWhen the first message is added to a thread by userconversationId, messageId, message_body, role (default is "customer")
Message ReceivedNon-custom response (text/voice) to user prompt by copilotconversationId, messageId, message_body, role (default is "agent")
Conversation EndedWhen a conversation is completedconversationId, message_count
Action InvokedWhen the model or user invokes a capability or toolconversationId, messageId, type, action
Media GeneratedWhen the model generates an image/video/audioconversationId, messageId, type, sub_type
Component LoadedWhen a new custom (non-text/voice) component is shown to a userconversationId, messageId, type
Feedback SubmittedWhen a user rates a conversation or messageconversationId, messageId, rating
IdentifyWhen a new user is identified anonymously or knownuserId and/or anonymousId
Standard Track CallsFor all events sent to Segment based on user actions taken, like items purchased, support requestedconversationId, messageId, ...

Live chat events

live-chat-events page anchor

Segment can also track the following live chat events:

  • Conversation Started
  • Message Sent
  • Message Received
  • Custom Component Loaded
  • Action Invoked
  • Media Generated
  • Conversation Ended

This section contains the structure and properties of each AI copilot tracked event.

The Conversation Started event should be sent when a customer sends their first message.

This event supports the following semantic properties:

PropertyTypeDescription
conversationIdstringThe conversation's unique identifier.

Here's an example of a Conversation Started call:

1
{
2
"userId": "123",
3
"action": "track",
4
"event": "Conversation Started",
5
"properties": {
6
"conversationId": "1238041hdou"
7
}
8
}

The Message Sent event should be sent when a user adds a new message to a thread. The default for role is "customer".

This event supports the following semantic properties:

PropertyTypeDescription
conversationIdstringThe conversation's unique identifier.
messageIdstringThe message's unique identifier.
message_bodystringThe message's content.
rolestringThe message's sender; default is "customer".

Here's an example of a Message Sent call:

1
{
2
"userId": "123",
3
"action": "track",
4
"event": "Message Sent",
5
"properties": {
6
"conversationId": "1238041hdou",
7
"messageId": "msg123",
8
"message_body": "What's the best stock in the Nasdaq right now?",
9
"role": "customer"
10
}
11
}

The Message Received event should be sent when the copilot gives a non-custom response (either text or voice) to something the user asked.

The default for role is "agent". You can extend role to different agent type, like ai_agent, human_agent, task_automation_agent, and so on.

This event supports the following semantic properties:

PropertyTypeDescription
conversationIdstringThe conversation's unique identifier.
messageIdstringThe message's unique identifier.
message_bodystringThe received message's content.
rolestringThe message's sender; default is "agent".
1
{
2
"userId": "123",
3
"action": "track",
4
"event": "Message Received",
5
"properties": {
6
"conversationId": "1238041hdou",
7
"messageId": "msg124",
8
"message_body": "Thank you for reaching out. How can I assist you today?"
9
},
10
"role": "agent"
11
}

The Conversation Ended event should be sent when a customer or agent explicitly indicates that the conversation has ended or deletes the chat.

This event supports the following semantic property:

PropertyTypeDescription
conversationIdstringThe conversation's unique identifier.

Here's an example of a Conversation Ended call:

1
{
2
"userId": "123",
3
"action": "track",
4
"event": "Conversation Ended",
5
"properties": {
6
"conversationId": "1238041hdou"
7
}
8
}

The Action nvoked event should be sent when the copilot or user uses a custom capability or tool, like making a call to an external API.

This event supports the following semantic properties:

PropertyTypeDescription
conversationIdstringThe conversation's unique identifier.
messageIdstringThe message's unique identifier.
typestringThe type of action invoked.
actionStringThe specific action taken with the tool.
rolestringThe message's sender; default is "customer".

Here's an example of an Action Invoked call:

1
{
2
"userId": "123",
3
"action": "track",
4
"event": "Action Invoked",
5
"properties": {
6
"conversationId": "1238041hdou",
7
"messageId": "msg125",
8
"type": "Inventory Request",
9
"action": "check stock level",
10
"role": "customer"
11
}
12
}

This event should be sent when an image, video, or custom audio is generated by the model.

This event supports the following semantic properties:

PropertyTypeDescription
conversationIdstringThe conversation's unique identifier.
messageIdstringThe message's unique identifier.
typestringThe type of media generated (like "image", "video")
sub_typeStringMedia data type (like "gif", "mp4", "wav")
rolestringThe message's sender; default is "agent".

Here's an example of a Media Generated call:

1
{
2
"userId": "123",
3
"action": "track",
4
"event": "Media Generated",
5
"properties": {
6
"conversationId": "1238041hdou",
7
"messageId": "msg126",
8
"role": "agent",
9
"type": "image",
10
"sub_type": "gif"
11
}
12
}

This event should be sent when a new, custom component is shown to the user that isn't text or voice.

This event supports the following semantic properties:

PropertyTypeDescription
conversationIdstringThe conversation's unique identifier.
messageIdstringThe message's unique identifier.
typestringThe type of custom component loaded.

Here's an example of a Component Loaded call:

1
{
2
"userId": "123",
3
"action": "track",
4
"event": "Component Loaded",
5
"properties": {
6
"conversationId": "1238041hdou",
7
"messageId": "msg127",
8
"type": "Stock Price Chart"
9
}
10
}

This event should be sent when a user rates a conversation or message.

This event supports the following semantic properties:

PropertyTypeDescription
conversationIdstringThe conversation's unique identifier.
messageIdstringThe message's unique identifier.
ratingnumberThe rating given by the user.

Here's an example of a Feedback Submitted call:

1
{
2
"userId": "123",
3
"action": "track",
4
"event": "Feedback Submitted",
5
"properties": {
6
"conversationId": "1238041hdou",
7
"messageId": "msg128",
8
"rating": 5
9
}
10
}

This event should be sent when a new user is identified, either anonymously or as a known user.

This event supports the following semantic properties:

PropertyTypeDescription
userIdstringThe user's unique identifier.
anonymousIdstringThe user's anonymous identifier (if applicable).

Here's an example of an Identify call:

1
{
2
"userId": "123" || "anonymousId" : "768923ihuy32",
3
"action": "identify",
4
"properties":
5
}

When sending events to Segment based on user actions, like items purchased or support requested, make sure to include relevant identifiers for accurate tracking and analysis.

These identifiers include conversationId and messageId, among others, depending on the specific tracked action:

IdentifierDescription
conversationIdThe conversation's unique identifier. This identifier is crucial to tracking actions within a messaging or support context.
messageIdThe message's unique identifier. This identifier is especially important for actions like messages read, media generated, or feedback submitted.

For example, to track an event where a user makes a purchase, the standard Track call could look like this:

1
{
2
"userId": "user123",
3
"action": "track",
4
"event": "Item Purchased",
5
"properties": {
6
"conversationId": "conv456",
7
"messageId": "msg789",
8
"itemId": "item101112",
9
"itemName": "Super Widget",
10
"itemPrice": 19.99,
11
"currency": "USD"
12
}
13
}