无法在Android中获取Dialogflow实现内联编辑器响应

时间:2018-07-18 12:37:23

标签: android dialogflow

我正在将一个android chat应用程序与Dialogflow集成在一起。集成部分已成功完成,我能够在android中显示特定查询的默认文本响应。

但是当我尝试Inline Editor Fulilment时,Inline Editor Fulfillment的响应未在android中显示。我想在Android中显示Inline编辑器的响应。

我已在Intent中启用了实现功能,并尝试通过删除默认的文字回复来进行尝试,但仍然无法正常工作。

我使用了方法     result.getFulfillment().getSpeech() 用于显示来自dialogflow的响应,它适用于来自意图的默认响应。还有其他方法可以显示来自Inline Editor Fulfilment的响应。

我只想显示从内联编辑器实现 Android 的简单响应。

在下面添加内联编辑器代码

  // See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
  // for Dialogflow fulfillment library docs, samples, and to report issues
  'use strict';

  const functions = require('firebase-functions');
  const {WebhookClient} = require('dialogflow-fulfillment');
  const {Card, Suggestion} = require('dialogflow-fulfillment');

  process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements

  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));

      function welcome(agent) {
        agent.add(`Welcome to Chess Master How can I assist you! `);
      }

      function fallback(agent) {
        agent.add(`I didn't understand`);
        agent.add(`I'm sorry, can you try again?`);
      }
      function RuyLopez(agent) {
        agent.add(`For Ruy Lopez, Please visit https://en.wikipedia.org/wiki/Ruy_Lopez`);
        agent.add(new Card({
            title: `Ruy Lopez`,

            imageUrl:
              'https://store.chessclub.com/media/catalog/product/cache/1/image/9df78eab    3 3525d08d6e5fb8d27136e95/r/u/ruy-lopez-store-large-no-sale_1.jpg',
            text: `Please vist \n https://en.wikipedia.org/wiki/Ruy_Lopez`,
            buttonText: 'Visit Website',
            buttonUrl: 'https://en.wikipedia.org/wiki/Ruy_Lopez'
          })
        );
        //agent.add(new Suggestion(`Quick Reply`));
        //agent.add(new Suggestion(`Suggestion`));
        //agent.setContext({ name: 'weather', lifespan: 2, parameters: { city:'Rome' }});
      }

      let intentMap = new Map();
      intentMap.set('Default Welcome Intent', welcome);
      intentMap.set('Default Fallback Intent', fallback);
      intentMap.set('Ruy Lopez', RuyLopez);
      // intentMap.set('your intent name here', googleAssistantHandler);
      agent.handleRequest(intentMap);
    });

谢谢

0 个答案:

没有答案