Created
January 8, 2018 01:24
-
-
Save DazWilkin/a614ed9a6bfc07b4ff8f81d18bb75f2b to your computer and use it in GitHub Desktop.
First (Worst?) Google Assistant app
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
| /* jshint strict: true */ | |
| /* jshint esversion: 6 */ | |
| /* globals exports,require */ | |
| const ActionsSdkApp = require('actions-on-google').ActionsSdkApp; | |
| const greet = (intentName) => `Hi, I\'m a silly app. This is the ${intentName} intent. You can ask me something`; | |
| const | |
| intent = { | |
| main: (app) => { | |
| console.log(`[intentMain] Enter`); | |
| let inputPrompt = app.buildInputPrompt(false, greet("Main")); | |
| app.ask(inputPrompt); | |
| console.log(`[intentMain] Exits`); | |
| }, | |
| daz: (app) => { | |
| console.log(`[intentDaz] Enter`); | |
| let inputPrompt = app.buildInputPrompt(false, greet("Daz")); | |
| app.ask(inputPrompt); | |
| console.log(`[intentDaz] Exits`); | |
| }, | |
| henry: (app) => { | |
| console.log(`[intentHenry] Enter`); | |
| let inputPrompt = app.buildInputPrompt(false, greet("Henry")); | |
| app.ask(inputPrompt); | |
| console.log(`[intentHenry] Exits`); | |
| }, | |
| text: (app) => { | |
| console.log(`[intentText] Enter`); | |
| let inputPrompt = app.buildInputPrompt(false, greet("Text")); | |
| app.ask(inputPrompt); | |
| console.log(`[intentText] Exits`); | |
| }, | |
| respond: (app) => { | |
| console.log(`[respond] Enter`); | |
| console.log(`[respond] Exits`); | |
| }, | |
| }; | |
| exports.silly = (req, res) => { | |
| console.log(`[main] Enter`); | |
| const app = new ActionsSdkApp({request: req, response: res}); | |
| let actionMap = new Map(); | |
| actionMap.set(app.StandardIntents.MAIN, intent.main); | |
| actionMap.set(app.StandardIntents.DO, intent.daz); | |
| actionMap.set(app.StandardIntents.HENRY, intent.henry); | |
| actionMap.set(app.StandardIntents.TEXT, intent.text); | |
| app.handleRequest(actionMap); | |
| console.log(`[main] Exits`); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment