// Copyright 2017, 2 Coffees 1 tea(m). | |
// Licensed under the Apache License, Version 2.0 (the 'License'); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an 'AS IS' BASIS, | |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
// See the License for the specific language governing permissions and | |
// limitations under the License. | |
'use strict'; | |
process.env.DEBUG = 'actions-on-google:*'; | |
// Importiamo Assistant per avere la magia di Google | |
const Assistant = require('actions-on-google').ApiAiAssistant; | |
// TODO: Dichiara alcune costanti con il | |
// nome delle actions aggiunte in Dialogflow | |
// Es. | |
// const ACTION_SPOILERS = 'spoiler_me'; | |
exports.dialogflowFirebaseFulfillment = (req, res) => { | |
// Creiamo una nuova istanza di Assistant | |
const assistant = new Assistant({request: req, response: res}); | |
// TODO: Aggiungi qui eventuali parametri | |
// che vuoi recuperare dalla API call | |
// Es. | |
// var serie = req.body.result.parameters['tvseries']; | |
// TODO: Aggiungi qui le funzioni con la logica dell'app | |
// che accettino assistant come parametro | |
// Es. | |
// function spoilerMe(assistant) { | |
// Fai qualcosa qui | |
// } | |
// TODO: Non dimenticare di usare l'Api | |
// assistant.tell(""); | |
// per far parlare Assistant | |
// Es. | |
// assistant.tell("Hello world!"); | |
// Associa le funzioni scritte prima con le azioni | |
// di Assistant | |
// Crea una nuova Map per associare ogni funzione | |
// alla stringa dell'action corrispondente in Dialogflow | |
const actionMap = new Map(); | |
// TODO: Associa funzioni alle Actions | |
// Es. | |
// actionMap.set(ACTION_SPOILERS, spoilerMe); | |
// Collega l'actionMap creata prima con | |
// l'istanza di Assistant | |
assistant.handleRequest(actionMap); | |
}; | |
// TODO: Fai il deploy su Firebase Functions o la console Dialogflow! | |
// Happy coding! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment