Untitled
plain_text
a month ago
1.0 kB
6
Indexable
Never
'use strict'; const { WebhookClient } = require('dialogflow-fulfillment'); exports.handler = (req, res) => { const agent = new WebhookClient({ request: req, response: res }); // Dialogflow agent console.log('Dialogflow Request headers: ' + JSON.stringify(req.headers)); // testing console.log('Dialogflow Request body: ' + JSON.stringify(req.body)); // testing // Default welcome intent function welcome(agent) { agent.add('Welcome to my chatbot!'); } // Default fallback intent function fallback(agent) { agent.add('Sorry, I don\'t understand.'); } // Default conversation end function endConversation(agent) { agent.add('Thank you and have a nice day!'); } let intentMap = new Map(); intentMap.set('Default Welcome Intent', welcome); intentMap.set('Default Fallback Intent', fallback); intentMap.set('End Conversation', endConversation); agent.handleRequest(intentMap); }; // expor