Skip to content

Instantly share code, notes, and snippets.

@DavidMellul
Last active April 18, 2018 00:13
Show Gist options
  • Select an option

  • Save DavidMellul/eb4ad9341d8c1e27f79e8364ae87f484 to your computer and use it in GitHub Desktop.

Select an option

Save DavidMellul/eb4ad9341d8c1e27f79e8364ae87f484 to your computer and use it in GitHub Desktop.
// Dependencies
const express = require('express');
const bodyparser = require('body-parser');
// Configuration
const app = express();
app.use(bodyparser.json());
// Webhook route
app.post('/webhook', (req, res) => {
const data = req.body;
// Code the task you want to achieve with @data
// Read the v2 api documentation of dialogflow : https://dialogflow.com/docs/fulfillment
// Using the v2 will become mandatory, Google wrote a guide to migrate from v1 to v2 as v2 is officially released
const response = {
fulfillmentText: "Your webhook works fine !",
}
res.json(response);
});
// Logic for running your server with HTTPS here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment