Skip to content

Instantly share code, notes, and snippets.

@acucciniello
Created August 2, 2017 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acucciniello/faff332c5c401402d698ca5fd2af9dba to your computer and use it in GitHub Desktop.
Save acucciniello/faff332c5c401402d698ca5fd2af9dba to your computer and use it in GitHub Desktop.
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