问题描述
我想在我的 c# bot 中实现自动完成,我使用 microsoft bot 框架开发并作为 iframe 添加到我的门户中.是否可以在此机器人中实现查询建议或查询自动完成?我也试过这个解决方案
注意:我输入a
,它显示一个列表项供我选择,然后我选择一个项目,例如ActionScript,如果我直接点击发送按钮,它只会发送 a
给机器人.为了避免这种情况,我们可以在点击发送按钮之前手动输入一个空格(或其他字符)并删除它们.
I want to implement autocomplete in my c# bot which i developed using microsoft bot framework and added into my portal as iframe.is it possible to implement query suggestion or query auto-completion in this bot?i tried this solution also
Auto complete in Bot Framework
but i did not find it helpful for me.can i use jquery auto-completion here ?
https://jqueryui.com/autocomplete/
please help me in this.
Thanks in advance.
Based on my test, we can attach jQuery Autocomplete widgets to webchat input box. The following sample code is for your reference.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<link href="https://cdn.botframework.com/botframework-webchat/latest/botchat.css" rel="stylesheet" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
<link rel="stylesheet" href="https://jqueryui.com/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdn.botframework.com/botframework-webchat/latest/botchat.js"></script>
<style>
.wc-chatview-panel {
width: 350px;
height: 500px;
position: relative;
}
</style>
</head>
<body>
<div id="mybot" />
</body>
</html>
<script>
BotChat.App({
directLine: { secret: "{your_directline_secret}" },
user: { id: 'You' },
bot: { id: '{your_bot_id}' },
resize: 'detect'
}, document.getElementById("mybot"));
$(function () {
var availableTags = ["ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL"];
$("input.wc-shellinput").autocomplete({
source: availableTags
});
})
</script>
Test result:
Note: I enter a
, it show a list items for my selecting, and then I select an item, such as ActionScript, if I directly click send button, it will only send a
to bot. To avoid it, we can manually enter a white-space (or other characters) and remove them before click send button.
这篇关于在 bot 框架中的 c# bot 中查询自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!