Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A Quick Example of How to setup intents for API.AI intents
'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