Configure custom events for AI agents

list-menuFeedback?
This article outlines the steps required for configuring custom event data for autonomous and scripted AI agents.

Custom event enables developers to perform the following tasks:

  • Pass data from the client to update an autonomous agent’s design time parameters. For example, passing customer name for a personalized welcome message.
  • Update autonomous AI agent design time variables. For example, optimize goals and instructions for specific customers, update action description and slots with information that’s available with the client so that the users are not re-prompted for it.

Currently, custom event for autonomous AI agents is supported through the voice channel only.

Configure custom data in flow designer

  1. In the Webex Contact Center Flow Designer, configure the Virtual Agent V2 activity in the flow.
  2. In the State Event settings, specify the following details in the Event Name - Event Data columns:
    1. Leave the event name field blank.
    2. Enter the custom data that you wish to pass from the Flow Designer to the autonomous AI agent.

Virtual Agent V2 activity in Flow designer

Access custom event data in AI Agent Studio

You can access event data (configured in the Flow Designer) using the syntax {{variable name}} in various sections of the autonomous agent. The variables passed in the custom data can be accessed in agent’s goal, welcome message, instructions, action description, and slot description.

Custom data in AI agent studio

In this example, the developer uses {{customer_name}} in the welcome message and {{calling_number}} in the agent instructions.

Custom events enable administrators to perform the following tasks:

  • Pass data from the client to create dynamic responses. For example, passing customer name for a personalized greeting.

  • Define a custom exit out from the AI agent to return control to the flow designer. For example, to execute fulfillment within the flow.

  • Set the AI agent to begin from a custom starting point rather than the welcome prompt by using a custom event.

  • Update AI agent state variables. For example, prepopulating the context or slots using custom data passed from the flow designer.

Currently, custom event for scripted AI agents is supported through the voice channel only.

Configure incoming custom event in AI Agent Studio

  1. On the AI agent configuration page, create a new response in the Responses tab.
  2. Under Default response, click + next to the Default (Web) channel to add the Voice channel
  3. In the Incoming event name field, define the event name that the agent receives.

Invoke custom event from Flow Designer

  1. In the Webex Contact Center Flow Designer, configure the Virtual Agent V2 activity in the flow.
  2. In the State Event settings, specify the following details in the Event Name - Event Data columns:
    1. Enter the custom event name that you've configured in the Response tab of the AI agent configuration page in AI Agent Studio.

    2. Enter the custom data that you wish to pass from the Flow Designer to the scripted AI agent.

Access custom event data in AI Agent Studio

You can access the event data (configured in the Flow Designer) in the Default response section where you configured your incoming event. In the following figure, you can see that the custom event name "custom_welcome" and event data "store name" are passed from the Flow Designer to AI Agent Studio.

Configure custom exit event & payload in AI Agent Studio

  1. In the AI Agent Studio, navigate to the scripted AI agent configuration page and go to Response where you want the control to be passed back to the flow designer.

  2. Add Custom Event to the Default response section.

  3. Enter the event name and event payload data in the JSON that you want to be returned to the flow.

In this example, the slots collected are returned to the flow with the custom exit event “order_details”.

Access custom event data in Flow Designer

You can access the custom event and payload from the Output Variables section of Virtual Agent V2 activity.

The Event name is returned under the StateEventName variable and the Event payload is returned as Metadata as shown in the following figure:

Update system values in AI Agent Studio

You can update system values such as context, intent, and slot using a special event state_update and Event payload with the values, as shown in the following example:

{ 
 "intent": "order_status", 
 "slots": { 
 "first_name": "John" 
 } 
 } 

In the above example, the intent of the scripted agent is set to order_status, the slot ‘first_name’ within that intent is set to ‘John’ and a context called ‘track’ is added to the session.

This event is useful for use-cases where the scripted agent conversation must be controlled by flow logic. Some use cases where this is especially useful include:

  • Re-prompt the user for information if fulfillment in the flow fails

    Consider a scenario where the agent is booking an appointment for a user. After gathering the date and time, this information is sent to the flow through a custom event, which then attempts to book the appointment using an HTTPS request activity. If the appointment is rejected due to a scheduling conflict, the AI agent needs to request an alternative time slot. To handle this, the developer can use the following event payload:

    {
    "intent": "book appointment",
    "slots": {
    "time": ""
    }
    }

    In this case, the value collected for time is cleared, and the AI agent prompts the user to provide a new one. Developers can set up conditional responses to let users know the previous slot was unavailable and request a new time.

  • Navigate to a different intent

    Consider a scenario where a user requests to check their balance but as a prerequisite, the user must first verify their identity. As part of the balance inquiry process, developers can send an event payload to inform the flow whether the user has already been verified. If verified, the system can proceed to fetch the balance; if not, the flow can prompt the AI agent to initiate the user verification process using the following event payload:

    {
    "intent": "verify user",
    }

    In this same example, let’s say that verification requires the user’s date of birth and pin code. Of the flow already has information about the user’s date of birth via CJDS, that can be passed as a slot and only pin code can be collected. The event payload for that will look like:

    {
    "intent": "verify user",
    "slots": {
    "date of birth": "06/26/1993"
    }
    }
  • Introduce or reset context in a conversation

    When the conversation context needs to be updated, developers can include it in the event payload for the state_update event. For example, after the AI Agent collects the slots for the 'verify user' intent, it sets the conversation context to 'verify'. If verification fails in the flow, the context should be reset to prevent the user from accessing intents that require the 'verify' context. The event payload for this scenario would look like:

    {
    "intent": "verify user",
    "slots": {
    "date of birth": "",
    "pincode": ""
    },
    "context": {
    "verify": 0
    }
    }

Was this article helpful?
Was this article helpful?