0

Want to set up the webhook on my pc and not on google cloud project like the guide is sugesting, and I'm not quite sure how to.

This is the guide: https://dialogflow.com/docs/getting-started/basic-fulfillment-conversation

It says to create a index.js with the following code in it

/*
* HTTP Cloud Function.
*
* @param {Object} req Cloud Function request context.
* @param {Object} res Cloud Function response context.
*/

exports.helloHttp = function helloHttp (req, res) {
response = "This is a sample response from your webhook!"
//Default response from the webhook to show it's working


res.setHeader('Content-Type', 'application/json');
//Requires application/json MIME type

res.send(JSON.stringify({ "speech": response, "displayText": response 
//"speech" is the spoken version of the response, "displayText" is the visual version
}));
};

Never seen exports. before. The guide wants me to do something with 'google functions' and make one called hellohttp or something. Trying to figure out how to do it without google cloud projects.

I installed Node.js and created that file. I set the webhook url to https://my_ip/index.js but doesn't work. Not really sure what to do

this is the JSON I get

{
  "id": "9c244834-3ee9-4291-98fd-aab8e975fb1f",
  "timestamp": "2018-02-22T23:11:34.067Z",
  "lang": "en",
  "result": {
    "source": "agent",
    "resolvedQuery": "weather TOMORROW in VIRGINIA",
    "action": "",
    "actionIncomplete": false,
    "parameters": {
      "date": "2018-02-24",
      "geo-city": "Virginia"
    },
    "contexts": [],
    "metadata": {
      "intentId": "44486050-dfd5-4c35-bcbf-4e168379df28",
      "webhookUsed": "true",
      "webhookForSlotFillingUsed": "false",
      "webhookResponseTime": 5006,
      "intentName": "Weather"
    },
    "fulfillment": {
      "speech": "I don't know about the weather for 2018-02-24 in Virginia. Sorry!",
      "messages": [
        {
          "type": 0,
          "speech": "I don't know about the weather for 2018-02-24 in Virginia. Sorry!"
        }
      ]
    },
    "score": 1
  },
  "status": {
    "code": 206,
    "errorType": "partial_content",
    "errorDetails": "Webhook call failed. Error: Webhook response was empty.",
    "webhookTimedOut": false
  },
  "sessionId": "9cdbd5bc-403e-4840-8970-e420f27d23e2"
}
user1021085
  • 729
  • 3
  • 10
  • 28
  • That code won't work as-is in a local node.js installation. Not sure what you expected from a guide that's explicitly for the Google Cloud environment. –  Feb 23 '18 at 14:34
  • I expected to find a way to make it work on a local node.js even if that meant asking for help on what adjustments to make. I'm aware that it won't work as is, hence me asking for help. – user1021085 Feb 23 '18 at 14:39
  • This sounds like a prime [XY problem](http://xyproblem.info/). Can you tell us what your actual goal is? –  Feb 23 '18 at 15:48
  • To run the bot on my pc. Preferably in a somewhat similar way to how the code would look on Google cloud projects that I can easily change the code to be hosted there in the future – user1021085 Feb 23 '18 at 16:22
  • It sounds like you want to run a nodejs webserver on your computer and access it from outside. That requires setting up port forwarding in your router. –  Feb 23 '18 at 16:44
  • This is due a belief that there only needs to be a smaller change made for it to work, some line or lines that will allow my computer to receive the request from people using the bot on kik and respond accordingly; that I can follow the guide on dialogflow more or less to learn more concepts (current concept being a weather bot). The reason for not wanting to immediately go to GCP is that I don't want to rely on a paid hosting service(I know the first year or so is free) and because I don't want what to me feels like a one click magical solution but instead want to understand how it works. – user1021085 Feb 23 '18 at 16:46
  • I have port forwarded ports 80 and 443 (since the webhook has be https) – user1021085 Feb 23 '18 at 16:47
  • Ok, so the goal for now should be to set up a basic node server. I recommend using express for that. The code you have, your `index.js`, is only a small part of that. Start with this: http://expressjs.com/en/starter/hello-world.html (you'll have to forward port 80 to 3000). Also, https won't work for a local installation like that; it requires a domain. Stick to http/80 for now. –  Feb 23 '18 at 17:14

0 Answers0