# Live Agent Setup

## Prerequisites <a href="#pdf-page-24videbz9tke9pyvz4wz-pdf-page-msnh2a5kvyyw7mdrka5q-id-2.-prerequisites" id="pdf-page-24videbz9tke9pyvz4wz-pdf-page-msnh2a5kvyyw7mdrka5q-id-2.-prerequisites"></a>

Before you begin, create an Aisera Bot and integrate it with your Genesys system using the following instructions:\
\
[**Genesys Integration**](https://docs.aisera.com/aisera-platform/channels/interactive-voice-response-ivr/genesys-integration)

## **To add the Live Agent functionality to your application (bot):**

1. Go to the **Details** page of your Aisera application (bot).
2. &#x20;Scroll down to `Live Agent` section.

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FGS0wddTk803DnjoK6TOp%2Fadd_live_agent2.png?alt=media&#x26;token=17621fc7-4274-4cc1-bd00-7b4b917f8991" alt="" width="426"><figcaption></figcaption></figure>

1. Click **+ Add Live Agent** if you don’t already have a live agent connected to your application, or click `edit live agent` if you already have a live agent integration for your Aisera application (bot).
2. Select your `Genesys` integration.

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2F0USy60BkNdmJyBXKeBob%2Fchoose_integration.png?alt=media&#x26;token=944f5d48-f1d9-4a83-bfde-498006da62a9" alt="" width="563"><figcaption></figcaption></figure>

3. Configure the details about the live agent connection and choose **OK**.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FEi7U1qZ7xz0XUnnX29wG%2Fimage.png?alt=media&#x26;token=deae1b88-2616-4e7c-a0db-feb206116bd5" alt="" width="375"><figcaption></figcaption></figure></div>

See descriptions for these fields in the table below.

<table><thead><tr><th width="217">Field</th><th>Description</th></tr></thead><tbody><tr><td>WebSocket Address</td><td>The <code>Web Socket Address</code> is based on the region of the Genesys Web Messaging application.</td></tr><tr><td>Deployment Id</td><td>The <code>Deployment Id</code> of the Web Messaging application.</td></tr><tr><td>Agent End Chat Message</td><td>The <code>Agent End Chat Message</code> <br>Genesys Web Messaging doesn’t provide the event when the agent ends the chat. However, when there is no agent available, Genesys will send text message to show the chat is ended. This message will be used as the indicator that Genesys/agent ends the chat. <br>For example, <code>End of Chat - goodbye.</code></td></tr><tr><td>Attachments</td><td>You can leave this field as <code>Not Supported.</code><br>(If you use Not Supported, you won't see the fields in the sections below.)</td></tr><tr><td>Agent Status Monitor Interval (seconds)</td><td>The time interval, in seconds, to get the agent’s status in the conversation, including <strong>Agent Join</strong> and <strong>Agent Left</strong>. For example, 5 seconds.</td></tr><tr><td>Attachments</td><td><p><code>Optional</code></p><p>If the attachment uploading is NOT needed, please select <code>Not Supported</code></p><p>If the attachment uploading is needed, please</p><p>1. Select <code>Supported</code> and</p><p>2. Set the File Extensions to <code>png, gif, jpg, jpeg</code></p><p>3. Set Max File size to <code>10 MB</code></p><p>Note: <code>Genesys</code> has limitation to file types and file size.</p><p><a href="https://developer.dev-genesys.cloud/commdigital/digital/webmessaging/websocketapi#inbound-message-with-an-image-attachment">Genesys Cloud Developer Center</a></p></td></tr></tbody></table>

&#x20;2\.  Verify that the Live Agent is enabled:

* choose **Intents** in the left navigation menu of the Aisera Admin UI
* select the **Action Flows** tab
* make sure the **Contact Live Agent Intent** is **Active**

You also have the option to enable other intents/flows to add advanced features.

#### 3. (Optional) Customize `deploymentId` on-the-fly in the `Preprocess Live Agent` flow <a href="#id-3.-optional-customize-deploymentid-on-the-fly-in-the-preprocess-live-agent-flow" id="id-3.-optional-customize-deploymentid-on-the-fly-in-the-preprocess-live-agent-flow"></a>

Sometimes, a customer wants to route the user to a different Genesys live agent based on some conditions, including language, help topic, or location.

a. Add a new output variable `deploymentId`

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2Fv1yF99o3ohwItkOFGaIK%2Fimage.png?alt=media&#x26;token=876da629-297f-4f59-a87c-58e25df2b9d3" alt="" width="563"><figcaption></figcaption></figure>

b. In the flow, set the value to `deploymentId`<br>

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2Fy2X8BiiwImtWfQU4BQ0g%2Fimage.png?alt=media&#x26;token=29fc66ce-0020-4ba3-8abb-24cb782decd3" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2F9WeYW4LjGeIu9b2JCw6i%2Fimage.png?alt=media&#x26;token=c0af38ea-7770-4ad2-ae95-cdc9e82ddd14" alt="" width="563"><figcaption></figcaption></figure>

#### 4. (Optional) Customize the customAttributes in the initial message to Agent/Genesys <a href="#id-4.-optional-customize-the-customattributes-in-the-initial-message-to-agent-genesys" id="id-4.-optional-customize-the-customattributes-in-the-initial-message-to-agent-genesys"></a>

When handling off to Genesys Live Agent, customer can customize the `customAttributes` in the payload of the initial message, so Genesys can know more about the information about this Live Agent connection.

This can be done by customizing the `Preprocess Live Agent` flow.

An example of the payload with `customAttributes`

```
{
  "message": {
    "type": "Text",
    "text": "01/03/2023 11:22:49 PM GMT Conversation History: \nUser: contact live agent\nAisera: Please explain your problem in few words\n\nUser: contact live agent\nAisera: Do you want to contact live agent?\n        Yes\n        No \n\n",
    "channel": {
      "metadata": {
        "customAttributes": {
          "web_command": "Aisera Escalation",
          "country": "US",
          "employee_id": "00001",
          "last_name": "Test",
          "classification": "contact live agent",
          "VIP": false,
          "first_name": "Fred",
          "client_name": "UUS",
          "email": "fred.test@aisera.com",
          "preferred_language": "en"
        }
      }
    }
  },
  "action": "onMessage",
  "token": "6593119c-80da-4ed5-bcbf-xxxxxxxx"
}
```

**Set up in `Preprocess Live Agent` flow:**

a)  Create an output variable `channel` to the flow:

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2Fa0y78Gdxz7SrYvbdgUdf%2Fimage.png?alt=media&#x26;token=489a1275-66c2-470f-8dbe-4aaa208e3e00" alt=""><figcaption></figcaption></figure>

b) Build the channel payload,(containing `customAttributes`) and set to `channel`

Build the payload of `channel`, this channel contains `metadata` and `metadata` contains `customAttributes`.

Convert the `channel` to string and output it.

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2Ff0q5yXRVrncJIJcbCZFm%2Fimage.png?alt=media&#x26;token=b3a9cd41-f4b9-4bbc-b78e-61bd39b4fea4" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FZ7biSnRlqX20kL6JMnXL%2Fimage.png?alt=media&#x26;token=bb56f89c-7240-4dfb-8819-1221cf678104" alt="" width="563"><figcaption></figcaption></figure>

The following code block is an example of building the `channel.`

(Customize the values of fields in real prod use cases)

```
var customAttributes = {};
customAttributes.first_name = 'Fred';
customAttributes.last_name = 'Test';
customAttributes.email = 'fred.test@unisys.com';
customAttributes.preferred_language = 'en';
customAttributes.employee_id = '0001';
customAttributes.classification = ticketTitle;
customAttributes.VIP = false;
customAttributes.client_name = 'UUS';
customAttributes.country = 'US';
customAttributes.web_command = 'Aisera Escalation';
var channel = {};
var metadata = {};
metadata['customAttributes'] = customAttributes;
channel['metadata'] = metadata;
return JSON.stringify(channel);
```
