# Contact Centers and Trigger-based Attended Automation

> This tutorial demonstrates how to work with multiple instances of the same form, at the same time. The scenario presented involves a contact center agent that operates with multiple customer phone calls coming in at the same time. In this scenario, forms and triggers help in displaying information about the customer the contact center agent is currently talking to, while being able to perform different actions for a customer, such as: change their account password, update their licensing plan, or delay their payment.

This tutorial demonstrates how to work with multiple instances of the same form, at the same time. The scenario presented involves a contact center agent that operates with multiple customer phone calls coming in at the same time. In this scenario, forms and triggers help in displaying information about the customer the contact center agent is currently talking to, while being able to perform different actions for a customer, such as: change their account password, update their licensing plan, or delay their payment.

This automation process streamlines the customer service experience by monitoring incoming calls and providing contact center agents with all the necessary information about the customer. The process retrieves customer data from a Data Service entity and displays it in a form, which remains open after the call ends so that agents can revisit it and perform additional actions. The process also prioritizes customers who have been put on hold for more than 25 seconds, displaying a form that prompts agents to either switch to that customer or ignore their call. By enabling agents to handle multiple calls simultaneously, this process optimizes efficiency and enhances the overall quality of customer service.

## Prerequisites
* Install **Form.Activities 23.4.3**
* Install **System.Activities 23.4.2**
* Install **UIAutomation.Activities 23.4.5**

## Sample app

