Last active
April 26, 2024 09:05
-
-
Save antonyharfield/b76f0556d7e696ba981005a78a8253ec to your computer and use it in GitHub Desktop.
A fulfillment web hook for Dialogflow supporting local dev and Firebase Cloud Functions
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) | |
}) | |
module.exports = app |
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 functions = require('firebase-functions') | |
const app = require('./app') | |
exports.app = functions.https.onRequest(app) |
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 app = require('./app') | |
app.listen(process.env.PORT || 8080) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment