【问题标题】:How to create table in dialogflow-fulfillment如何在 dialogflow-fulfillment 中创建表
【发布时间】:2019-07-10 06:57:29
【问题描述】:

在 actions-on-google 我们可以添加如下表格:

const {dialogflow, Table} = require('actions-on-google');
const request = require('request');
const conv = new DialogflowConversation(request);
conv.ask('This is a simple table example.');
conv.ask(new Table({
     dividers: true,
    columns: ['header 1', 'header 2', 'header 3'],
     rows: [
         ['row 1 item 1', 'row 1 item 2', 'row 1 item 3'],
         ['row 2 item 1', 'row 2 item 2', 'row 2 item 3'],
     ],
}));

如何使用 dialogflow-fulfillment 创建表格??

实际上,就我而言,我使用的是对话流实现。 并且我想像这样使用:

agent.add(new Table({
     dividers: true,
     columns: ['header 1', 'header 2', 'header 3'],
     rows: [
       ['row 1 item 1', 'row 1 item 2', 'row 1 item 3'],
       ['row 2 item 1', 'row 2 item 2', 'row 2 item 3'],
     ],
 }));

我可以使用 dialogflow-fulfillment 做到这一点吗?

【问题讨论】:

    标签: dialogflow-es actions-on-google dialogflow-es-fulfillment


    【解决方案1】:

    从库的源代码来看,其中似乎还没有提供Table

    通过查看source,我可以说它正在提供

    • 文字
    • 卡片
    • 图片
    • 建议芯片(快速回复)

    即使我们查看 src 文件夹,它也没有与 Table 相关的任何内容

    【讨论】:

      【解决方案2】:

      也许,是的。这取决于您期望该表在哪里工作。

      Dialogflow 集成通常没有表定义。因此,您无法创建适用于 Facebook 集成的表。

      但是,如果您想为 Actions on Google 创建一个表格,您可以这样做。您可以使用agent.getConv() 获取conv 对象,并使用它来添加带有conv.add() 的表,而不是尝试将其添加到您的agent 对象中。

      我还没有测试过,但可能是这样的:

      const { WebhookClient } = require('dialogflow-fulfillment');
      const { Table } = require('actions-on-google');
      
      exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
        const agent = new WebhookClient({ request, response });
      
        function assistantTableHandler(agent) {
          let conv = agent.conv(); // Get Actions on Google library conversation object
          conv.ask('Please choose an item:'); // Use Actions on Google library to add responses
          conv.ask(new Table({
           dividers: true,
           columns: ['header 1', 'header 2', 'header 3'],
           rows: [
             ['row 1 item 1', 'row 1 item 2', 'row 1 item 3'],
             ['row 2 item 1', 'row 2 item 2', 'row 2 item 3'],
           ],
          }));
        };
      
      // Add handler registration, etc
      
      }
      

      您可以通过 dialogflow-fulfillment 库see a more complete example 了解如何使用 Actions on Google 对象。

      【讨论】:

      • 是否可以在嵌入网络的对话流中使用表格和 corousel ??
      • 没有。这些响应类型仅适用于 Google 助理。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多