> ## Documentation Index
> Fetch the complete documentation index at: https://koreai.mintlify.site/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. The integration supports 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.
* 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 set up 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 /call events 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 the Agent Assist backend.
9. The Agent Assist backend shares the transcripts with Agent Desktop widget (Agent Assist Transcript tab).
10. The Agent Assist backend shares the transcripts with the 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 renders for conversations routed based on the defined skill or campaign.

Refer to [third-party configuration](/ai-for-service/agentai/configuration/third-party-configuration) 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 must 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 you have turned on the Third-Party Configuration setting 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 SIP Trunk

Create a SIP trunk in Kore Platform with **Agent AI** as the production selection. For steps, see [Steps to Configure SIP Trunk](/ai-for-service/channels/voice-gateway/configure-voice-gateway#steps-to-configure-sip-trunk). Use the generated SIP identifier to configure the **Five9 IVR** script in the next step.\\

<img src="https://mintcdn.com/koreai/WpX_vttOthVIy8Vp/ai-for-service/agentai/integration/five9-voice/images/configure-sip-trunk.png?fit=max&auto=format&n=WpX_vttOthVIy8Vp&q=85&s=15a0aeb04f2a55cacc8e51cc452b89d5" alt="configure-sip-trunk" width="701" height="858" data-path="ai-for-service/agentai/integration/five9-voice/images/configure-sip-trunk.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. Select **Create**.

   <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. Enter 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. Select **Next**.

8. Select **Field** from the **Add** dropdown list in the **Parameters** section.

   <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 select **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. Select the **Edit** symbol next to each parameter and update the values as follows:
    * call\_id -> callid
    * domain\_id -> domainid
    * id -> agentid
    * session\_id -> conversationid
    * skill\_name/campaign\_name -> identifiers

11. Select **Constant** from the **Add** dropdown list in the **Parameters** section.

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

12. Enter 'accountid' in the **Name** field and the **accountid** of your Agent AI account in the **Value** field. To find this ID, go to **Agent AI** > **Flows & Channels** > **Channels** > **Digital** > **Web/Mobile Client** > **JWT App Details**. For more details, see this [doc](/ai-for-service/channels/add-web-mobile-client#add-webmobile-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. Select **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. The default selection for **Trigger Event** is **Call** and for **On Call Event** is **On Call Accepted**.

15. Select **Done**.

## Create Custom Call Variables

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

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

3. Select **Create**.

4. Enter **Kore** as the group **Name**, and select **Create**.

5. Select **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. Select **Create Variable**.

7. Enter **botid** as the variable **Name**.

8. For the question **Will this variable contain sensitive data?**, select the **No** option, select the **Datatype** as **String**, and then select **Next**.

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

10. Select **Next**.

11. 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.

12. Select **Done**.

13. Select **Create Variable**.

14. Repeat the same steps to create a variable named `sipuri` with a default value of the SIP URI configured for your Agent AI bot.

15. Select **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 an 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 select **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. Select **Create**.

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

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

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

7. Configure the following destinations and provide the **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. Select **Done**.

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

## 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 the 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, except for the path being `{{context.session.UserContext.secureCustomData.<key>}}`
