簡體   English   中英

如何在dialogflow-fulfillment中創建表格

[英]How to create table in dialogflow-fulfillment

在 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 創建表格?

實際上,就我而言,我使用的是 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 這樣做嗎?

從庫的源代碼來看,里面似乎還沒有提供Table

通過查看來源,我可以說它提供

  • 文本
  • 圖片
  • 建議籌碼(快速回復)

即使我們查看 src 文件夾,它也沒有與Table相關的任何內容

在此處輸入圖片說明

也許是吧。 這取決於您希望該表在何處工作。

Dialogflow 集成一般沒有表定義。 因此,您無法創建可用於 Facebook 集成的表。

但是,如果您想為 Actions on Google 創建一個表,您可以這樣做。 而不是試圖將其添加到您的agent對象,你可以得到一個conv使用對象agent.getConv()並以此來增加一個表conv.add()

我沒有測試過這個,但它可能是這樣的:

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 庫在 Google 對象上使用 Actions。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM