0

We are creating an action that will take user's input and create an entity in our database (datastore).

Ideally, we would like to be able to access the user's raw input audio, but it doesn't seem that is possible.

As a work around we are going to send the speech-to-text of user's utterance to our backend services. We are using firebase cloud functions for our fulfillment and an external rest api for our crud operations.

We are trying to make a post request in a webhook to create an entity based on user's input, but when I check my logs it doesn't seem like the post request is reaching our service. I'm not able to debug what or if we are getting a response back

app.intent('favorite color', (conv, {color}) => {

    const options = {
        // options
    };

    function callback(error, response, body) {
        // log response or error
    }

    request(options, callback);

    const luckyNumber = color.length;
    // Respond with the user's lucky number and end the conversation.
    conv.close('This word has ' + luckyNumber + ' letters.');
});

// Set the DialogflowApp object to handle the HTTPS POST request.
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);

This question is not the same as the one that it was marked as a duplicate because the solution was the account type not supporting POST requests to an external API and not the HTTP Client we were using

islalobo
  • 617
  • 2
  • 8
  • 22
  • Are you using firebase cloud functions for your fulfillment and an external rest api for your crud operations? – Yüksel Tolun Feb 20 '19 at 18:45
  • Yes, our fulfillment webhook url is taken from our firebase console. The post request we are trying to make is to an external rest api – islalobo Feb 20 '19 at 18:57
  • Is there a different way that we should approach doing this? I have been looking around at what other have done and looking at some sample action on google code – islalobo Feb 20 '19 at 18:58
  • Edit your question to state this and I'll answer below. – Yüksel Tolun Feb 20 '19 at 18:59

1 Answers1

0

The Inline Editor in the Dialogflow console uses Firebase Cloud Functions, as you already know.

Unfortunately, Firebase Cloud Functions DOESN'T support external API calls in it's free plan. You may need to switch to blaze plan or deploy your fulfillment elsewhere.

Yüksel Tolun
  • 336
  • 1
  • 6
  • I'm not using the inline editor. We're using a webhook. Does that make a difference or is what you say still applicable? – islalobo Feb 20 '19 at 19:04
  • It's still applicable, I've added that detail for other people who might encounter the same problem in the future. But I guess I violated the cooperative principle (https://designguidelines.withgoogle.com/conversation/conversation-design/learn-about-conversation.html) of our conversation :) – Yüksel Tolun Feb 20 '19 at 19:07
  • Heheh! We'll let it slide ;) I was able to update to a Blaze account, but I'm still not able to successfully make a POST request in my index.js Also, I can't see if there is any response or error information received when I try to make this request. What is the proper way to console.log and see debugging information when building fulfillment locally with webhooks? – islalobo Feb 20 '19 at 19:18
  • @islalobo console.log should work fine, you would see the result in firebase console. Aren't you? – Yüksel Tolun Feb 20 '19 at 19:26
  • I am! I just figured that out and was coming back to update my comment. Also the call is working now, it's just an error on the jwt we're sending with it – islalobo Feb 20 '19 at 19:39
  • Glad all is well now :) have fun developing for AoG! – Yüksel Tolun Feb 20 '19 at 19:43