Skip to content

Instantly share code, notes, and snippets.

@axleweb-technologies
Created September 27, 2020 00:58
Show Gist options
  • Save axleweb-technologies/de817e280068465bb4d7d3a27d38878b to your computer and use it in GitHub Desktop.
Save axleweb-technologies/de817e280068465bb4d7d3a27d38878b to your computer and use it in GitHub Desktop.
Code snippet to deploy your Dialogflow fulfillment on Heroku
const express = require('express')
const bodyParser = require('body-parser')
const {WebhookClient} = require('dialogflow-fulfillment');
const app = express()
app.use(bodyParser.json())
const port = process.env.PORT || 3000
app.post('/dialogflow-fulfillment', (request, response) => {
dialogflowFulfillment(request, response)
})
app.listen(port, () => {
console.log(`Listening on port ${port}`)
})
const dialogflowFulfillment = (request, response) => {
const agent = new WebhookClient({request, response})
function sayHello(agent){
agent.add("Hello, this was a nice tutorial by axlewebtech")
}
let intentMap = new Map();
intentMap.set("Default Welcome Intent", sayHello)
agent.handleRequest(intentMap)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment