

# Test and roll out to agents

Test in your test environment first, with test records. Then pilot one queue with a small group of agents, adjust the views, and move agents in waves.

The sample account and case guide uses only standard objects and fields: it reads and writes Account, Contact, Case and case comments (through the case's Comments field), and reads CaseStatus, EmailMessage and ContentDocumentLink. It needs no changes to your org's schema. Your org's validation rules still apply.

The guide has these parts:

1. **Inbound flow**. Sets the contact attributes `customerContactId` and `customerChannel`, and on a call `customerPhone` to the caller's number. Then it sets the guide flow as the **Default flow for Agent UI**, and the wrap-up flow as the **Disconnect flow for agent UI** if the stack has it, and transfers the contact to the queue in `TestQueueArn`. It expects `accountId`, or the other attributes in [How the guide finds the record](real-time-data-integration-start.md#real-time-data-integration-find-record), to be set upstream by a trusted source.

1. **Guide flow**. Moves the agent between the views. It finds the customer, reads the account and a case, lists the account's cases, creates cases and customers, and updates the account and its contacts through the guide's flow modules, and calls the gateway directly for Update case, Add a contact and four reads; see [Extend the guide with flow modules](real-time-data-integration-modules.md).

1. **Flow modules**. Find the record, Find the customer, Read the account, Read a case, List the account's cases, Create a case, Create a customer, Update a record and, in a nested stack, Create a case with details. The stack also creates Read the verified account, which only the AI self-service account agent runs. Each one refuses a value that contains a character that could change its query, such as `'`, `\` or `%`, before it calls the gateway. Your own flows can call them too; see [Extend the guide with flow modules](real-time-data-integration-modules.md).

1. **Wrap-up flow**. If you deploy with **Wrap-up flow and form** set to `Enabled`, a guide that opens when the contact ends. Its **After contact work** view asks the agent for a **Disposition code** and notes, and sends nothing to Salesforce. For reports, it sets these contact attributes:
   + On the customer's contact, when the form opens: `wrapUpStatus` `shown`.
   + On the customer's contact, on **Save**: `wrapUpReason` (`Resolved`, `FollowUp`, `Escalated` or `InfoOnly`), `wrapUpNotes`, and `wrapUpStatus` `submitted`.
   + On the wrap-up guide's own contact, when the form has shown three times with no save: `wrapUpStatus` `expired`. The customer's contact keeps `shown`.

    The stack creates it only when **Wrap-up flow and form** (`WrapUp`) is `Enabled`; the default is `Disabled`.

1. **Views**. The screens agents see, such as `{{stack-name}}-view-main`, the account view. The stack creates them in a nested stack. For what each screen shows, see [What agents see in the sample account and case guide](real-time-data-integration-agent-experience.md).

## Test each channel and transfers
<a name="real-time-data-integration-test-voice"></a>

Before you go live, test each channel your agents take, chat and voice, with a test chat and a test call as in [Test the guide with the inbound flow](real-time-data-integration-start.md#real-time-data-integration-test-chat), and test transfers. To have a test call open a test account without a search, assign the test phone number to a copy of your inbound flow in which the **Set contact attributes** block sets `accountId` to the test account's ID.

On a transferred contact, the guide opens again for each agent who accepts the contact. It opens the case view when the previous agent left the contact in the case view, and otherwise the account view of the account the previous agent had open. Each agent's wrap-up writes the same contact attributes, so the last agent to save wins.

## What to check
<a name="real-time-data-integration-test-checks"></a>

1. The guide starts when the contact is offered to you, and shows the record when you accept. With the Salesforce guide, that is the account view, with the account's recent cases and contacts.

1. **View case** on a case shows its details and its related lists, and **Back to the account** returns to the account view.

1. A contact with no record ID, or with an ID that matches no record, shows **Customer not found** on a chat and **Unknown caller** on a call or any channel other than chat. Each search finds a test record: by account number and by contact email, an account; by name, phone, email or case subject, the matching accounts, contacts and cases; and by case number, the case in the case view.

1. Changing a case's status with a comment adds the comment to the case in Salesforce. Use a test case with no contact, or an internal one: a public comment can reach the contact as soon as it's saved. Save a comment with the status unchanged, then a new status with a comment. Then open the test case's **Case Comments** related list and check **Created By** and **Public** for the two comments. Both must be by the integration user and not public.

   Instead, in the Salesforce Developer Console, you can choose the **Query Editor** tab and run the following query, which lists today's newest case comments. On the two comments, `IsPublished` must be false:

   ```
   SELECT Parent.CaseNumber, IsPublished, CreatedBy.Name, CommentBody FROM CaseComment
   WHERE CreatedDate = TODAY ORDER BY CreatedDate DESC LIMIT 10
   ```

   Repeat on a test case of each record type or support process agents will update.

   A public comment means that something in your org, such as automation, published it. Clear **Public** on it. Before agents use **Update case**, your Salesforce administrator decides whether the automation that published it runs on the integration user's comments. If it must, build your own guide on the gateway-only template, `connect-sf-real-time-data-integration-gateway.template.json`, which creates the gateway and no guide.

1. Creating a case adds it to the account in Salesforce. Check it in Salesforce, and check that its creator is the integration user.

1. After a search that finds nothing, **New customer** creates a test account with its contact, and **Add a contact** adds a contact to it. Check both in Salesforce, and delete the test records afterwards.

1. With the least-privilege integration user you will use in production as the app's **Run As** user, not an administrator, every step still works, including creating a case and a customer in each org you use. A missing permission shows one of these:
   + **Could not load**, when the account view can't be read.
   + **Case not created**, with Salesforce's message, when a case create is refused. A subject the guide reads as empty, such as the word `null`, shows **The case wasn't created. Enter a subject.** instead.
   + **Salesforce did not save the customer, and nothing was created:**, with Salesforce's message, on **New customer**.
   + **Salesforce did not save the changes.**, on Edit customer and Edit contact.

1. Creating a case works with your org's validation rules. A required custom field with no default value makes every create fail. A rule that requires a contact on every case makes a create fail when the guide didn't find the customer through a contact.

1. Automation in your system, such as Salesforce assignment rules, behaves as you expect on the guide's writes; see [Update records and run automation in your system](real-time-data-integration-automation.md).

If a check fails, see [Troubleshoot real-time data integration](real-time-data-integration-troubleshoot.md).

## Test and production environments
<a name="real-time-data-integration-environments"></a>

Set up a test environment first, with a test Connect Customer instance and a test copy of each system (for Salesforce, a sandbox). Each environment needs its own stack, and so its own gateway, credential provider, integration user and API credentials: each stack's gateway calls one Salesforce org (`SalesforceMyDomainUrl`) and is associated with one Connect Customer instance (`InstanceArn`).

A guide flow calls tools by names that include the gateway ID and the target name: `gateway_{{gateway-id}}__{{target-name}}___{{operation}}`. A flow copied from the test instance to production still points at the test gateway, so update the application and tool in every External Tool block. The same happens if you rename a target, or if a stack update replaces the gateway. Deploy one stack per environment instead of copying flows.

## Roll out in waves
<a name="real-time-data-integration-waves"></a>

Before you move the first wave, confirm the following:
+ The calls the guides will make fit your system's API allocation, the gateway's quota and the concurrent active chats quota; see [Plan for scale](real-time-data-integration-limits.md).
+ Your system's automation on the guide's writes does what you expect; see [Update records and run automation in your system](real-time-data-integration-automation.md).
+ You checked the integration user's permissions against the operations your guides and AI agents call, and the record ID comes from a source the customer can't change; see [Security considerations](real-time-data-integration-security.md).
+ You checked who has the **Flows - Edit** permission: those users can call every tool on the gateway.

Then move each wave:

1. Repeat the setup for your production org and instance. The stack creates the guide's views and flows in each instance it is deployed to, so you deploy it again rather than copy them. Make again any change you made to them in the test instance. If you keep the change in views and flows of your own and copy those, set the application and tool in every External Tool block to the production stack's gateway after you copy them.

1. Move a wave by routing its contacts through flows that set the guide flow as the **Default flow for Agent UI** (and the wrap-up flow as the **Disconnect flow for agent UI**, if you use it), and by giving its agents the security profile permissions in [Give your security profile the permissions to edit the guide's flows](real-time-data-integration-instance.md#real-time-data-integration-instance-guides). To move a wave back, remove those permissions and that routing; its agents then work as before.

Agents who have moved and agents still on the CTI Adapter see the same records, because the guide reads and writes the source system directly.