Skip to content

Instantly share code, notes, and snippets.

@antonyharfield
Last active December 29, 2018 03:14
Show Gist options
  • Save antonyharfield/66f3a403b0fbd7fd490fc615d190dc0c to your computer and use it in GitHub Desktop.
Save antonyharfield/66f3a403b0fbd7fd490fc615d190dc0c to your computer and use it in GitHub Desktop.
A simple fulfillment web hook for Dialogflow
const express = require('express')
const { WebhookClient } = require('dialogflow-fulfillment')
const app = express()
app.get('/', (req, res) => res.send('online'))
app.post('/dialogflow', express.json(), (req, res) => {
const agent = new WebhookClient({ request: req, response: res })
function welcome () {
agent.add('Welcome to my agent!')
}
let intentMap = new Map()
intentMap.set('Default Welcome Intent', welcome)
agent.handleRequest(intentMap)
})
app.listen(process.env.PORT || 8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment