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

# Chatbot on Salesforce Experience Cloud

> Add the IrisGPT chatbot to a Salesforce Experience Cloud site and let it open Service Cloud cases from the conversation

Add the IrisGPT chatbot to your Experience Cloud support portal so guests and logged-in customers get answers from your knowledge base. When a customer needs a person, the chatbot creates the Service Cloud case for them, with the full conversation attached. It asks guests for their name and email, and can take them from Salesforce for logged-in customers.

## Before you begin

* Admin access to Salesforce, and to the Experience Cloud site in **Experience Builder**
* Salesforce connected to IrisAgent as your ticketing system. See [Salesforce](https://docs.irisagent.com/data-sources/Salesforce.md). The chatbot creates cases through this connection.
* An IrisGPT chatbot configuration and its embed snippet. See [Chatbot on Website](https://docs.irisagent.com/deploying-irisagent/Chatbot-on-Website.md).

## 1. Allow the chatbot's script in the site

Experience Cloud blocks third-party scripts by default.

1. Open the site in **Experience Builder** and go to **Settings → Security & Privacy**.
2. Set **Security Level** to **Relaxed CSP: Permit Access to Inline Scripts and Allowed Hosts**, then confirm.
3. Under **Trusted Sites for Scripts**, click **Add Trusted Site** and add `https://chatbot.irisagent.com`.
4. In **Setup → Trusted URLs**, add these hosts with all CSP directives (connect-src, img-src, style-src, font-src, media-src) enabled:
   * `https://chatbot.irisagent.com`
   * `https://api1.irisagent.com`
   * `https://cdn.jsdelivr.net` (chat sounds and fonts)

## 2. Add the embed snippet

1. In Experience Builder, go to **Settings → Advanced → Edit Head Markup**.
2. Paste your chatbot's embed snippet and click **Save**:

   ```html theme={null}
   <script async
     src="https://chatbot.irisagent.com/web.iife.js"
     data-token="YOUR_CHATBOT_TOKEN"
     data-host="https://api1.irisagent.com">
   </script>
   ```

   A warning asking you to confirm third-party hosts is expected after step 1.
3. Click **Publish**.

## 3. Let the chatbot open cases

1. In the [IrisAgent dashboard](https://web.irisagent.com/), go to **AI Products → Chatbot → Configure and deploy** and open the configuration you embedded.
2. Under **Handoff**, set **Method** to **Open a support ticket** and save.

This creates an **Agent handoff** procedure for the chatbot that collects the customer's name and email, then creates the case. Open it under **Automate → Procedures** to adjust the wording or add training phrases such as "agent" or "human". Keep the procedure's channel set to **Chat**.

### What the case contains

| Case field | Value |
| - | - |
| Subject | `<name> <email> \| IrisAgent Chatbot` |
| Description | The full conversation, followed by the information the chatbot collected |
| Origin | `Web` |
| Web Email (SuppliedEmail) | The email the customer gave |

The case is created as the Salesforce user who connected IrisAgent, so that user needs **Create** on Case. IrisAgent does not set Account, Contact, or custom fields directly. Use a Flow for those (next section) so your routing rules keep working from your own data.

## 4. Optional: skip name and email for logged-in customers

Head Markup is the same for every visitor, so on its own the chatbot cannot tell who is logged in and asks every customer for their name and email. The **IrisAgent Chat User** component from the IrisAgent Salesforce package reads the logged-in user's name and email from Salesforce and passes them to the chatbot. It shows nothing on the page and does nothing for guests.

1. Install or upgrade the IrisAgent Salesforce package to **v1.6.0** or later while logged in to the org: [production or Developer org](https://login.salesforce.com/packaging/installPackage.apexp?p0=04tak000000ylVVAAY) or [sandbox](https://test.salesforce.com/packaging/installPackage.apexp?p0=04tak000000ylVVAAY). Choose **Install for All Users**.
2. In Experience Builder, open the page where customers chat (for example **Home**), click **Components** (the lightning bolt icon) and drag **IrisAgent Chat User** from **Custom Components** into the page's content, for example below an existing component. It shows nothing on the page.
3. Repeat step 2 for every other page where customers open the chat. The component only works on pages it is on, and template header regions are often locked, so it cannot always be placed once for the whole site.
4. Open **Page Structure** (the list icon) and check that **IrisAgent Chat User** is listed, then click **Publish**. Until you publish, the component works only in **Preview**.

When a logged-in customer asks for help, the chatbot opens the case without asking for their name and email. Web Email on the case is set to the user's email, so the Flow in the next section can match the Contact.

> [!NOTE]
>
> The chatbot uses this identity to fill in the name and email and the case's Web Email. It does not link the case to an Account or Contact by itself. Keep using the Flow for that.

## 5. Optional: fill routing fields with a Flow

Most teams route on Account data such as support level or tier, and want to report on cases where the customer tried AI first. A record-triggered Flow handles both.

1. Create the fields you need on Case, for example a checkbox **AI Used First** and text fields **Support Level** and **Support Tier**.
2. In **Setup → Flows**, create a **Record-Triggered Flow** on **Case**, triggered when a record is **created**, optimized for **Actions and Related Records** (runs after save).
3. Add these elements:
   * **Get Records (Contact):** if Case Contact is empty and Web Email is set, find the Contact whose Email equals Web Email.
   * **Decide** which Contact and Account to use: the found Contact, or the case's own Contact and Account.
   * **Get Records (Account):** the Account from the previous step.
   * **Update Records (triggering Case):** set Contact, Account, **AI Used First** to the formula `CONTAINS({!$Record.Subject}, 'IrisAgent Chatbot')`, and copy the Account's support level and tier fields.
4. Activate the Flow.

> [!WARNING]
>
> Use an after-save Flow. For cases that logged-in portal users create, Salesforce fills in Contact and Account only after before-save Flows have run, so a before-save Flow sees them empty.

## 6. Test it

1. Open the published site in a private browser window so you are a guest, not your admin session.
2. Ask a question your help center answers and check that the reply cites sources.
3. Type `I need to talk to someone about my billing`, then give a name and an email that matches a Contact.
4. The chatbot confirms the ticket was created. In Service Cloud, open the new case and check the Description, Contact, Account, and any fields your Flow sets.
5. If you added **IrisAgent Chat User**, log in to the site as a customer user and repeat step 3. The chatbot should not ask for a name or email, and the case's Web Email should be that user's email.

## Troubleshooting

> [accordion] The chat window does not appear
>
> * Confirm the site was **published** after you edited Head Markup.
> * Check **Settings → Security & Privacy**: Relaxed CSP is selected and `https://chatbot.irisagent.com` is under Trusted Sites for Scripts.
> * Open the browser console. A blocked host is listed as a CSP error; add it under **Setup → Trusted URLs**.

> [accordion] The chatbot collects name and email but no case appears
>
> * The Salesforce connection may have expired. Reconnect Salesforce in **Data Sources → Ticketing System**, signing in as the integration user.
> * Confirm the integration user has **Create** on Case and edit access to Web Email.
> * Confirm the chatbot's Handoff method is **Open a support ticket**.

> [accordion] The chatbot still asks a logged-in customer for their name and email
>
> * Open the page in Experience Builder, open **Page Structure** and confirm **IrisAgent Chat User** is listed. It must be on every page where the chat is used.
> * Publish the site after adding it. Until then it works only in **Preview**.
> * Start a new chat after logging in. The identity is sent with each message, so an old chat window may still be waiting for an answer it asked for earlier.
> * Check that the user record has an email address.
> * If **IrisAgent Chat User** is not in the Components list, upgrade the IrisAgent Salesforce package to v1.6.0 or later, then reopen Experience Builder.

> [accordion] Account, Contact, or routing fields are empty on the case
>
> * Check that the Flow is active and runs **after save**.
> * The email the customer gives must match the Contact's Email exactly.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.