Created
July 25, 2019 20:25
-
-
Save leoaiassistant/5b9142be72407f2ef5a09c95c4be9362 to your computer and use it in GitHub Desktop.
Función para ejecutar respuestas matemáticas como la sumatoria, promedio, división, multiplicaión, entre otras a través de node.js para Actions on google & Dialogflow
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
function facturar (agent) { | |
let numerotickets = agent.parameters.ordentickets; | |
const precio = 20; | |
for (let i = 0; i < agent.parameters.ordentickets.lenght; i++) | |
{ | |
numerotickets += agent.parameters.ordentickets[1].number; | |
} | |
let total = precio * numerotickets; | |
let frase ="Tu cuenta es de "+total+" dolares. Vuelo confirmado"; | |
agent.add(frase); | |
} | |
// Run the proper function handler based on the matched Dialogflow intent name | |
let intentMap = new Map(); | |
intentMap.set('Default Welcome Intent', welcome); | |
intentMap.set('Default Fallback Intent', fallback); | |
intentMap.set('calcular.totalcuenta', facturar); | |
// intentMap.set('your intent name here', yourFunctionHandler); | |
// intentMap.set('your intent name here', googleAssistantHandler); | |
agent.handleRequest(intentMap); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment