【问题标题】:How to integrate LiveChat Dashboard with Google Dialogflow for agents handoff?如何将 LiveChat Dashboard 与 Google Dialogflow 集成以进行代理交接?
【发布时间】:2021-10-31 14:41:21
【问题描述】:

当用户在 google dialogflow 聊天机器人上询问或选择“代理”/“与代理聊天”选项时,它应该将聊天转移到 LiveChat(https://www.livechat.com/) 仪表板,以便代理从聊天机器人接管。

【问题讨论】:

  • 请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。

标签: dialogflow-es chatbot livechat


【解决方案1】:

要将数据从没有安装 LiveChat 聊天窗口的页面传递到 LiveChat, 您可以使用 LiveChat API 中的以下方法: https://developers.livechat.com/docs/messaging/agent-chat-api#create-customer 创建客户

然后,以该客户的身份开始聊天:

https://developers.livechat.com/docs/messaging/customer-chat-api#start-chat

一旦开始聊天 - 您可以使用以下方法提交事件: https://developers.livechat.com/docs/messaging/customer-chat-api#send-event

对于以上所有内容,您都需要提供授权,请参见下文: https://developers.livechat.com/docs/authorization/authorizing-api-calls

要获得授权,您需要在 LiveChat 开发者控制台中拥有一个帐户: https://developers.livechat.com/console/

在控制台中,您还可以找到 LiveChat 开发者社区的联系方式(Discord 和电子邮件)

编辑:这看起来像是更多的动手:

  1. 我们需要做的第一件事是获得身份验证 - 在这种情况下,我们想作为客户进行身份验证,有几种方法可以作为客户进行身份验证 - 以下是有关所有方法的说明: https://developers.livechat.com/docs/authorization/authorizing-api-calls#case-new-customer

我将使用代理令牌授予方法并通过发送以下 curl 获取客户访问令牌:

curl --location --request POST 'https://accounts.livechat.com/customer/token' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer dal:xxxFpzmIHk5c86Zwn3uf2YunhGk' \
--data-raw '{
"grant_type": "agent_token",
"client_id": "3xxx45a50544060cedc26c90644f7677",
"response_type": "token",
"redirect_uri": "https://my.livechatinc.com"
}
'

以下是收到的回复:

{
    "access_token": "dal:xxx-zH-fTOKYJsUolAKzow",
    "client_id": "xxx145a50544060cedc26c90644f7677",
    "entity_id": "xxx1d260-e284-44c0-53d2-3e958f74488a",
    "expires_in": 28800,
    "token_type": "Bearer"
}
  1. 获取客户访问令牌后,我们将寻求发送“开始聊天”方法

此请求需要一个名为“organization_id”的参数 - 这是您帐户在所有 LiveChat Inc. 产品中的唯一标识符,它是静态的,因此我们只需要获取一次, 您可以通过发送以下 curl 来获取它:

curl --location --request GET 'https://api.livechatinc.com/v3.4/configuration/action/get_organization_id?license_id=1234567'

可在您的 LiveChat 跟踪代码中找到上述所需的许可证 ID: https://my.livechatinc.com/settings/code

发送请求会在响应中为您提供“organization_id”:

{
    "organization_id": "xxx29b0e-012c-4384-9f72-614324ec0xxx"
}

现在我们拥有一切 - 我们可以开始聊天了:

curl --location --request POST 'https://api.livechatinc.com/v3.4/customer/action/start_chat?organization_id=xxx29b0e-012c-4384-9f72-614324ec0741' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer dal:xxx-zH-fTOKYJsUolAKzow' \
--data-raw '{}'

响应如下所示:

{
    "chat_id": "R5MUSNS1I5",
    "thread_id": "R5MUSNS1J5"
}

上述响应中的chat_id 属性对于发送事件和恢复聊天很有用,如果访问者以后想再次聊天

  1. 要发送消息,我们将使用“send_event”方法,如下所示:
curl --location --request POST 'https://api.livechatinc.com/v3.4/customer/action/send_event?organization_id=xxx29b0e-012c-4384-9f72-614324ec0741' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer dal:xxx-zH-fTOKYJsUolAKzow' \
--data-raw '{
    "chat_id": "R5MUSNS1I5",
    "event": {
      "type": "message",
      "text": "hello world",
      "recipients": "all"
    }
  }'

结果如下: incoming chat

希望对你有帮助!

【讨论】:

  • 仅链接到文档并不理想。能否提供一个代码示例?
  • 嗨,我已经编辑了帖子以提供更清晰的信息。亲切的问候:)
猜你喜欢
  • 2023-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-17
  • 1970-01-01
  • 2018-11-05
  • 2020-09-28
相关资源
最近更新 更多