Dialogflow es 向DialogFlow中的知识库添加其他链接

Dialogflow es 向DialogFlow中的知识库添加其他链接,dialogflow-es,Dialogflow Es,通过DialogFlow中的知识库,您可以上传基本的FAQ。第一栏是问题,第二栏是答案。通常我们需要让答案提供一个额外的链接。e、 “你的问题的答案是否定的,菠萝不适合比萨饼。” 我想提供的是答案,然后是一个丰富的响应链接。既然电子表格中不能有第三列来添加链接,我该如何干净地添加链接?当然,我可以把这个链接作为答案文本的一部分,但这并没有那么漂亮 我可以复制这个问题,然后提供一个链接作为第二个答案(即$Knowledge.answer(2)),但是有些答案没有链接,我不能将此设置为条件 我假设我

通过DialogFlow中的知识库,您可以上传基本的FAQ。第一栏是问题,第二栏是答案。通常我们需要让答案提供一个额外的链接。e、 “你的问题的答案是否定的,菠萝不适合比萨饼。”

我想提供的是答案,然后是一个丰富的响应链接。既然电子表格中不能有第三列来添加链接,我该如何干净地添加链接?当然,我可以把这个链接作为答案文本的一部分,但这并没有那么漂亮

我可以复制这个问题,然后提供一个链接作为第二个答案(即$Knowledge.answer(2)),但是有些答案没有链接,我不能将此设置为条件


我假设我可以实现这一点,但我不确定实际的代码是否可以返回答案($Knowledge.answer(1)),然后有条件地添加一个带有链接的丰富响应。

我最终解决了这个问题

首先,我在我的答案中使用了一些分隔符(这里只是'Z$Z')

例如,在csv文件中,我将以下内容放在第二列:

你的问题的答案是否定的,菠萝不上比萨饼$Z$More Info$Z$https://www.mashed.com/183299/the-most-controversial-pizza-toppings-explained/

这样,当我得到满足时,我就可以解析答案了。 下面是代码的一部分:

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
  console.log('Dialogflow Request body: ' + JSON.stringify(request.body));

  // save off the answer to parse
  let answer = JSON.stringify(request.body.queryResult.fulfillmentText);   
  
  function faqHandler(agent) {
    let answerAlt = answer.slice(1,-1); // remove first and last double quote
    let answerParse = answerAlt.split("Z$Z"); // parse the answer
    if( answerParse.length == 1) {
      // no links
      agent.add(answerParse[0].toString());
    } else {
      // display the content with the text and links
      // you can use different ways here to display but you have access to
      // the answer, title, and url as follows
      // answerParse[0].toString(), answerParse[1].toString(), answerParse[1].toString()
    }
  }
  ...
  intentMap.set('Knowledge.KnowledgeBase.ID_OF_KNOWLEDGEBASE',faqHandler);