From 45cbb97fc2be7c8ae00431ba7005fa167fdc2316 Mon Sep 17 00:00:00 2001 From: Victor Sanchez Date: Tue, 8 Jun 2021 17:04:52 -0500 Subject: [PATCH] hh --- funtions.js | 3 ++- index.js | 20 +++++++++++++++++++- interacciones.js | 8 +++++++- metodos.js | 31 +++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/funtions.js b/funtions.js index fd63248..6aea858 100644 --- a/funtions.js +++ b/funtions.js @@ -1,6 +1,7 @@ const { error } = require('actions-on-google/dist/common'); const axios= require('axios'); -const URLPC = 'http://mantaentusmanos.test/'; +//const URLPC = 'http://mantaentusmanos.test/'; +const URLPC = 'https://portalciudadano.manta.gob.ec/'; const { WebhookClient } = require("dialogflow-fulfillment"); function conver_base64(data) { diff --git a/index.js b/index.js index f38684a..88f5ba3 100644 --- a/index.js +++ b/index.js @@ -60,6 +60,17 @@ app.post("/webhook", express.json(), function (req, res) { return metodos.Fun_ConsultarCCAtras(agent, req, res); } + + + //Validar documentos + function ValidarDocumentos(){ + return metodos.Fun_ValidarDocumentos(agent, req, res, 1); + } + function ValidarCodigobarras(){ + return metodos.Fun_ValidarDocumentos(agent, req, res, 2); + } + + let intentMap = new Map(); //Menu 1 - principal @@ -83,12 +94,19 @@ app.post("/webhook", express.json(), function (req, res) { intentMap.set('0 - Bienvenida - Cerrar sesion - SI', SiCerrarSesionAgent); intentMap.set('0 - Bienvenida - Cerrar sesion - NO', NoCerrarSesionAgent); intentMap.set('0 - Bienvenida - Cerrar sesion - fallback', ConfirmarCerrarSesionAgent); + + + //Menu 1 - Validar Documentosany + intentMap.set('0 - Bienvenida - Validar Documentos', ValidarDocumentos); + intentMap.set('0 - Bienvenida - Validar Documentos - codigo', ValidarCodigobarras); + + agent.handleRequest(intentMap); }); -let port = 3000; +let port = 4000; app.listen(port, () => { console.log("Estamos ejecutando el servidor en el puerto " + port); }); \ No newline at end of file diff --git a/interacciones.js b/interacciones.js index 8443a5b..9e39ac1 100644 --- a/interacciones.js +++ b/interacciones.js @@ -16,6 +16,12 @@ function mensaje(name, username = null) { 'Ayudeme con el número el número de cédula del propietario(a)' ]; break; + case 'sol_data_codigo': + jsom_interaciones = [ + 'Por favor ingrese el código de barras del documento', + 'Ayudeme con el número el código de barras del documento' + ]; + break; case 'retorno_inicio': jsom_interaciones = [ '¿Hay algo mas en lo que le pueda ayudar?', @@ -51,7 +57,7 @@ function mensaje(name, username = null) { } break; case 'menu_1': - var menu = "\n1. Consultar predios \n0. Cerrar sessión"; + var menu = "\n1. Consultar predios \n2. Validar documentos digitales \n0. Cerrar sessión"; jsom_interaciones = [ 'Recuerde que puedo ayudarle en cosas como:\n' + menu, 'Puedo ayudarle ahora con:\n' + menu, diff --git a/metodos.js b/metodos.js index b74c0fe..d380598 100644 --- a/metodos.js +++ b/metodos.js @@ -199,6 +199,36 @@ async function Fun_ConsultarOtrasClavesCatastrales(agent, req, res, tipo){ } } + + + +async function Fun_ValidarDocumentos(agent, req, res, tipo){ + let data_context = await ValidateDataUserContext(agent); + if(data_context){ + if(tipo == 1){ + return agent.add(dialog.mensaje('sol_data_codigo')); + }else if(tipo == 2){ + var Contx = agent.context.get('context_codigo_barras'); + if (Contx == null || Contx == NaN || Contx == undefined){ Contx = ExistParamtContext(agent,'context_codigo_barras'); } + if (Contx != null && Contx != NaN && Contx != undefined){ + console.log(Contx); + if(Contx.parameters.codigo_barras != null && Contx.parameters.codigo_barras != "" ){ + console.log('esperando el codigo de barras '+Contx.parameters.codigo_barras); + return agent.add(Contx.parameters.codigo_barras); + //return Fun_ConsultarClavesCatastrales(agent, req, res, Contx.parameters.codigo_barras); + } + }else{ + return Fun_ListarMenu(agent, req, res); + // return Fun_ConfirmarConsultarClavesCatastrales(agent, req, res); + } + } + }else{ + return Fun_WelcomeAgent(agent, req, res); + } +} + + + async function Fun_ConsultarClavesCatastrales(agent, req, res, _cedula = null){ try { let data_context = await ValidateDataUserContext(agent); @@ -257,5 +287,6 @@ module.exports = { "Fun_ConsultaPredios": Fun_ConsultaPredios, "Fun_ConsultarCCAtras": Fun_ConsultarCCAtras, "Fun_ListarMenu": Fun_ListarMenu, + "Fun_ValidarDocumentos": Fun_ValidarDocumentos, "Fun_ConsultarClavesCatastrales": Fun_ConsultarClavesCatastrales } \ No newline at end of file