# Salesforce

Connect Salesforce so your AI agent can open a case for your support team or hand a customer to a live agent

## Overview

The QwryAI Salesforce integration gives your AI agent two ways to bring in a person. It can open a Salesforce case with an AI-written summary of the conversation, or it can hand the customer to a live agent in Salesforce, in the same chat. One connection serves both.

| Action | What it does |
| --- | --- |
| Create ticket | Opens a case in Salesforce for an issue your team can follow up later. |
| Salesforce live chat | Connects the customer to a Salesforce agent in real time, in the chat they are already in. |

## Before you start

- A QwryAI AI agent. The connection is per AI agent, and each AI agent can connect one Salesforce org.
- A Salesforce user who can create cases. Cases are created as this user, and this user owns them.
- For cases: the Case fields Web Email and Web Name must be visible to that user (field-level security). Salesforce hides them from some profiles by default, and the case then fails.
- For live chat: a Salesforce org with Messaging and Omni-Channel.

## How to connect Salesforce

#### 1. Open your QwryAI AI agent

Go to your QwryAI dashboard and select the AI agent you want to connect.

#### 2. Connect Salesforce

Choose Integrations, then click Connect under Salesforce. Sign in to Salesforce and allow access. You enter no keys.

Custom domain is optional. Fill it in only for a sandbox, or for an org that blocks login.salesforce.com. It must be a My Domain address ending in .my.salesforce.com, for example acme.my.salesforce.com.

## Create ticket

Go to Build → Actions → Create Action, select Create ticket under Escalations, and choose Salesforce as the Ticket Platform. Salesforce is listed only after you connect it. It has no extra options on the Action. Follow the Escalate to Human guide for the rest of the setup.

The Action works on the Chat Bubble, Help Page, Center Stage, Email, and the API.

#### What the case contains

- Subject: written by the AI agent from the customer's issue. The customer is never asked for it.
- Description: a short AI-written summary of the issue in the customer's own words and language.
- Case Origin: Web.
- Web Email and Web Name: the customer's email and name.
- Owner: the Salesforce user who connected.
- Private comment: a link to the full conversation in QwryAI, added right after the case is created.

QwryAI doesn't create or link a Contact or Account, and sets no priority, type, or custom fields.

#### What the customer sees

The AI agent asks for the customer's email and name if it doesn't already have them, creates the case, and tells the customer the case number. On the Chat Bubble, Help Page, and Center Stage, a ticket card also shows the case number, its subject and description, and the customer's name and email. If Salesforce refuses the case, the card reads "Failed to create ticket" and the AI agent tells the customer that no ticket was created.

> Test the Action by asking your AI agent to speak to a human, and confirm a case appears in Salesforce with the conversation summary.

## Salesforce live chat

Live chat works on the Chat Bubble, Help Page, and Center Stage. Set up your Salesforce org first, then create the Action.

#### 1. Turn on Messaging

In Salesforce Setup, search for Messaging Settings and turn Messaging on.

#### 2. Set up Omni-Channel

In Setup, search for Omni-Channel and set up presence statuses, a routing configuration, and a queue, so chats reach your agents.

#### 3. Add the JSON Web Keyset

In QwryAI, go to Build → Actions → Create Action → Salesforce live chat and copy the JSON Web Keyset URL from the editor. In Salesforce Setup, search for Enhanced Chat User Verification, open JSON Web Keysets, click New, give it a Name and API Name, choose Endpoint as the type, and paste the URL. Paste the same URL into JSON Web Key Issuer; chats are refused if the issuer differs. Salesforce uses the keyset to check that a chat really comes from your AI agent's visitor.

#### 4. Create the Messaging channel

In Messaging Settings, click New Channel, select Enhanced Chat, and choose Mobile as the deployment type. Set its routing to your Omni-Channel queue, accept Salesforce's terms when asked, and save. Select Add User Verification and save again. Then open the channel, find User Verification Configuration, click New, select the keyset from step 3, give it a name without spaces, keep Active selected, and save. Salesforce creates a Mobile deployment for the channel on its own; you don't use that one.

#### 5. Create the deployment

In Setup, search for Embedded Service Deployments and click New Deployment. Select Enhanced Chat, then Custom Client, pick the channel from step 4, save, and publish. On this Custom Client deployment (not the Mobile one Salesforce created in step 4), click Install Code Snippet and note the OrganizationId, DeveloperName, and Url. In QwryAI they are Org ID, Developer Name, and Salesforce Live Chat API URL.

#### 6. Create the Action

Back in the Salesforce live chat editor in QwryAI, enter the three values: Url as Salesforce Live Chat API URL, DeveloperName as Developer Name, and OrganizationId as Org ID. Save, choose the channels, and enable the Action.

#### What the customer sees

When the AI agent starts a live chat, it stops answering and the customer waits for an agent. The agent gets an AI-written summary of the issue as the first message. Once the agent replies, the chat shows "<agent name> connected" and the agent's messages appear with their name. The customer's messages go to the agent. When the agent ends the chat in Salesforce, the AI agent answers again.

## Disconnecting

On the Integrations page, open the menu on the Salesforce card and click Disconnect. QwryAI lists the Salesforce Actions of this AI agent, both Create ticket and live chat, and deletes them when you confirm. It also revokes its access in Salesforce. Cases already in Salesforce aren't affected.

## Troubleshooting

### The card says "Enter a Salesforce domain ending in .my.salesforce.com"

The Custom domain must be your My Domain address, for example acme.my.salesforce.com or acme--uat.sandbox.my.salesforce.com. Leave the field empty unless you use a sandbox or your org blocks login.salesforce.com.

### The chat shows "Failed to create ticket"

Salesforce refused the case. The most common cause is that Web Email or Web Name is hidden from the user who connected. In Salesforce Setup, open Object Manager → Case → Fields & Relationships, and make both fields visible for that user's profile.

### Cases stopped being created, but the card still says Connected

The card shows Connected as long as a saved connection exists, even if Salesforce no longer accepts it (for example, after access was revoked in Salesforce). Disconnect and connect again.

### Saving the live chat Action shows "Invalid URL"

Salesforce Live Chat API URL must be the Url from the deployment's code snippet. It starts with https:// and ends with salesforce-scrt.com.

### The customer keeps waiting and no agent gets the chat

Check that the deployment is published, that the Messaging channel has an active User Verification configuration with the keyset from QwryAI, and that an agent is online in Omni-Channel with capacity for the channel's queue.

## Frequently asked questions

### Can I connect a sandbox?

Yes. Enter the sandbox's My Domain address in Custom domain before you click Connect.

### Do replies on a case show up in the chat?

No. Your team replies from Salesforce the way it normally does, usually by email. The chat only shows the case number.

### Does live chat need a separate connection?

No. Live chat uses the same Salesforce connection, plus the three deployment values on the Action.

### What happens to my Actions if I disconnect Salesforce?

QwryAI lists the Salesforce Actions and deletes them when you confirm. Recreate them after you connect again.

## Next steps

- [Escalate to Human: configure when your AI agent escalates, which details it collects first, and which channels it can escalate from](/docs/user-guides/actions/escalate-to-human)
