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 条评论
Hiedi Kysther
Hi 6703592508570
Yes! As long as Magento have public API’s then our Make an API call step can make the HTTP requests to those systems.
Hope this helps!
1
Maria Gmerek
Hi,
So would it be possible to make an API call via Magento and Zendesk integrations? Does the plug-in, give you the ability to retrieve data so that when a customer asks the chatbot about his order status, he can receive complete information about it (e.g. fulfillment status)?
0
Wanessa Nascimento
Olá! Eu consigo utilizar esse recurso de fazer chamada de API para o bot conectado ao Instagram?
0
Cody Hunter
Actually I figured out my issue. I was utilizing the order # and not the order id. Which brings me to my next question. How would a customer obtain an order id? I ask this because if the customer is unable to obtain this then this use case offers no value to customers in the chat, or am I incorrect on the customer's access to this number?
0
Tony
Did you have issues following the steps in the article? Also, if you are stuck, it might be good to reach out to our Support, explaining the errors you are getting.
Best,
0
Cody Hunter
Hello,
I have got to be making a simple mistake somewhere, but I am unable to figure out where. I have the content-type in and generated an admin API and I am getting errors each time. I have tried to change the URL endpoint and it has changed my error, but not really my results. At one point I managed to get json data over, but it was not the correct data, it was just form our home page. Could someone assist me with the steps to setting up the order API for Shopify in the Zendesk Conversation bot?
0
Dane
I have created a ticket for you to check your setup. Please wait for an update via email and let's continue from there.
0
Customer Support (admin)
Hi There,
After I created a button to save user's selected order, the button showed as "Option not supported" in my iOS app. Do you know what's the reason for this?
0
Mike DR
What's the API endpoint that you're using in the bot?
0
Gabriel Manoel
Olá ao realizar uma chamada de API através dao Bot esta correndo o seguinte erro: Request Taking Too Long, o zendesk esta fechandoa conexão antes da resposta da API. como podemos configurar essa questão de timeout dessas chamadas?
Obrigado.
0
登录再写评论。