If you want to try out this tutorial with the same contact center agent application, you can download the sample app [here](https://documentationexamplerepo.blob.core.windows.net/examples/Forms/UiPath%20CC%20Agent-1.0.4%20Setup%20%281%29.exe).

## Sample workflows

To follow the steps and test out the idea yourself, download the sample project [here](https://documentationexamplerepo.blob.core.windows.net/examples/TriggerBasedAttendedAutomation/Contact_Center_Tutorial.zip).

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177884-657fa77a.webp)

The sample project contains the following files:

| Workflow | Tutorial |
| --- | --- |
| **Main.xaml** (entry point) | [Step 1: Create the Main workflow](https://docs.uipath.com/studio/standalone/latest/user-guide/contact-centers-and-trigger-based-attended-automation#step-1%3A-create-the-main-workflow) |
| **Customer Data.uiform** | [Step 2: Create customer data form](https://docs.uipath.com/studio/standalone/latest/user-guide/contact-centers-and-trigger-based-attended-automation#step-2%3A-create-customer-data-form) |
| **on incoming call.xaml** | [Step 3: Create workflow for incoming call](https://docs.uipath.com/studio/standalone/latest/user-guide/contact-centers-and-trigger-based-attended-automation#step-3%3A-create-workflow-for-incoming-call) |
| **on current call.xaml** | [Step 4: Create workflow for current call](https://docs.uipath.com/studio/standalone/latest/user-guide/contact-centers-and-trigger-based-attended-automation#step-4%3A-create-workflow-for-current-call) |
| **on ignore click.xaml** | [Step 5: Create workflow to ignore customer call](https://docs.uipath.com/studio/standalone/latest/user-guide/contact-centers-and-trigger-based-attended-automation#step-5%3A-create-workflow-to-ignore-customer-call) |
| **on resume click.xaml** | [Step 6: Create workflow to resume customer call](https://docs.uipath.com/studio/standalone/latest/user-guide/contact-centers-and-trigger-based-attended-automation#step-6%3A-create-workflow-to-resume-customer-call) |
| **Too long to hold.uiform** | [Step 7: Create form when customer is on hold for too long](https://docs.uipath.com/studio/standalone/latest/user-guide/contact-centers-and-trigger-based-attended-automation#step-7%3A-create-form-when-customer-is-on-hold-for-too-long) |
| **check on hold times.xaml** | [Step 8: Create workflow to check Hold time](https://docs.uipath.com/studio/standalone/latest/user-guide/contact-centers-and-trigger-based-attended-automation#step-8%3A-create-workflow-to-check-hold-time) |
| **on ignore clicked.xaml** | [Step 9: Create workflow for ignoring call on hold](https://docs.uipath.com/studio/standalone/latest/user-guide/contact-centers-and-trigger-based-attended-automation#step-9%3A-create-workflow-for-ignoring-call-on-hold) |
| **on switch cliked.xaml** | [Step 10: Create workflow for switching to call on hold](https://docs.uipath.com/studio/standalone/latest/user-guide/contact-centers-and-trigger-based-attended-automation#step-10%3A-create-workflow-for-switching-to-call-on-hold) |

## Step 1: Create the Main workflow

This workflow represents the project’s entry point, and the workflow that starts all triggers.

1. Add a **Build Data Table** activity, and build a table with the following columns:
   1. **Caller** (`String`) – to store the customers phone numbers.
   2. **Since** (`DateTime`) – to store the time when you answer a customer call.
   3. **Ignore** (`Boolean`) - to record if the customer call was ignored.
2. Store the Data Table inside a global variable named `callers`
3. Add a **Run Local Triggers** activity, to start all the triggers inside the project at the same time.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177827-79d96fb9.webp)

## Step 2: Create customer data form

Create a form to fetch and display information about the customer that’s calling or the customer the contact center agent is talking to (**Customer Data**)

1. Create a new **Form** file from the Studio design ribbon. Name it **Customer Data**.
2. Add three **Label/Header** components that hold the name, Id, and payment status of the customer that is calling. Edit them as follows:
   1. First **Label/Header** - Type **Loading…** in the **Content**field and set the property name as `customerName`, in the **Property Name** field.
   2. Second **Label/Header** - Type **Caller ID:** in the **Content** field. Set the property name as `callerId`, in the **Property Name** field.
   3. Third **Label/Header** – Type **Payment Status: Loading…** in the **Content** field and set the property name as `paymentStatus`.
3. Add six **Button** components, that trigger certain action events. For this example, create buttons for the following action events (using the **Action** dropdown):
   1. **Change password**
   2. **Reset 5G**
   3. **Service request**
   4. **Update plan**
   5. **Address Change**
   6. **Delay payment**

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177855-0020c3aa.webp)

## Step 3: Create workflow for incoming call

This workflow represents the scenario when there’s an incoming customer call (**on incoming call.xaml**).

1. Add an **Application Event Trigger** for the incoming call app event.
   1. **Event type** – Appeared
   2. **Scheduling mode** – Sequential
2. Add a **Use Application/Browser** activity to focus on the Contact Center agent app and fetch information about the customer.
   1. Add a **Get Text** activity and indicate the phone number. Save it to a global variable named `incomingCaller`.
   2. Add a **Show Form** activity to display the **Customer Data** form using the information that you previously fetched. Set the **Instance Name** as `incomingCaller`. In the **Arguments** collection, pass in the customer’s phone number:

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177861-01907d6d.webp)

   3. For this example, query additional client data from a Data Service entity. Save the queried data inside a local variable named `clientData`.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177865-9d370e9b.webp)

4. Add a **Set Form Values** activity, to add the previously fetched client data to the same **Customer Data** form instance. For this example, pass arguments for name, invoice number, and payment status.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177851-bdb0b251.webp)

5. To personalize the form instance, change its title based on the queried client data, at runtime, by adding a **Change Form Properties** activity.
   1. **Select Form** – Customer Data
   2. **Title** – `clientData.FullName`

## Step 4: Create workflow for current call

This workflow represents the scenario when you answer a customer call and you’re currently talking to them (**on current call.xaml**).

1. Add an **Application Event Trigger** activity for the current call event.
   1. **Event type** – Appeared
   2. **Scheduling mode** – Concurrent
2. Add a **Use Application/Browser** activity to focus on the Contact Center agent app and fetch information about the customer.
   1. Add a **Get Text** activity and indicate the phone number. Save it to a global variable named `caller`.
   2. Add the customer that is currently on call to the `callers` global variable, where the Data table from the [Main](https://docs.uipath.com/studio/standalone/latest/user-guide/contact-centers-and-trigger-based-attended-automation#step-1%3A-create-the-main-workflow) workflow is stored.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177871-4edb67cb.webp)

3. Add a **Bring Form to Foreground** activity to bring the **Customer Data** form to the front, so you can focus on the customer that you’re talking to. Add a global variable named `caller` as the **Instance Name** of the form.

## Step 5: Create workflow to ignore customer call

This workflow represents the scenario when the contact center agent clicks Ignore on an incoming call from a customer (**on ignore call**).

1. Add a **Click Trigger** activity for the **Ignore** button.
   1. **Mouse button** – Left
   2. **Trigger mode** – Down
   3. **Scheduling mode** – Concurrent
2. Add a **Close Form** activity, to close the customer form assigned to the customer, whose call you ignored.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177889-d7145ba9.webp)

## Step 6: Create workflow to resume customer call

This workflow represents the scenario where the contact center agent resumes the call with a customer that was put on hold (**on resume click**).

1. Add a **Click Trigger** activity, for the **Resume** button.
   1. **Mouse button** – Left
   2. **Trigger mode** – Down
   3. **Scheduling mode** – Concurrent
2. Add a **Use Application/Browser** activity, activity to focus on the Contact Center agent app and fetch information about the customer that you resumed the call for.
   1. Add a **Get Text** activity, to fetch the phone number.
   2. Add a **Bring Form to Foreground** activity to bring back to front the assigned **Customer Data** form. Set as the **Instance Name** the `caller` global variable.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177894-e12f4ba1.webp)

## Step 7: Create form when customer is on hold for too long

This workflow represents the scenario where the contact center agent keeps a customer on hold for too long (**Too long on hold.uiform**).

1. Create a **new Form** file from the Studio design ribbon. Name it **Too long to hold**. The **Form Builder** opens in the **Designer** panel.
2. Add a **Label/Header** component to display a message for when a customer stays on hold for too long. Set the **Property Name** to `message`.
3. Add two **Button** components to allow the contact center agent to switch to the customer that was held too much on hold, or ignore the customer call.
   1. First **Button** – set the **Label** as **Switch**, and the **Action** to **event**.
   2. Second **Button** – set the **Label** as **Ignore**, and the **Action** to **event**.
4. Add a **Hidden** component, and set the **Property Name** to `caller`. That’s where we’ll show the phone number of the customer that stayed on hold for too long.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177899-475330bf.webp)

## Step 8: Create workflow to check Hold time

This workflow tracks the time a customer stays on hold.

1. Add a **Repeat Trigger** activity to constantly check the time customers are on hold. For this example, set the **Interval** to 5 seconds.
2. Search for the time a customer was on hold in the `caller` global variable, that you usedto store data about the customer. For this example, if a customer was on hold for more than 25 seconds, then the **Too long on hold** form appears.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177847-ec9f1e12.webp)

## Step 9: Create workflow for ignoring call on hold

This workflow represents the scenario where the contact center agent clicks **Ignore** in the **Too long to hold** form.

1. Add a **Form Event Trigger** activity, to trigger other activities when the **Ignore** button is clicked.
   1. **Select Form** – Too long to hold.
   2. **Event** – Ignore clicked.
2. Add a **Get Form Values** activity, to fetch the phone number of the customer that stayed too long on hold.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177835-5a62c035.webp)

3. Add the phone number of the customer that you fetched at step 2, in the `callers` data table.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177839-a14964a6.webp)

4. Add a **Close Form** activity to close the **Too long on hold** form after the **Ignore** button is clicked.

## Step 10: Create workflow for switching to call on hold

This workflow represents the scenario when the contact center agent clicks **Switch** in the **Too long to hold** form.

1. Add a **Form Event Trigger** activity, to trigger other activities when the **Switch** button is clicked.
   1. **Select Form** – Too long on hold
   2. **Event** – Switch clicked
2. Add a **Get Form Values** activity, to fetch the phone number of the customer that stayed too long on hold.
3. Add a **Close Form** activity, to close the **Too long on hold** form.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177843-02ebd28c.webp)

4. Add a **Use Application/Browser** activity to focus on the contact center agent app and resume the call with the customer from the **Too long on hold** form.
   1. Add an **If** activity that:
      1. Clicks **Resume** in the contact center agent app if the customer on hold is available in the contact center agent app, using a Click activity.
      2. Selects the phone number of the customer you want to switch to, using a **Select Item** activity.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-177831-dd3ca499.webp)

## Result

The result of this automation is:

* Display forms on all customers that are calling the contact center at the same time.
* Display actionable forms. For example, these could allow the contact center agent to delay a payment or change the address for a specific customer.
* Display forms based on the customer that's currently on call. This involves bringing to front the form on that specific customer.
* Keep displaying form files, even if the customers hung up. This prevents the loss of any customer data.

To see the behavior of this automation, check out the video below:

  <iframe
    src="https://documentationexamplerepo.blob.core.windows.net/examples/Forms/contact_center_automation_result.mp4"
    title="Accelerate building automations with UiPath Integration Service"
    style={{
      position: "absolute",
      top: 0,
      left: 0,
      width: "100%",
      height: "100%",
      border: 0,
    }}
    loading="lazy"
    allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
    referrerPolicy="strict-origin-when-cross-origin"
    allowFullScreen
  ></iframe>
