Dialogflow没有给出正确的响应

时间:2018-06-01 05:42:10

标签: firebase actions-on-google dialogflow

我试图在对话框流中获取firebase函数的响应。当我启用webhook并调用代理时,我收到错误

enter image description here

这是我的代码

const functions = require('firebase-functions');
const admin = require('firebase-admin');
const requst = require('request');
const {
    dialogflow,
    BasicCard,
    BrowseCarousel,
    BrowseCarouselItem,
    Button,
    Carousel,
    Image,
    LinkOutSuggestion,
    List,
    MediaObject,
    Suggestions,
    SimpleResponse,
} = require('actions-on-google');
const intentSuggestions = [
    'Basic Card',
    'Browse Carousel',
    'Carousel',
    'List',
    'Media',
    'Suggestions',
    'Table',
];
admin.initializeApp(functions.config().firebase);
var firestore = admin.firestore();
const randomize = require('randomatic');


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

    const app = dialogflow({ debug: true });
    app.intent('Default Welcome Intent', (conv) => {
        conv.ask(new SimpleResponse({
            speech: 'Hi there!',
            text: 'Hello there!',
        }));
        conv.ask(new SimpleResponse({
            speech: 'I can show you basic cards, lists and carousels ' +
                'as well as suggestions on your phone.',
            text: 'I can show you basic cards, lists and carousels as ' +
                'well as suggestions.',
        }));
        conv.ask(new Suggestions(intentSuggestions));
    });

});

这是firebase中的日志输出。

enter image description here

请让我知道我哪里出错了,我该怎么办呢。

由于

2 个答案:

答案 0 :(得分:1)

您首先错误地说未配置您的结算帐户:这将阻止代码中的所有外部呼叫。 您可以先在Google控制台中尝试激活结算>导航菜单>结算>启用结算。

答案 1 :(得分:1)

您遇到的错误与计费无关。您显示的日志尚不完整,但是从您的代码中,我可以发现以下问题:

  • 函数名称必须为dialogflowFirebaseFulfillment才能使用dialogflow。

  • 您的const app = dialogflow({ debug: true });必须从exports块移到它之前的某个位置。

如果仍然存在问题,请使用完整的错误日志更新您的问题。