Last active
December 29, 2018 03:14
-
-
Save antonyharfield/66f3a403b0fbd7fd490fc615d190dc0c to your computer and use it in GitHub Desktop.
A simple fulfillment web hook for Dialogflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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