为什么Dialogflow Node.js SDK会“检测知识库的意图”?方法以null响应? (V2Beta) [英] Why does Dialogflow nodejs sdk "detect Intent with Knowledge Base" method responds with null ? ( V2Beta)

查看:72
本文介绍了为什么Dialogflow Node.js SDK会“检测知识库的意图”?方法以null响应? (V2Beta)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 Dialogflow Node.js sdk 集成到我的应用程序中,以借助以下文档 nodejs-dialoglowflow-detect-knowledgebase-intent

I am integrating the Dialogflow Nodejs sdk into my application to detect the knowledge base intent with the help of the following document nodejs-dialoglowflow-detect-knowledgebase-intent.

以下是我的查询请求

const request = {
session: sessionPath,
queryInput: {
  text: {
    // The query to send to the dialogflow agent
    text: message,
    // The language used by the client (en-US)
    languageCode: 'en-US',
  },
},
queryParams: {
  knowledgeBaseNames: ['projects/my-project-id/knowledgeBases/my-knowledge-base-name'],
},

};

当我在dialogflow控制台中测试FAQ时,它可以工作,但是当我尝试使用 Dialoglflow Nodejs SDK ,dialogflow响应中的 knowledgeAnswers 对象为空。

When I test the FAQ in dialogflow console it works, but when I try to do the same with Dialoglflow Nodejs SDK, the knowledgeAnswers object from dialogflow response is null.

我们将提供任何帮助。谢谢

Any help is appreciated. Thanks

推荐答案

这是由于 knowledgeBaseNames 属性中的值不正确而发生的。
创建知识库时,它返回以下响应:

This is happening because of the incorrect value in knowledgeBaseNames property. When you create a knowledge base it returns below response:

{
  "name": "projects/project-id/knowledgeBases/NDA4MTM4NzE2MjMwNDUxMjAwMA",
  "displayName": "knowledge-base-display-name"
}

knowledgeBaseNames 属性接受 name 数组。它不同于 displayName

knowledgeBaseNames property accepts the array of name. It is different than displayName.

如果您创建了Konwledgebase表单Dialogflow仪表板,则在该仪表板中不会看到此详细信息。但是,Dialogflow SDK提供了API以获取代理的知识库列表。 Node js V2Beta1 SDK具有方法 projects.knowledgeBases.list ,当给定项目名称时,它将列出所有知识库以及它们的显示名称和名称。您可以将名称列表发送到检测意图请求中。

In case you have created the Konwledgebase form Dialogflow dashboard, you won't see this detail in the dashboard. However, Dialogflow SDKs Provide APIs to get the list of knowledgebase of an agent. Node js V2Beta1 SDK has a method projects.knowledgeBases.list, which, when given a project name, will list all of the knowledge bases along with their display name and their name. You can send the list of names into the detect intent request.

如果您的用例只需要知道知识库的ID,则可以从Dialogflow控制台的试用部分获得if。输入您在知识库中添加的问题,然后单击诊断信息。它将以JSON显示dialogflow响应。查找 knowledgeAnswers 对象。知识库ID是 source 属性的一部分,如下所述:

If your use case only requires knowing the ID for the knowledge base then you can get if from "Try it out" section of the Dialogflow console. Type a question you have added in knowledgebase and click on diagnostic info. It will show the dialogflow response in JSON. Look for the knowledgeAnswers object. The knowledgebase ID is the part of source property as mentioned below:

"knowledgeAnswers": {
            "answers": [{
                "source": "projects/project-id/knowledgeBases/knowledgebase-id/documents/document-id"
            }]
}

这篇关于为什么Dialogflow Node.js SDK会“检测知识库的意图”?方法以null响应? (V2Beta)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