_
This commit is contained in:
parent
7650f17c01
commit
64baee1a7c
30
funtions.js
30
funtions.js
@ -188,6 +188,35 @@ async function ConsultaClaves(cedula, chang = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
async function ConsultaTasaRecoleccion(cedula, index) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const array = { ok: false, data: [], msg: null };
|
||||||
|
try {
|
||||||
|
const data = fs.readFileSync('trb.json', 'utf8');
|
||||||
|
const json = JSON.parse(data);
|
||||||
|
if (!Array.isArray(json)) {
|
||||||
|
array.msg = 'El JSON no es un arreglo';
|
||||||
|
return resolve(array);
|
||||||
|
}
|
||||||
|
const response = json.find(
|
||||||
|
item => String(item.documento).trim() === String(cedula).trim()
|
||||||
|
);
|
||||||
|
if (response) {
|
||||||
|
array.ok = true;
|
||||||
|
array.data = response;
|
||||||
|
array.msg = 'Consulta exitosa';
|
||||||
|
} else {
|
||||||
|
array.msg = 'No se encontraron valores disponibles';
|
||||||
|
}
|
||||||
|
resolve(array);
|
||||||
|
} catch (error) {
|
||||||
|
array.msg = error.message;
|
||||||
|
resolve(array);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function ConsultaComprobantes(cedula, index) {
|
async function ConsultaComprobantes(cedula, index) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var array = { 'ok': false, 'data': [], 'msg': null };
|
var array = { 'ok': false, 'data': [], 'msg': null };
|
||||||
@ -295,6 +324,7 @@ module.exports = {
|
|||||||
"conver_capitalice": conver_capitalice,
|
"conver_capitalice": conver_capitalice,
|
||||||
"ValidarComprobante": ValidarComprobante,
|
"ValidarComprobante": ValidarComprobante,
|
||||||
"ConsultaComprobantes": ConsultaComprobantes,
|
"ConsultaComprobantes": ConsultaComprobantes,
|
||||||
|
"ConsultaTasaRecoleccion": ConsultaTasaRecoleccion,
|
||||||
"OptInfoBot": OptInfoBot,
|
"OptInfoBot": OptInfoBot,
|
||||||
"ConsultaNoticias": ConsultaNoticias,
|
"ConsultaNoticias": ConsultaNoticias,
|
||||||
"GetMisTramites": GetMisTramites,
|
"GetMisTramites": GetMisTramites,
|
||||||
|
|||||||
9
index.js
9
index.js
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
// https://chatboot.manta.gob.ec/webhook
|
||||||
var funcion = require("./funtions.js");
|
var funcion = require("./funtions.js");
|
||||||
var metodos = require("./metodos.js");
|
var metodos = require("./metodos.js");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
@ -131,6 +133,10 @@ app.post("/webhook", express.json(), function (req, res) {
|
|||||||
return metodos.Func_InformacionTramites(agent, req, res, tramer[1]);
|
return metodos.Func_InformacionTramites(agent, req, res, tramer[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********** TRB **********/
|
||||||
|
function TasaRecoleccionBasura(){
|
||||||
|
return metodos.Func_MiTasaRecoleccionBasura(agent, req, res);
|
||||||
|
}
|
||||||
|
|
||||||
let intentMap = new Map();
|
let intentMap = new Map();
|
||||||
|
|
||||||
@ -177,6 +183,9 @@ app.post("/webhook", express.json(), function (req, res) {
|
|||||||
intentMap.set('0 - Bienvenida - Mis Tramites - fallback', MistramitesFallback);
|
intentMap.set('0 - Bienvenida - Mis Tramites - fallback', MistramitesFallback);
|
||||||
intentMap.set('0 - Bienvenida - Mis Tramites - previous', MistramitesPrevious);
|
intentMap.set('0 - Bienvenida - Mis Tramites - previous', MistramitesPrevious);
|
||||||
|
|
||||||
|
//******** Menu 1 - Mis tramites **************/
|
||||||
|
intentMap.set('0 - Bienvenida - TRB', TasaRecoleccionBasura);
|
||||||
|
|
||||||
|
|
||||||
/***** Menu 1 - Informacion de tramites *****/
|
/***** Menu 1 - Informacion de tramites *****/
|
||||||
intentMap.set('0 - Bienvenida - Inf Tram - fallback', FallbackInfoTramites);
|
intentMap.set('0 - Bienvenida - Inf Tram - fallback', FallbackInfoTramites);
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
|
|
||||||
function mensaje(name, username = null, massager = null) {
|
function mensaje(name, username = null, massager = null) {
|
||||||
var jsom_interaciones = ['Es un placer poder ayudarle.....'];
|
var jsom_interaciones = ['Es un placer poder ayudarle.....'];
|
||||||
var menu_context = "\n1. Consulta de deudas"+
|
var menu_context = "\n1️⃣ Consulta de deudas"+
|
||||||
"\n2. Validar documentos digitales"+
|
"\n2️⃣ Validar documentos digitales"+
|
||||||
"\n3. Mis comprobantes de pago"+
|
"\n3️⃣ Mis comprobantes de pago"+
|
||||||
"\n4. Mis trámites"+
|
"\n4️⃣ Mis trámites"+
|
||||||
"\n5. Información sobre trámites"+
|
"\n5️⃣ Información sobre trámites"+
|
||||||
"\n0. Cerrar sesión"+
|
"\n6️⃣ Tasa de recolección de basura"+
|
||||||
|
"\n0️⃣ Cerrar sesión"+
|
||||||
"\n\n -Ingrese el número de la opción que desee.";
|
"\n\n -Ingrese el número de la opción que desee.";
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'sol_cedula':
|
case 'sol_cedula':
|
||||||
|
|||||||
44
metodos.js
44
metodos.js
@ -392,7 +392,7 @@ async function Fun_QueHacesFunction(agent, req, res, vari = null) {
|
|||||||
|
|
||||||
async function Fun_pruebas(agent, req, res) {
|
async function Fun_pruebas(agent, req, res) {
|
||||||
|
|
||||||
return agent.add('hola como estras');
|
return agent.add('Estamos en proceso de desarrollo');
|
||||||
try {
|
try {
|
||||||
return Fun_QueHacesFunction(agent, req, req, 1);
|
return Fun_QueHacesFunction(agent, req, req, 1);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -595,6 +595,47 @@ function Func_FallbackInfoTramites(agent, req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function Func_MiTasaRecoleccionBasura(agent, req, res, lery) {
|
||||||
|
try {
|
||||||
|
let data_context = await ValidateDataUserContext(agent);
|
||||||
|
if (data_context) {
|
||||||
|
if (lery == 3) {
|
||||||
|
return Fun_ConsultarCCAtras(agent, req, res);
|
||||||
|
}
|
||||||
|
if (data_context != null && data_context != "") {
|
||||||
|
let legion = await funcion.ConsultaTasaRecoleccion(data_context.cedula, lery);
|
||||||
|
console.log("yaya")
|
||||||
|
console.log(data_context.cedula)
|
||||||
|
console.log(legion)
|
||||||
|
if (legion['ok'] == true) {
|
||||||
|
let coun = legion['data'].length;
|
||||||
|
if(count > 0){
|
||||||
|
var msger = '*Tasa de recolección de basura CC: ' + legion['data'].cc + '*\n\n';
|
||||||
|
let suma = 0;
|
||||||
|
let meses_arr = ['Enero 2026', 'Feberero 2026', 'Marzo 2026'];
|
||||||
|
meses_arr.forEach(element => {
|
||||||
|
suma += Number(legion['data'].promedio);
|
||||||
|
msger = msger + '🚛 ' + element + ' : *$' + legion['data'].promedio + '*\n';
|
||||||
|
});
|
||||||
|
msger = msger + '\n💵 *Total a pagar: $' + suma.toFixed(2) + '*';
|
||||||
|
}else{
|
||||||
|
msger = msger + "No se encontrarón valores pendientes de pago";
|
||||||
|
}
|
||||||
|
agent.add(msger);
|
||||||
|
return Fun_RetornarAlinicio(agent, req, res, funcion.conver_name(data_context.name));
|
||||||
|
} else {
|
||||||
|
agent.add(funcion.conver_name(data_context.name) + ', ' + legion['msg']);
|
||||||
|
return Fun_RetornarAlinicio(agent, req, res, funcion.conver_name(data_context.name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Fun_WelcomeAgent(agent, req, res);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return ResolveDefauld(agent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function Func_MisComprobantesPago(agent, req, res, lery) {
|
async function Func_MisComprobantesPago(agent, req, res, lery) {
|
||||||
try {
|
try {
|
||||||
let data_context = await ValidateDataUserContext(agent);
|
let data_context = await ValidateDataUserContext(agent);
|
||||||
@ -718,6 +759,7 @@ module.exports = {
|
|||||||
"Func_InformacionTramites": Func_InformacionTramites,
|
"Func_InformacionTramites": Func_InformacionTramites,
|
||||||
"Fun_ValidarDocumentos": Fun_ValidarDocumentos,
|
"Fun_ValidarDocumentos": Fun_ValidarDocumentos,
|
||||||
"Func_MisComprobantesPago": Func_MisComprobantesPago,
|
"Func_MisComprobantesPago": Func_MisComprobantesPago,
|
||||||
|
"Func_MiTasaRecoleccionBasura": Func_MiTasaRecoleccionBasura,
|
||||||
"Func_FallbackComprobantes": Func_FallbackComprobantes,
|
"Func_FallbackComprobantes": Func_FallbackComprobantes,
|
||||||
"Func_FallbackInfoTramites": Func_FallbackInfoTramites,
|
"Func_FallbackInfoTramites": Func_FallbackInfoTramites,
|
||||||
"Fun_QueHacesFunction": Fun_QueHacesFunction,
|
"Fun_QueHacesFunction": Fun_QueHacesFunction,
|
||||||
|
|||||||
146
trb.json
Normal file
146
trb.json
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"t_documento": "Cédula",
|
||||||
|
"documento": "1309029708",
|
||||||
|
"name": "CANTOS PARRAGA CHRISTIAN RAFAEL",
|
||||||
|
"cc": "3072019000",
|
||||||
|
"n_contrato": "001",
|
||||||
|
"coordenadas": "-0.965690, -80.709358",
|
||||||
|
"direccion": "LA PAZ AV. 203 C. 303",
|
||||||
|
"jul": "5.00",
|
||||||
|
"ago": "5.50",
|
||||||
|
"sep": "6.30",
|
||||||
|
"oct": "6.05",
|
||||||
|
"nov": "5.75",
|
||||||
|
"dic": "6.80",
|
||||||
|
"promedio": "5.90"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t_documento": "Cédula",
|
||||||
|
"documento": "1310006646",
|
||||||
|
"name": "VALDIVIESO ZAMORA MARCIANA AUXILIADORA",
|
||||||
|
"cc": "1290708000",
|
||||||
|
"n_contrato": "002",
|
||||||
|
"coordenadas": "-0.965690, -80.709358",
|
||||||
|
"direccion": "MZ-E LT.08 URB. CIUDAD DEL SOL",
|
||||||
|
"jul": "7.50",
|
||||||
|
"ago": "7.25",
|
||||||
|
"sep": "6.80",
|
||||||
|
"oct": "6.55",
|
||||||
|
"nov": "7.30",
|
||||||
|
"dic": "8.00",
|
||||||
|
"promedio": "7.23"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t_documento": "Cédula",
|
||||||
|
"documento": "912120797",
|
||||||
|
"name": "POVEDA BURGOS-FAUSTO ELIAS",
|
||||||
|
"cc": "1290708000",
|
||||||
|
"n_contrato": "002",
|
||||||
|
"coordenadas": "-0.965690, -80.709358",
|
||||||
|
"direccion": "MZ-E LT.08 URB. CIUDAD DEL SOL",
|
||||||
|
"jul": "7.50",
|
||||||
|
"ago": "7.25",
|
||||||
|
"sep": "6.80",
|
||||||
|
"oct": "6.55",
|
||||||
|
"nov": "7.30",
|
||||||
|
"dic": "8.00",
|
||||||
|
"promedio": "7.23"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t_documento": "Cédula",
|
||||||
|
"documento": "1310006646",
|
||||||
|
"name": "VALDIVIESO ZAMORA MARCIANA AUXILIADORA",
|
||||||
|
"cc": "3263418000",
|
||||||
|
"n_contrato": "003",
|
||||||
|
"coordenadas": "-0.965690, -80.709358",
|
||||||
|
"direccion": "URB. TERRAZA SANTA MARIA MZ. B LT. 18",
|
||||||
|
"jul": "5.80",
|
||||||
|
"ago": "5.50",
|
||||||
|
"sep": "5.30",
|
||||||
|
"oct": "6.00",
|
||||||
|
"nov": "5.75",
|
||||||
|
"dic": "7.00",
|
||||||
|
"promedio": "5.89"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t_documento": "Cédula",
|
||||||
|
"documento": "912120797",
|
||||||
|
"name": "POVEDA BURGOS-FAUSTO ELIAS",
|
||||||
|
"cc": "3263418000",
|
||||||
|
"n_contrato": "003",
|
||||||
|
"coordenadas": "-0.965690, -80.709358",
|
||||||
|
"direccion": "URB. TERRAZA SANTA MARIA MZ. B LT. 18",
|
||||||
|
"jul": "5.80",
|
||||||
|
"ago": "5.50",
|
||||||
|
"sep": "5.30",
|
||||||
|
"oct": "6.00",
|
||||||
|
"nov": "5.75",
|
||||||
|
"dic": "7.00",
|
||||||
|
"promedio": "5.89"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t_documento": "Cédula",
|
||||||
|
"documento": "1315604361",
|
||||||
|
"name": "PINARGOTE GARCIA CHRISTIAN GONZALO",
|
||||||
|
"cc": "2330709000",
|
||||||
|
"n_contrato": "004",
|
||||||
|
"coordenadas": "-0.965690, -80.709358",
|
||||||
|
"direccion": "MZ. B LOTE 09 URBANIZACION LA FRAGATA",
|
||||||
|
"jul": "4.50",
|
||||||
|
"ago": "4.75",
|
||||||
|
"sep": "5.00",
|
||||||
|
"oct": "5.10",
|
||||||
|
"nov": "5.30",
|
||||||
|
"dic": "6.20",
|
||||||
|
"promedio": "5.14"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t_documento": "Cédula",
|
||||||
|
"documento": "1311464265",
|
||||||
|
"name": "FIGUEROA INTRIAGO ANA AUXILIADORA",
|
||||||
|
"cc": "2235204000",
|
||||||
|
"n_contrato": "005",
|
||||||
|
"coordenadas": "-0.965690, -80.709358",
|
||||||
|
"direccion": "LOT. COSTA AZUL MZ K-2 LOTE 10",
|
||||||
|
"jul": "6.80",
|
||||||
|
"ago": "6.30",
|
||||||
|
"sep": "6.40",
|
||||||
|
"oct": "7.00",
|
||||||
|
"nov": "6.90",
|
||||||
|
"dic": "7.50",
|
||||||
|
"promedio": "6.82"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t_documento": "Cédula",
|
||||||
|
"documento": "1311464265",
|
||||||
|
"name": "FIGUEROA INTRIAGO ANA AUXILIADORA",
|
||||||
|
"cc": "2234311000",
|
||||||
|
"n_contrato": "006",
|
||||||
|
"coordenadas": "-0.965690, -80.709358",
|
||||||
|
"direccion": "LOT. COSTA AZUL MZ-S-2 LOTE 11",
|
||||||
|
"jul": "4.80",
|
||||||
|
"ago": "5.10",
|
||||||
|
"sep": "5.50",
|
||||||
|
"oct": "4.80",
|
||||||
|
"nov": "5.30",
|
||||||
|
"dic": "6.30",
|
||||||
|
"promedio": "5.30"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t_documento": "Cédula",
|
||||||
|
"documento": "1311464265",
|
||||||
|
"name": "FIGUEROA INTRIAGO ANA AUXILIADORA",
|
||||||
|
"cc": "2235712000",
|
||||||
|
"n_contrato": "007",
|
||||||
|
"coordenadas": "-0.965690, -80.709358",
|
||||||
|
"direccion": "LOT. COSTA AZUL MZ- J-2 LOTE 12",
|
||||||
|
"jul": "5.50",
|
||||||
|
"ago": "5.20",
|
||||||
|
"sep": "5.80",
|
||||||
|
"oct": "5.60",
|
||||||
|
"nov": "6.00",
|
||||||
|
"dic": "6.50",
|
||||||
|
"promedio": "5.77"
|
||||||
|
}
|
||||||
|
]
|
||||||
Loading…
x
Reference in New Issue
Block a user