Last active
April 21, 2017 14:54
-
-
Save apkelly/037e96defab192e3e2fa7a04e8626c5e to your computer and use it in GitHub Desktop.
Cloud Function for ChicagoRoboto talk.
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
'use strict'; | |
process.env.DEBUG = 'actions-on-google:*'; | |
const Assistant = require('actions-on-google').ApiAiAssistant; | |
exports.myAction = (req, res) => { | |
const assistant = new Assistant({request: req, response: res}); | |
console.log('Request headers: ' + JSON.stringify(req.headers)); | |
console.log('Request body: ' + JSON.stringify(req.body)); | |
// Fulfill action business logic | |
function responseHandler (assistant) { | |
// Complete your fulfillment logic and send a response | |
assistant.ask('Im sorry to hear that your ' + assistant.getArgument('body-parts') + ' hurts. Does anything else hurt?', ['I didnt hear you', 'What else is causing you pain', 'I guess this concludes our consultation']); | |
} | |
const actionMap = new Map(); | |
actionMap.set('describe-symptoms', responseHandler); | |
assistant.handleRequest(actionMap); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Learn more about the ApiAiAssistant class here https://developers.google.com/actions/reference/ApiAiAssistant
The webhook request/response format is described here https://developers.google.com/actions/reference/webhook-format