无法在firebase中获得用户的输入

时间:2018-06-07 09:15:11

标签: firebase google-cloud-platform dialogflow

请找到我的index.js文件。我想得到用户的输入。在"默认欢迎意图"我无法使用"输入"来获取用户的输入。当我使用actionsdk时,我能够通过"输入"来获得用户的输入。但在对话流中,我无法得到它。它在谷歌评估中显示为"欢迎来到我的dialogFlow代理! [object Object]。"

对于"测试意图"我创建了一个实体@ sys.ordinal,参数名称为"序数",我没有得到任何值。请让我知道,如何解决这个问题。      请分享指南,找到对象请求,响应和转换中可用的方法和全局变量

import * as functions from 'firebase-functions';
import * as gApp from 'actions-on-google';
import { myService } from './services/myService';
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
import admin from 'firebase-admin';
const app = gApp.dialogflow({debug: true});

process.env.DEBUG = 'dialogflow:debug'; 

//exports.dialogflowSample = functions.https.onRequest((request, response) => 
//{


  app.intent('Default Welcome Intent',(conv,input) => {
    conv.ask(`Welcome to my dialogFlow agent! <say-as >${input}</say-as>.</speak>`);
    conv.data.question = 'question1';

  });


app.intent('Test Intent',(conv,params) => {
    let qNo:string  =   conv.data.question;
    conv.ask('<speak>Testing the application'
    +`<say-as >`+conv.params.ordinal+`</say-as>.</speak>`);
    conv.ask('<speak>Testing the application'+`<say-as >`+qNo+`</say-as>.</speak>`);
    });

  exports.dialogflowSample = functions.https.onRequest(app);
//});

1 个答案:

答案 0 :(得分:1)

您需要指定要提取的参数名称。在您的情况下,它是ordinal

app.intent('Default Welcome Intent', (conv, { original }) => {
  conv.ask(`Welcome to my dialogFlow agent! <say-as >${original}</say-as>.</speak>`);
  conv.data.question = 'question1';
});

Dialogflow Intent Handler的第二个参数是一个对象,它是参数值到参数值的映射。

你也可以像对象一样使用它。

app.intent('Default Welcome Intent', (conv, params) => {
  conv.ask(`Welcome to my dialogFlow agent! <say-as >${params.original}</say-as>.</speak>`);
  conv.data.question = 'question1';
});