当用户在google聊天机器人上询问或选择“代理”/“与代理聊天”选项时,它应该将聊天转移到LiveChat(https://www.livechat.com/)仪表板上,以便由代理接管聊天机器人。
发布于 2022-01-14 11:36:36
要从没有安装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 Developer控制台中的一个帐户:https://developers.livechat.com/console/
在控制台中,您还可以找到与LiveChat开发人员社区的联系(不和谐和电子邮件)。
编辑:下面是更多的手放在上面的样子:
我将使用代理令牌授予方法,并通过发送以下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"
}此请求需要一个名为"organization_id“的参数--这是所有LiveChat Inc. .产品中您帐户的唯一标识符,因此我们只需要获得一次,您可以通过发送以下curl来获得它:
curl --location --request GET 'https://api.livechatinc.com/v3.4/configuration/action/get_organization_id?license_id=1234567'上面所需的许可证ID可以在您的LiveChat跟踪代码中找到: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属性对于发送事件和在访问者将来想再次聊天时恢复聊天非常有用。
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"
}
}'结果是:来袭聊天
我希望这能帮上忙!
https://stackoverflow.com/questions/69024877
复制相似问题