gpt4 book ai didi

dialogflow-es - 如何将对话流与网站中的 float 聊天集成

转载 作者:行者123 更新时间:2023-12-03 09:46:01 25 4
gpt4 key购买 nike

关闭。这个问题需要更多focused .它目前不接受答案。












想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post .

去年关闭。




Improve this question




我想在网站内使用 Dialogflow 框架。我知道 dialogflow 提供网站集成作为小部件,但是。我想在网站中使用自定义设计的 float 聊天框。就像悬停在页面角落的聊天框。我如何与这样的聊天界面集成

最佳答案

是的,对话流中有一种方法可以做到这一点。您只需要在 html/angular 或您想要设计的任何框架中创建一个简单的聊天窗口。您可以只捕获用户输入的查询并进行 ajax 调用并将其传递给 dialogflow。同样,这取决于您使用的 api 版本。 Dialogflow 为您提供 v1/v2 api,它本身会更改请求格式。请看下面的代码(使用 v1 api):

function captureUserQuery() {
var text = jQuery(".my-text").val();
dialogflowApi(text);
}

function dialogflowApi(text) {
jQuery.ajax({
type: "POST",
url: "https://api.dialogflow.com/v1/query?v=20170712",
contentType: "application/json; charset=utf-8",
headers: {
"Authorization": "Bearer " + access_token
},
data: JSON.stringify({
query: text,
lang: "en",
sessionId: "chatbot"
}),
success: function(response) {
console.log("success");
// Here you will get the response to your query in json, you will have to parse it based on the type it has like text, image, card etc. & show it to user.
parseResponse(response); // function to parse your response.
},
error: function() {
console.log("Error");
}
});
}

希望这能回答您的疑问。如果你还有更多,请告诉我。

关于dialogflow-es - 如何将对话流与网站中的 float 聊天集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49179584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com