This Gist was automatically created by Carbide, a free online programming environment.
Created
November 10, 2021 22:13
-
-
Save carbide-public/37237905f8c8ac0242448551bc33f010 to your computer and use it in GitHub Desktop.
untitled
This file contains 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
"use strict"; | |
const functions = require("firebase-functions"); | |
const { WebhookClient } = require("dialogflow-fulfillment"); | |
const { Card, Suggestion } = require("dialogflow-fulfillment"); | |
const axios = require('axios'); | |
const fetch = require('node-fetch'); | |
process.env.DEBUG = "dialogflow:debug"; // enables lib debugging statements | |
export default (request, response) => { | |
const agent = new WebhookClient({ request, response }); | |
function ApiNet(agent) { | |
let NOMBRE = agent.parameters["nombre"]; | |
let TELEFONO = agent.parameters["telefono"]; | |
agent.add( | |
//"Tu cita fue registrado correctamente :"+" Los valores son :"+NOMBRE+" , "+FECHA+ " , "+ ESPECIALIDAD | |
//"Los valores son :"+JSON.stringify(todo) | |
"Los valores son :"+NOMBRE + " "+TELEFONO | |
); | |
} | |
async function consultarTramite(agent) { | |
let NroSeguimiento = agent.parameters["NroSeguimiento"]; | |
let respuesta = await axios.get( | |
"https://sheet.best/api/sheets/40f72ec2-a709-4e90-bac5-be276b0e0e30/NroSeguimiento/" + | |
NroSeguimiento | |
); | |
let tramites = respuesta.data; | |
if (tramites.length > 0) { | |
let tramite = tramites[0]; | |
agent.add("El estado del trámite: " + tramite.Estado); | |
} else { | |
agent.add("El número de seguimiento proporcionado no existe"); | |
} | |
} | |
let intentMap = new Map(); | |
intentMap.set("ApiNet", ApiNet); | |
intentMap.set("Tramites.consultar", consultarTramite); | |
agent.handleRequest(intentMap); | |
} | |
//); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment