> ## Documentation Index
> Fetch the complete documentation index at: https://koreai.mintlify.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent AI with Five9 Inbound Voice

This document explains how to integrate the Agent AI widget into the Five9 Agent Desktop. It provides step-by-step instructions for a smooth and efficient setup. This integration supports key Agent AI features, including Automation, [Agent Coaching](/ai-for-service/agentai/agent-experience/agent-realtime-coaching), [Agent Playbook](/ai-for-service/agentai/agent-experience/playbook), [sentiment analysis](/ai-for-service/agentai/agent-experience#sentiment-analysis), [Transcription](/ai-for-service/agentai/agent-experience#transcript-tab), with end-of-call summary, Custom Data, and Secure Custom Data passing, such as agent name and ID to the Agent AI widget.

## Prerequisites

* Five9 administrators with access to the Admin Console and privileges to set up the configurations.
* Five9 administrators who can receive calls on Five9 Agent desktop.
* Five9 VoiceStream set up for your instance. Contact your Five9 representative for help.
* Platform administrators with access to Agent AI instance and know-how of Agent AI bots.
* Kore App credentials, such as Agent AI Widget URL, Bot ID, Client ID, Client Secret, Account ID, and SIP URI.

## Definitions

| Key                       | Definition                                                                                                                                                                                                                                                                                                                         | Reference                                                                                                  |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `Identifiers`             | A unique identifier in the Data Table to fetch bot details at run time. It can be a skill name or a campaign name.                                                                                                                                                                                                                 |                                                                                                            |
| `SecureCustomDataConfig`) | Defines the key–value pairs in `SecureCustomData`, a session-level store for sensitive data. Use the `SecureCustomDataConfig` to pass sensitive information to the Agent AI Bot. Provide a JSON object with keys and their corresponding xpath (paths to locate the value in Five9 Call Variables).<br /> This column is optional. | **Sample:**<br />`{`<br />`"skillName": "Call.skill_name",`<br />`"agentName": "Agent.full_name"`<br />`}` |
| `CustomDataConfig`        | Use this to pass information to the Agent AI bot. The KVPs you need to include in CustomData. JSON object containing the necessary keys and xpath (paths to locate the value in Five9 Call Variables).<br /> Optional column. Use it to send custom data to Agent AI.                                                              | **Sample:**<br />`{`<br />`"skillName": "Call.skill_name",`<br />`"agentName": "Agent.full_name"`<br />`}` |

## Configurations on Platform

* [Bot Information in Agent AI Third-Party Configuration](#agent-ai-bot-mapping-for-skills-or-campaigns)
* [Access Custom Data and Secure Custom Data in Agent AI Bot](#access-custom-data-and-secure-custom-data-in-the-agent-ai-bot)

## Configurations on Five9 Admin Console

* [Five9 account setup for incoming phone call](#five9-account-setup-for-incoming-phone-call)
* [Create connector](#create-connector)
* [Create voice stream](#create-voicestream)
* [Create custom call variables](#create-custom-call-variables)

## Interaction between Five9 and Agent AI

<img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/architecture-diagram.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=da5c7d18c8a8b8235ace5371d722cde4" alt="architecture-diagram" width="1193" height="676" data-path="ai-for-service/agentai/integration/five9-voice/images/architecture-diagram.png" />

## Five9 Agent AI - Voice Flow Steps

1. Customer calls Five9 Virtual Contact Center.
2. Agent accepts the call on Five9 Agent Desktop.
3. Five9 sends call metadata via HTTP POST /callevents to Audiosocket Server.
4. Five9 opens gRPC StreamingVoice bidirectional stream (audio encoding: LINEAR16, 8000Hz).
5. Five9 adapter routes audio to Voice Gateway.
6. Voice Gateway sends audio stream to Kore-managed ASR.
7. ASR returns real-time transcriptions to Voice Gateway.
8. The system forwards the transcriptions to Agent Assist backend.
9. Agent Assist backend shares the transcripts with Agent Desktop Widget (Agent Assist Transcript Tab).
10. Agent Assist backend shares the transcripts with Agent Assist bot, and the bot recognizes the intents and sends responses back to the Agent Assist Widget. This process continues until the end of the call.

### Agent AI Bot Mapping for Skills or Campaigns

[Third-Party Configuration](/ai-for-service/agentai/configuration/third-party-configuration) maps Agent AI bots to specific skills or campaigns. Use it to set the bot’s language, custom data, and secure custom data.

**Example:** To associate Agent AI Bot1 with Skill1, create a record for Agent AI Bot1 and set the Queue Identifier to Skill1.

Map each skill or campaign to only one Agent AI bot. This setup ensures the correct Agent AI widget is rendered for conversations routed based on the defined skill or campaign.

Refer to [third-party configuration](/ai-for-service/agentai/configuration/third-party-configuration) doc for instructions on creating records for an Agent AI bot.

**Example**:

You have a skill named Chat\_Skill, that handles incoming chat requests, and you want the Agent AI widget to render for conversations routed to this skill. You must create the following details of the third-party configuration record in your Agent AI account:

<img src="https://mintcdn.com/koreai/GWGsqn3XZU0BlNsX/ai-for-service/agentai/integration/five9-voice/images/create-record.png?fit=max&auto=format&n=GWGsqn3XZU0BlNsX&q=85&s=9e28ccbfde3dc6ec1be5e99089d44d1f" alt="create-record" width="644" height="622" data-path="ai-for-service/agentai/integration/five9-voice/images/create-record.png" />

<img src="https://mintcdn.com/koreai/GWGsqn3XZU0BlNsX/ai-for-service/agentai/integration/five9-voice/images/create-record-add-values.png?fit=max&auto=format&n=GWGsqn3XZU0BlNsX&q=85&s=0cfdf8986d70ec93bc0f7ebf6b133ab7" alt="create-record-add-values" width="638" height="449" data-path="ai-for-service/agentai/integration/five9-voice/images/create-record-add-values.png" />

The values should be base64 encoded.

<img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/third-party-configuration-page.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=23198222eff4d1ea4984748a57f7bb68" alt="third-party-configuration-page" width="1602" height="474" data-path="ai-for-service/agentai/integration/five9-voice/images/third-party-configuration-page.png" />

Ensure the Third-Party Configuration setting is enabled in **Agent AI** > **Configurations** > **Widget Settings** > **Agent AI Settings** > **Agent AI General Settings**.

<img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/third-party-config-setting-agentai.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=90ead145841c0e8d452d282294b85a8f" alt="third-party-config-setting-agentai" width="1584" height="867" data-path="ai-for-service/agentai/integration/five9-voice/images/third-party-config-setting-agentai.png" />

## Create Connector

1. Sign in to **[Five9 Administrator Console](https://admin.us.five9.net/)**.

2. Search for **connectors** in the search bar, and select **Connectors**.

3. Click the **Create** button.

   <img src="https://mintcdn.com/koreai/GWGsqn3XZU0BlNsX/ai-for-service/agentai/integration/five9-voice/images/create-new-connector.png?fit=max&auto=format&n=GWGsqn3XZU0BlNsX&q=85&s=b5d3ecfa2d66b24803402b9c073eebb4" alt="create-new-connector" width="1424" height="796" data-path="ai-for-service/agentai/integration/five9-voice/images/create-new-connector.png" />

4. Provide a name in the **Connector Name** field.

5. Enter the URL as `{Agent AI URL}/integrations/five9/`.

6. Enter the method as **GET**.

   <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/connector-configuration.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=26208d52792861d4de5e82d7394530cb" alt="connector-configuration" width="1848" height="890" data-path="ai-for-service/agentai/integration/five9-voice/images/connector-configuration.png" />

7. Click **Next**.

8. In the **Parameters** section, click the **Add** dropdown list, and select **Field**.

   <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/connector-add-select-field.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=78807e79b5e3d13f1f583ddadecc4d09" alt="connector-add-select-field" width="1850" height="933" data-path="ai-for-service/agentai/integration/five9-voice/images/connector-add-select-field.png" />

9. Select **call\_id**, **session\_id**, **domain\_id**, **id**, **skill\_name** / **campaign\_name** (choose either skill\_name or campaign\_name, depending on which you use to map the bot in Agent AI), and click **Ok**.

   <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/add-field.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=65b5d466e7baa19b6fa2fe5ec651464c" alt="add-field" width="1849" height="892" data-path="ai-for-service/agentai/integration/five9-voice/images/add-field.png" />

   <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/connector-configuration-complete.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=6b7cf57e7df134c95cbf99889d693c36" alt="connector-configuration-complete" width="1843" height="894" data-path="ai-for-service/agentai/integration/five9-voice/images/connector-configuration-complete.png" />

10. Click the **Edit** icon against the parameters and change as per the following:
    * call\_id -> callid
    * domain\_id -> domainid
    * id -> agentid
    * session\_id -> conversationid
    * skill\_name/campaign\_name -> identifiers

11. In the **Parameters** section, click the **Add** dropdown, and select **Constant**.

    <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/connector-parameters-constant.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=0d80a817e02a755924b6cec40cffc2a9" alt="connector-parameters-constant" width="1848" height="882" data-path="ai-for-service/agentai/integration/five9-voice/images/connector-parameters-constant.png" />

12. Enter **Name** as **accountid** and the **Value** should be the **accountid** of your Agent AI account. Find this ID by navigating to **Agent AI** > **Flows & Channels** > **Channels** > **Digital** > **Web/Mobile Client** > **JWT App Details**. Refer to this **[doc](/ai-for-service/channels/add-web-mobile-client#adding-the-web-mobile-client-channel)**.

    <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/add-constant.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=b178d31d4c07366ad265bb4ec6b8c683" alt="add-constant" width="1848" height="887" data-path="ai-for-service/agentai/integration/five9-voice/images/add-constant.png" />

13. Click **Ok** > **Next**.

    <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/add-constant-next.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=4eea71f6d31ef943a34653259ba7cf10" alt="add-constant-next" width="1848" height="931" data-path="ai-for-service/agentai/integration/five9-voice/images/add-constant-next.png" />

14. By default, **Call** is selected for **Trigger Event** and **On Call Accepted** is selected for **On Call Event**.

15. Click **Done**.

## Five9 Account Setup for Incoming Phone Call

1. Buy a phone number by following the [Numbers Inventory](https://documentation.five9.com/bundle/admin-console/page/admin-console/numbers-inventory/_ch-numbers-intro.htm) doc.

2. Create IVR script by following the [Creating an IVR Script](https://documentation.five9.com/bundle/ivr-admin/page/ivr-admin/examples/creating-an-ivr-script.htm) doc.

   **Sample IVR Script**:

   <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/sample-ivr-script.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=8d57291c1fb9faaa227355912f4f9774" alt="sample-ivr-script" width="896" height="473" data-path="ai-for-service/agentai/integration/five9-voice/images/sample-ivr-script.png" />

   <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/assignment.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=10f18880d24d257c5bf662c6fcc42cef" alt="assignment" width="377" height="415" data-path="ai-for-service/agentai/integration/five9-voice/images/assignment.png" />

   <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/variable.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=65165ab77aa1211c8786bb8696c35f46" alt="variable" width="377" height="412" data-path="ai-for-service/agentai/integration/five9-voice/images/variable.png" />

   <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/set-variable-module.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=e722c5a4bcf362107a90cf459e1a4df7" alt="set-variable-module" width="548" height="347" data-path="ai-for-service/agentai/integration/five9-voice/images/set-variable-module.png" />

3. Create a skill and add agents to the skill by following the [Skills](https://documentation.five9.com/bundle/admin-console/page/admin-console/skills/_ch-user-skills.htm) doc.

4. Create an inbound campaign by following the [Create Inbound Campaigns](https://documentation.five9.com/bundle/admin-console/page/admin-console/campaigns/creating-campaigns.htm) doc.

   <Note>
     After you create the inbound campaign, run it.
   </Note>

## Create VoiceStream

1. Sign in to [Five9 Admin Console](https://admin.us.five9.net/).

2. Search for **VoiceStream**, and click **VoiceStream**.

   <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/voice-stream.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=4de78d9828045b3206cdee5f1759c3fb" alt="voice-stream" width="1848" height="932" data-path="ai-for-service/agentai/integration/five9-voice/images/voice-stream.png" />

3. Click **Create**.

4. Enter a unique VoiceStream subscription name in the **Name** field.

5. Select **Other (Self Service)** in **Streaming Destination** field.

6. Select **gRPC** as **Streaming Protocol**.

7. Configure the following Destinations and provide **Trust Token** value as **KoreGrpc**.
   * **Primary Streaming Destination**: savg-us-grpc-audiosocket.kore.ai:443
   * **CTI Call Event Destination**: [https://savg-webserver.kore.ai/audiosocket/five9/callevents](https://savg-webserver.kore.ai/audiosocket/five9/callevents)
   * **VoiceStream Event Destination**: [https://savg-webserver.kore.ai/audiosocket/five9/callevents](https://savg-webserver.kore.ai/audiosocket/five9/callevents)

8. Click **Done**.

9. Configure the **Trust Token** (provided by Kore) while creating the subscription. It's validated at Kore by call event get API.

## Create Custom Call Variables

1. Sign in to [Five9 Admin Console](https://admin.us.five9.net/).

2. Search for variables, and open **Variables**.

3. Click **Create**.

4. Give the group **Name** as **Kore**, and click **Create**.

5. Click **Kore**.

   <img src="https://mintcdn.com/koreai/eijlvsUuVVetpoxP/ai-for-service/agentai/integration/five9-voice/images/variable-groups.png?fit=max&auto=format&n=eijlvsUuVVetpoxP&q=85&s=d3914eb8f4a6a76544bcd9d042bd7e65" alt="variable-groups" width="1847" height="931" data-path="ai-for-service/agentai/integration/five9-voice/images/variable-groups.png" />

6. Click **Create Variable**.

7. Give the variable **Name** as **botid**. For the question **Will this variable contain sensitive data?**, select option **No**, select the **Datatype** as **String**, and then click **Next**.

8. For the question **Will the data in this variable be needed in reports?**, select **No**.

9. Click **Next**.

10. For the question **Should the values of this variable come from a predefined list?**, Select **No** and provide your **Bot Client ID** in the **Set Default Value** field.

11. Click **Done**.

12. Click **Create Variable**.

13. Repeat the same steps and create a variable with the name **sipuri**, and a default value containing the sipuri configured for your Agent AI Bot.

14. Click **Done**.

## Access Custom Data and Secure Custom Data in the Agent AI Bot

You can access the Custom Data and Secure Custom Data in Welcome Events in Agent AI configuration page and in Dialog Tasks in the Agent AI automation page.

You can access the Custom Data as `{{context.session.UserContext.customData.<key>}}`.

Follow [this doc](/ai-for-service/agentai/agent-experience/access-custom-data-in-agent-ai) for the detailed steps on how to access Custom Data.

You can access the Secure Custom Data as `{{context.session.UserContext.secureCustomData.<key>}}`

Follow the same steps of [this doc](/ai-for-service/agentai/agent-experience/access-custom-data-in-agent-ai) for detailed information on how to access Secure Custom Data, with the exception of the path being `{{context.session.UserContext.secureCustomData.<key>}}`
