user3872094
user3872094

Reputation: 3351

Dialogflow is not giving the proper response

I am trying to get a response from firebase function in dialogflow. when I've enabled the webhook and invoking the agent, I'm getting an error as

enter image description here

and here is my code

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

});

Here is the log output in firebase.

enter image description here

Please let me know where am I going wrong and how can I fix it.

Thanks

Upvotes: 0

Views: 498

Answers (2)

Ali Nem
Ali Nem

Reputation: 5550

The error you're getting has nothing to do with billing. The log you have shown is not complete but from your code I can spot the following issues:

  • The name of your function must be dialogflowFirebaseFulfillment to work with dialogflow.

  • Your const app = dialogflow({ debug: true }); must move out of the exports block to somewhere before it.

If there are still issues, please update your question with the complete error log.

Upvotes: 1

Rémi C.
Rémi C.

Reputation: 339

You first error is saying that your billing account is not configured: this will block all external calls in your code. You can first try activating billing in Google Console > Navigation Menu > Billing > Enable Billing.

Upvotes: 1

Related Questions