Created
September 27, 2020 00:58
-
-
Save axleweb-technologies/de817e280068465bb4d7d3a27d38878b to your computer and use it in GitHub Desktop.
Code snippet to deploy your Dialogflow fulfillment on Heroku
This file contains hidden or 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 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