本页面为开发者提供构建特定应用GPT Action的说明与指南。在继续之前,请确保您已熟悉以下信息:
此特定GPT操作概述了如何连接到Salesforce,特别是Salesforce服务云。此操作中详述的模式允许用户直接从ChatGPT提取案例数据并更新案例。为其他Salesforce云解决方案创建操作的设置过程使用相同的连接应用和身份验证设置,但需要不同的API模式。
价值与示例商业应用场景
价值: 用户现在可以利用ChatGPT的自然语言能力直接连接到Salesforce
示例用例:
- 降低客户的平均响应时间
- 缩短故障排查案例或问题的时间
- 结合GPT中的知识和指令,确保在回应客户时保持更一致的品牌声音
应用信息
应用密钥链接
在开始之前,请查看应用程序中的这些链接:
应用前提条件
在开始之前,请确保您已在应用程序环境中完成以下步骤:
- 确保您拥有在Salesforce中创建应用的权限
ChatGPT 步骤
自定义GPT指令
创建自定义GPT后,请将以下文本复制到指令面板中。有问题吗?查看入门示例详细了解此步骤的操作方法。
**Context**: Your purpose is to pull information from Service Cloud, and push updates to cases. A user is going to ask you a question and ask you to make updates.
**Instructions**:
1. When a user asks you to help them solve a case in Service Cloud, ask for the case number and pull the details for the case into the conversation using the getCaseDetailsFromNumber action.
2. If the user asks you to update the case details, use the action updateCaseStatus.
**Example**:
User: Help me solve case 00001104 in Service Cloud.OpenAPI 规范
创建自定义GPT后,在操作面板中复制以下文本。有问题吗?查看入门示例了解此步骤的详细操作方式。
openapi: 3.1.0
info:
title: Salesforce Service Cloud Case Update API
description: API for updating the status of Service Cloud tickets (cases) in Salesforce.
version: 1.0.3
servers:
- url: https://your_instance.my.salesforce.com
description: Base URL for your Salesforce instance (replace 'your_instance' with your actual Salesforce domain)
paths:
/services/data/v60.0/sobjects/Case/{CaseId}:
patch:
operationId: updateCaseStatus
summary: Updates the status of a Service Cloud case
description: Updates the status of a Service Cloud ticket based on the case ID number.
parameters:
- name: CaseId
in: path
required: true
description: The ID of the case to update.
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
Status:
type: string
description: The new status of the case.
responses:
'204':
description: Successfully updated the case status
'400':
description: Bad request - invalid input or case ID not found
'401':
description: Unauthorized - authentication required
'404':
description: Not Found - case ID does not exist
delete:
operationId: deleteCase
summary: Deletes a Service Cloud case
description: Deletes a Service Cloud ticket based on the case ID number.
parameters:
- name: CaseId
in: path
required: true
description: The ID of the case to delete.
schema:
type: string
responses:
'204':
description: Successfully deleted the case
'400':
description: Bad request - invalid case ID
'401':
description: Unauthorized - authentication required
'404':
description: Not Found - case ID does not exist
/services/data/v60.0/query:
get:
operationId: getCaseDetailsFromNumber
summary: Retrieves case details using a case number
description: Retrieves the details of a Service Cloud case associated with a given case number.
parameters:
- name: q
in: query
required: true
description: SOQL query string to find the Case details based on Case Number.
schema:
type: string
example: "SELECT Id, CaseNumber, Status, Subject, Description FROM Case WHERE CaseNumber = '123456'"
responses:
'200':
description: Successfully retrieved the case details
content:
application/json:
schema:
type: object
properties:
totalSize:
type: integer
done:
type: boolean
records:
type: array
items:
type: object
properties:
Id:
type: string
CaseNumber:
type: string
Status:
type: string
Subject:
type: string
Description:
type: string
'400':
description: Bad request - invalid query
'401':
description: Unauthorized - authentication required
'404':
description: Not Found - case number does not exist
认证说明
以下是设置与这个第三方应用程序进行身份验证的说明。有问题吗?查看入门示例以更详细地了解此步骤的工作原理。
预操作步骤
在ChatGPT中设置身份验证之前,请先在应用程序中执行以下步骤。
在ChatGPT中设置身份验证之前,请先在应用程序中执行以下步骤。
- 导航至Salesforce设置

- 搜索“应用管理器”

- 点击“新建关联应用”
- 输入连接的应用程序名称
- 输入联系邮箱(您的邮箱)
- 勾选复选框以启用OAuth设置
- 插入一个回调URL(暂时使用类似https://chat.openai.com/aip//oauth/callback的占位符,稍后在ChatGPT中创建Action时再更新)

- 选择“Selected OAuth Scopes”并授予适当的权限。根据内部安全策略设置这些范围。

- 确保勾选以下复选框:
- 启用客户端凭据流
- 启用授权码和凭证流程
- 启用令牌交换流程
- 确保以下方框未被勾选:
- 要求支持的授权流程使用代码交换证明密钥(PKCE)扩展

- 保存您的新连接应用
- 在“Consumer Key and Secret”下方点击“Manage Consumer Details”。使用发送至您账户的验证码确认访问权限,然后复制密钥和密钥串。
- Salesforce Consumer Key = ChatGPT 客户端 ID
- Salesforce 消费者密钥 = ChatGPT 客户端密钥

- 返回应用页面
- 点击“管理”
- 点击“编辑策略”
- 在OAuth策略下,勾选“启用令牌交换流程”复选框

- 点击保存!
在ChatGPT中
在ChatGPT中,点击"认证"并选择"OAuth"。输入以下信息。
- 客户端ID: 使用上述步骤中的客户端ID
- 客户端密钥: 使用上述步骤中的客户端密钥
- 授权URL: https://[inserturlhere].my.salesforce.com/services/oauth2/authorize
- 令牌URL: https://[inserturlhere].my.salesforce.com/services/oauth2/token
- 范围: 全部
- Token: 默认 (POST)
后续操作步骤
在ChatGPT中设置好身份验证后,按照应用程序中的以下步骤完成Action的最终设置。
- 从GPT Action复制回调URL
- 返回Salesforce中的Connected App,并添加您的回调URL。
常见问题与故障排除
- 回调URL错误: 如果您在ChatGPT中遇到回调URL错误,请仔细查看上面的截图。您需要直接将回调URL添加到Salesforce中,才能使操作正确进行身份验证
- 内部服务器错误: 确保在您连接的应用程序的OAuth设置中正确勾选和/或取消勾选所有复选框。
是否有您希望我们优先考虑的集成方案?我们的集成是否存在错误?请在GitHub上提交PR或问题,我们会尽快查看。