Suite | Any plan |
在本文中,我们将带您了解在消息传送人工智能专员中添加和配置步骤所涉及的程序。
有关进行 API 调用步骤及其配置规则的概述,请参阅了解人工智能专员步骤类型:进行 API 调用。
本文章包括以下部分:
将“进行 API 调用”步骤添加到人工智能专员
将进行 API 调用步骤添加到人工智能专员涉及到各种任务。
添加“进行 API 调用”步骤
添加 API 详情
使用“API 详情”部分配置要进行的 HTTP 调用,包括 HTTP 请求方法、外部资源的位置,以及根据需要添加标头。以下步骤是上一部分程序的延续。
添加 API 详情
- 在配置面板中,单击 API 详情。
- 选择一个请求方法:
- GET 可从 API 服务检索外部资源。这是最常用的方法。
- POST 可发送数据以在外部系统中创建资源。如果资源已存在,则发送的数据将修改资源。
- PUT 可发送数据以更新资源。
- PATCH - 可发送数据以更新外部网站的资源,用于将部分修改应用于资源。
- DELETE - 可移除外部资源。
- 输入端点 URL。
该端点 URL 是要连接的外部资源的位置,端点 URL 支持
https://
协议。URL 的路径或查询字符串值中可以包含变量。有关更多信息,请参阅在 API 调用中传递变量。 - (可选)选择一个连接以对 API 调用进行身份验证。
注意:您必须先创建连接,才能在进行 API 调用步骤中使用。
- 如果需要,请输入可选标头的键值和值。重要提示:请勿使用标头进行身份验证,而应改用 API 连接。
包含身份验证相关标头(例如
authorization
或x-api-key
)的进行 API 调用步骤会自动失败。如果进行 API 调用步骤失败,对话将遵循该步骤的 API 调用失败分支。 - 单击进行 API 调用以测试 API 调用。
将变量添加到步骤的 URL 或标头可以在外部服务中包含可选的测试数据,以检查 API 调用是否如预期工作。请注意,这将向已配置的端点 URL 发出 HTTP 请求。
在 API 调用中传递变量
为 API 调用输入端点 URL,即可在 URL 的路径或查询字符串值中包含变量。这样可以将数据从对话传递到外部系统。
例如,消息传送人工智能专员可以使用询问详情步骤提示客户提供订单号。然后,人工智能专员可以使用进行 API 调用步骤从您的在线商店获取订单的送货状态。
端点 URL 的域名或子域名不能使用变量。下表列举了有效和无效端点 URL 值的示例。
有效端点 URL | 无效端点 URL |
---|---|
https://myshopify.com/admin/api/orders/order_number.json 指定 Shopify 的订单 ID 以检索订单。 ![]() |
变量不能添加到域名/子域名 |
从 Google 的场所 API 按关键字搜索检索位置。 |
变量不能添加到查询字符串键值 |
如果变量无效或为空,人工智能专员将在对话期间跳过该变量。
保存来自 API 响应的变量
配置详情并测试 API 调用后,可以将 API 调用的 JSON 响应的值保存为变量。在进行 API 调用步骤中,最多可以保存 12 个变量。只保存变量值的前 280 个字符。
根据响应数据创建变量
- 在配置面板中,单击进行 API 调用。
- 展开折叠面板,并确定要转为变量的外部系统数据。
提示:切换到响应正文标签可查看从外部系统返回的原始响应。
- 单击保存。
- 为新变量命名。
变量名称只能包含小写字母、数字和下划线。
在 API 调用中传递数组变量
{
"info": {
"count": 50,
"pages": 2,
"next": "https://mycompany.com/api/orders?page=2",
"prev": null
},
"results": [
{
"id": 1052,
"name": "Alexander Cummings",
“address”: “123 MyStreet”,
"Item": "belt",
"price": "15.00",
"image": "https://mycompany.com/api/orders/avatar/1.jpeg",
…
id
、name
、address
、item
、price
和 image
都会显示出来。此数据通常被传递到轮播,但轮播最多只能显示 10 个项目。
lastname
和 firstname
可以单独另存为数组变量。
"name":
{
"lastname": "Cummings”,
"firstname": “Alexander"
},
在管理中心的轮播配置中无法编辑数组或数组值。如需更改任何数据,必须在管理中心删除该数组并创建一个新数组。
{{customer.order}}
的值为空。其中,卡片 1 将显示为“订单号”的部分标题,卡片 2 则因生成的标题为空而不会显示。
Card 1
Title: Order number {{customer.order}}
Description: Here's your order {{product.description}}
Card 2
Title: {{customer.order}}
Description: Here's your order {{product.description}}
示例
{
"info": {
"count": 5,
"pages": 1
},
"results": [
{
"createdAt": "July 10, 2023",
"name": "Connie Stokes",
"Shippingaddress": "123 Street, City, State",
"order": {
"Status": "Ordered",
"Image": "https://images.pexels.com/photos/1484808/pexels-photo-1484808.jpeg"
},
"Quantity": 1,
"Price": 45,
"Item": "Shirt",
"id": "1"
},
…
本例使用进行 API 调用创建了数组变量,然后使用动态轮播向终端用户显示结果。
创建数组
- 在配置面板中,单击进行 API 调用。
- 输入 orders 作为名称。
- 在配置面板中,单击 API 详情。
- 单击请求方法下拉菜单,然后选择 GET。
- 输入 URL 作为端点 URL。
- 对于身份验证,选择您的身份验证方法。
有关更多信息,请参阅创建连接以与外部服务整合。
- 单击进行 API 调用。
- 单击结果旁边的保存。
- 从值下拉菜单中选择 Order,然后选择 Image。
使用默认变量名称 (image)。
- 单击添加项目,然后重复上述步骤,为 Order Status 和 Item 创建项目。
最多可添加 12 个项目(或键值对)。
- 单击保存。
- 在智能机器人生成器中,单击 API 调用成功下的添加步骤,然后选择添加轮播。
- 在配置面板中,单击转换为动态消息。
- 在数组下拉菜单中,单击结果。随即显示上面创建的数组。
- 对于标题,单击加号,选择 results.item。
对于标题和描述,您最多可以输入 128 个字符。
- 对于按钮链接,单击加号,选择 results.image。
- 对于按钮文本,单击加号,选择 results.status。
- 对于图像链接,单击加号,选择 results.image。
- 单击完成。
以下是一个动态轮播的例子。
关于步骤分支
进行 API 调用步骤是分支步骤。添加此步骤可根据 API 请求是否成功执行来拆分人工智能专员响应。
- API 返回 400 或 500 响应代码。
- API 返回 200 响应代码(如果保存的变量之一缺失或有
null
值)。
在所有其他情况下,人工智能专员将沿成功分支下移。
69 条评论
Alex Duffey
We need the character limit to be lifted. 280 is very small. Please look at opening this in the future. We are trying to a return an accessory list of products for one of our products, but the 280 limit stops us from providing that full list.
We tried breaking it up into multiple variables, but the the system requires us to save each one for each new product, which then runs into the 50 mac variable limit.
Please either raise the character limit to at least 1000 or raise the variable limit to at least 200.
0
Jeffrey Porter
Is it possible to include the originating URL for the page on which the chat bot was accessed in an API call? Our use case is that we are installing the chat bot on a video player and each video has a distinct URL. I created a chat bot flow that creates a Zendesk ticket. We'd like to be able to include the URL for the page in the ticket so we know where to go look for a problem. Right now we'd have to ask the user for something and we're guaranteed to get vague answers.
0
Aktie Projeto
Como faço para apagar variáveis que coloquei para teste e agora estão ocupando espaço no meu bot?
0
Yiannis Lamprou
I am trying to get data from hubspot via Make API call.
I am using POST method and i get all fields i want and can turn them to variable.
However the fields ( variables) are coming as numbers. (e.g
"hs_pipeline_stage":"67655766",
)How can i say to ZD to display text according to the variable coming in?
Is there a way to create an array or so besides carousel?
0
이지훈
I have a similar question to 6336142945306
For example, I want to use users.json to allow end users to retrieve their information using an API.
If a user has a "custom_role_id" value, I can create a flow by saving that value as a variable.
However, if the flow is executed for a user who does not have a "custom_role_id" value, an API error is returned.
In conclusion, even null values should be saved as variables, and when the variable is referenced in the flow, a null value should be returned instead of an error.
Is this possible?
0
Nir Tzezana
Hi,
I have some data I want to add to the API request body, this is data that I already have when the chat window opened (no need to gather it from the user), how can I do that?
0
Fatima Sbeih
Has anyone managed to set this up with Stripe?
0
דורין אברבך
Hey, https://support.zendesk.com/hc/en-us/articles/4572971586586/comments/4614301298458 is there any updates?
about getting information from the user in order to use their input as parameters in API request
0
Javier DM
Este caso que comentas, está justamente mencionado al pie de este artículo, donde pone:
He visto este tipo de situaciones, cuando se quiere utilizar un
null
value como expresión boolean. Por eso la llamada puede ser exitosa (respuesta 200), pero el valor no corresponde a ninguna de las varlables que se han guardado para el flujo, por lo que el paso API fallará.Un ejemplo:
En este caso, cuando el valor sea
null
el paso API va a fallar, por mas que la llamada sea exitosa. Ya que la variable aquí guardada esorganization_id
ynull
no es un valor exista para ese atributo.Espero esta explicación te sea de utilidad. Si precisaras revisar tu caso en mas profundidad, te sugiero por favor dirigirte a support.zendesk.com/hc e iniciar una conversación con el bot para ponerte en contacto con nuestro equipo de soporte.
Saludos y que tengas buena semana!
0
María del Mar Beiras Neira
Buenas, he configurado la respuesta de Hacer una llamada a una API al revisar los Logs, veo que la respuesta fue “SUCCEEDED”, sin embargo entra por la rama de error de llamada API, entonces realmente no se que hacer para este caso, ya que no entiendo porque esta entrando por esa rama.
0
登录再写评论。