[英]is there any way that a azure chatbot can query the databse and return answer from the database? may be using qna maker or luis?
I am trying to build a chat bot which queries a database and returns answer from the database depending on the question asked.我正在尝试构建一个聊天机器人,它查询数据库并根据所提出的问题从数据库中返回答案。 is there any way to connect the azure chat bot to the database say azure SQL database?有什么方法可以将 azure 聊天机器人连接到数据库,比如 azure SQL 数据库?
Per your additional information, I have changed my answer.根据您的附加信息,我已更改答案。 The original suggestion using QnA Maker is below.使用 QnA Maker 的原始建议如下。 If you need to retrieve data from a database, such as student scores the best way to do this is with a slot-filling dialog.如果您需要从数据库中检索数据,例如学生成绩,最好的方法是使用插槽填充对话框。 Personally, I use and prefer waterfall dialogs initiated by intent recognition with LUIS, but there are other ways to do it.就个人而言,我使用并更喜欢通过 LUIS 的意图识别启动的瀑布对话,但还有其他方法可以做到这一点。
if (step._info.options.entities.orderNumber) {
return await step.next(step._info.options.entities.orderNumber[0].toUpperCase());
} else {
return await step.prompt(ORDER_PROMPT, {
prompt: 'Please provide your order number.',
retryPrompt: 'Please enter a valid order number.',
});
}
step.values.orderNumber = step.result;
例如,在上述步骤之后的步骤中,您将通过step.values.orderNumber = step.result;
在我的示例中存储订单号。 ( or step.result.value
if returning a choice selection). (或step.result.value
如果返回选项选择)。const score = await queryMyDb(student, subject)
.但是,如果我们假设您是通过某种帮手来做到这一点的,那么您只需调用类似const score = await queryMyDb(student, subject)
类的东西。 Then you can reply with the score to the user.然后您可以将分数回复给用户。This should give you enough to make an attempt at retrieving the information.这应该足以让您尝试检索信息。 If you try and still have trouble, you can open a separate request showing your code and the specific problems you are encountering.如果您尝试但仍然遇到问题,您可以打开一个单独的请求,显示您的代码和您遇到的具体问题。
Previous answer before additional context received:收到附加上下文之前的先前答案:
Assuming you are just wanting to retrieve answers to questions in a single question-answer pair, it sounds like you just need to deploy QnA Maker and create a bot to utilize it.假设您只想在单个问答对中检索问题的答案,听起来您只需要部署 QnA Maker 并创建一个机器人来使用它。 Microsoft provides good instructions on how to Create, train, and publish your QnA Maker knowledge base . Microsoft 提供了有关如何创建、培训和发布 QnA Maker 知识库的良好说明。 Give it a try and if you have any issues, come back and ask via a separate question along with the code you've tried.试一试,如果您有任何问题,请返回并通过单独的问题以及您尝试过的代码提出问题。
QnA Maker can support prompts for multi-turn conversations as well. QnA Maker 也可以支持多轮对话的提示。 You're still dealing with single question-answer pairs, but you can provide a easy selection for users to bring up related answers with a click of a button.您仍在处理单个问答对,但您可以为用户提供一个简单的选择,以便通过单击按钮来显示相关答案。
If you are using azure storage like table storage or blob.如果您使用 azure 存储,例如表存储或 blob。 I suggest using Azure search service.我建议使用 Azure 搜索服务。 This will help you solve your problem, but it will certainly add up the cost.这将帮助您解决问题,但肯定会增加成本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.