Created
August 2, 2017 21:40
-
-
Save acucciniello/faff332c5c401402d698ca5fd2af9dba to your computer and use it in GitHub Desktop.
A Quick Example of How to setup intents for API.AI intents
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
'use strict'; | |
process.env.DEBUG = 'actions-on-google:*'; | |
const App = require('actions-on-google').ApiAiApp; | |
const functions = require('firebase-functions'); | |
// [START YourAction] | |
exports.yourAction = functions.https.onRequest((request, response) => { | |
const app = new App({request, response}); | |
console.log('Request headers: ' + JSON.stringify(request.headers)); | |
console.log('Request body: ' + JSON.stringify(request.body)); | |
// Fulfill action business logic | |
function responseHandler (app) { | |
// Complete your fulfillment logic and send a response | |
app.ask('Welcome to your action. What would you like to do next? You can say 'test' or 'time'.); | |
} | |
function testIntent (app) { | |
app.tell('test'); | |
} | |
function timeIntent (app) { | |
app.tell('time'); | |
} | |
const actionMap = new Map(); | |
actionMap.set('input.welcome', responseHandler); | |
actionMap.set('test', testIntent); | |
actionMap.set('time', timeIntent); | |
app.handleRequest(actionMap); | |
}); | |
// [END YourAction] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment