我在Google上的Action和我的Alpha-Beta测试用户以及正式版有问题。我正在使用Dialogflow-V2,当我在测试模式下使用我的应用程序,模拟器或与我的开发人员帐户关联的手机时,一切正常,并且我没有任何问题。
但是我已经用alpha-beta测试用户测试了我的项目。我将“选择加入链接”发送给我的用户,他们可以接受为alpha-beta测试人员,并且可以使用Invocation示例启动代理。
欢迎意图启动正常,然后在使用上下文时出现问题,因为在请求主体的日志中存在该日志,但是在实现中不存在该问题。
当我使用手机时,任何上下文都会退出,firebase中有日志,但Google Cloud Platform中没有任何日志。
package.json
{
"name": "dialogflowBUSCADORCFP",
"description": "This is the dialogflowBUSCADORCFP for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowBUSCADORCFP",
"deploy": "firebase deploy --only functions:dialogflowBUSCADORCFP"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.6.0",
"axios": "^0.18.0",
"i18next": "^15.0.5",
"moment": "^2.24.0"
}
}
index.js
// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const axios = require('axios');
const i18n = require('i18next');
const moment = require('moment');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
moment.locale(agent.locale);
i18n.init({
lng: agent.locale,
debug: false,
resources: {
es: {
translation: {
WELCOME_MSG: 'Bienvenido al buscador de cursos del Centro de Formación Permanente de la Universidad Politécnica de Valencia. Puedes buscar cualquier curso diciendo: busca cursos de java o busca algún curso sobre windows, o de cualquier tema que te interese. ¿Dime que buscar?',
BUSCAR_MSG: 'Hemos encontrado {{numero_results}} cursos. ',
CURSO_MSG: 'El curso ',
NO_CURSOS_MSG: 'No he encontrado ningún curso, con la palabra: {{palabra}}. ',
MAS_INFO_MSG: 'Si quieres que te envíe más información de este curso a tu correo electrónico, di la orden: "Enviar información" o si quieres hacer otra búsqueda, busca de nuevo por palabra.',
HELP_MSG: 'Puedes buscar cualquier curso diciendo: busca cursos de java o busca algún curso sobre windows, o de cualquier tema que te interese, para salir puedes decir cancela. ¿Cómo puedo ayudarte?',
GOODBYE_MSG: 'Espero que hayas encontrado lo que estabas buscando. Puedes encontrar más información en nuestra página web: www.cfp.upv.es . Hasta pronto.',
CONJUNCION_MSG: ' y ',
FALLBACK_MSG: '¿Quieres realizar otra búsqueda? ¿Dime que buscar?',
ERROR_MSG: 'Lo siento, ha habido un error. Por favor, inténtelo de nuevo.',
NO_RESULTS_MSG: 'Tienes que realizar una búsqueda por palabra. ¿Dime que buscar?',
TEXTO_MAS_INFO1_MSG: ', fecha de inicio {{fechaInicio}}, fecha fin {{fechaFin}}',
TEXTO_MAS_INFO21_MSG: ', precio mínimo: {{minimo}} euros, precio máximo: {{maximo}} euros',
TEXTO_MAS_INFO22_MSG: ', precio: {{precio}} euros',
TEXTO_MAS_INFO3_MSG: ', modalidad {{modalidad}}',
TEXTO_MAS_INFO4_MSG: ', horas presenciales: {{h_presen}}',
TEXTO_MAS_INFO5_MSG: ', horas a distancia: {{h_distan}}',
FORMATO_MSG: 'DD/MM/YYYY',
NO_TIMEZONE_MSG: 'No he podido determinar tu zona horaria. Verifica la configuración de tu dispositivo, abre otra vez la skill e inténtalo otra vez.',
AMPLIAR_INFO_MSG: '¿Quieres ampliar la información de algún curso, dime el número del curso?',
ENVIO_INFO_MSG: 'Hemos enviado más información a tu correo electrónico.',
UNSUPPORTED_DEVICE_MSG: 'Este dispositivo no soporta la operación que estás intentando realizar. ',
MISSING_PERMISSION_MSG: 'Parece que no has autorizado poder conocer tu correo electrónico. Te he enviado una tarjeta a la app para que lo habilites. ',
EMAIL_ERROR_MSG: 'Perdona, ha habido un error al buscar tu correo electrónico. ',
EMAIL_ERROR_SIN_CURSO_MSG: 'Primero tienes que seleccionar el curso, para poder enviarte la información a tu correo electrónico de dicho curso. ',
}
}
}
});
function welcome(agent) {
agent.add(i18n.t('WELCOME_MSG'));
}
function fetchBuscarCursos(palabra_value) {
const url = 'https://www.cfp.upv.es/cfp-ws/rest/cursos/idioma/es';
var config = {
timeout: 6500, // timeout api call
};
async function getJsonResponse(url, palabra_value, config){
const res = await axios.post(url, {
palabra: palabra_value,
tiposNoIncluidos: ["CG"]
});
return res.data;
}
return getJsonResponse(url, palabra_value, config).then((result) => {
return result;
}).catch((error) => {
return null;
});
}
async function buscarCursos(agent) {
const palabra_value = agent.parameters.palabra;
let speakOutput = '';
const results = await fetchBuscarCursos(palabra_value);
if(results!==null && results.length>0) {
console.log('insertamos cursos context');
agent.context.set({ name: "cursos", lifespan: 5, parameters: {listado: results}});
speakOutput = i18n.t('BUSCAR_MSG',{numero_results: results.length});
results.forEach((curso,index) => {
speakOutput += i18n.t('CURSO_MSG') + (index+1) + ': ' + curso.denominacion;
if (index === Object.keys(results).length - 2)
speakOutput += i18n.t('CONJUNCION_MSG');
else
speakOutput += '. ';
});
speakOutput += i18n.t('AMPLIAR_INFO_MSG');
agent.add(speakOutput);
}else{
speakOutput = i18n.t('NO_CURSOS_MSG',{palabra: palabra_value}) + i18n.t('FALLBACK_MSG');
agent.add(speakOutput);
}
}
async function masInfo(agent) {
let speakOutput = '';
const numero = agent.parameters.numero;
console.log(numero);
console.log('sacamos cursos context');
let listados = agent.context.get('cursos');
console.log(listados); //HERE is UNDEFINED WHEN USE A PHONE
const cursos = listados.parameters.listado; //ERROR
console.log(cursos);
if(cursos!==null && cursos.length>0 && numero!==null && numero<=cursos.length) {
const curso = cursos[numero-1];
console.log('insertamos info_curso1 context');
agent.context.set({ name: "info_curso1", lifespan: 5, parameters: {idcurso: curso.id}});
speakOutput += curso.denominacion + i18n.t('TEXTO_MAS_INFO1_MSG',{fechaInicio: moment(curso.fechaInicio).format('LL'), fechaFin: moment(curso.fechaFin).format('LL')});
if(curso.precioMin!==curso.precioMax) {
speakOutput += i18n.t('TEXTO_MAS_INFO21_MSG', {minimo: curso.precioMin, maximo: curso.precioMax});
}else{
speakOutput += i18n.t('TEXTO_MAS_INFO22_MSG', {precio: curso.precioMin});
}
speakOutput += i18n.t('TEXTO_MAS_INFO3_MSG', {modalidad: curso.modalidadIdioma});
if(curso.horasPresenciales>0) {
speakOutput += i18n.t('TEXTO_MAS_INFO4_MSG', {h_presen:curso.horasPresenciales});
}
if(curso.horasAdistancia>0) {
speakOutput += i18n.t('TEXTO_MAS_INFO5_MSG', {h_distan:curso.horasAdistancia});
}
speakOutput += ' . ' + i18n.t('MAS_INFO_MSG');
}else{
speakOutput = i18n.t('ERROR_MSG');
}
agent.add(speakOutput);
}
function fallback(agent) {
agent.add(i18n.t('FALLBACK_MSG'));
}
function finalizar(agent) {
agent.add(i18n.t('GOODBYE_MSG'));
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Bienvenida', welcome);
intentMap.set('CursosCFPIntent', buscarCursos);
intentMap.set('MasInfoIntent', masInfo);
intentMap.set('Fallback', fallback);
//intentMap.set('FinalizarIntent', finalizar);
agent.handleRequest(intentMap);
});
错误
让listados = agent.context.get('cursos');
console.log(listados); //当使用电话时,这里的位置未定义const cursos = listados.parameters.listado; //错误
dialogflowFirebaseFulfillment(请求正文)
“ Dialogflow请求主体:{” responseId“:” a70161bc-638a-43b2-a6fd-72939fc46e3e-a14fa99c“,” queryResult“:{” queryText“:” el curso 2“,” parameters“:{” numero“: 2},“ allRequiredParamsPresent”:true,“ fulfillmentMessages”:[{“ text”:{“ text”:[“”]}}]],“ outputContexts”:[{“ name”:“ projects / buscador-cfp-awvidl / agent / environments / __ aog-6 / users /-/ sessions / ABwppHGIQ2rhvD_AvCN073Dli9Z0TBCdI2MqjwmfuZvG-wDWEm9fOZs3PJUCILOTr-UWsM6DE7ZwbRHFelk5lLbigA / contexts:“”,“” acronimo”:“ 21.MDADM.EPSG-87264”,“ denominacion”:“ ARQUITECTURAS软件YDISEÑOAVANZADO DE INTERUACE USUARIO”,“ caca”:2020,“ campus”:“ I”,“ tipoCurso”:“ CMTP”, “ fechaInicio”:1618783200000,“ fechaFin”:1626040800000,“ fechaMatricula”:null,“ fechaMatriculaFin”:null,“ fechaIniPreinscripcion”:1613689200000,“ fechaFinPreinscripcion”:null,“ horasPresenciales”:0,“:horasAdistan” “:8,” fechaAnulado“:null,” precioMin“:310,” precioMax“:370,” dondeIdioma“:” INTERNET“,” urlFicha“:” ../ cursos / arquitecturas-softwar ey-diseno-avanzado-de-interface-usuario_idiomaes-cid68575.html“,” modalidad“:” O“,” peso“:100,” areasEstudio“:[” TIC“],” areasEstudioIdioma“:[” TIC“] ,“ tipoCursoIdioma”:“ Curso corto”,“ modalidadIdioma”:“在线”,“ etiquetas”:null,“ tipoIdioma”:null,“ nivelIdioma”:null,“ clasificacion”:“案例A:永久性大学,” tipoCursoWeb“:” FE“},{” id“:68063,” acronimo“:” 20.DSIC-DREAW“,” denominacion“:” CURSO ONLINE DEDISEÑODEPÁGINASWEB CON DREAMWEAVER Y PHOTOSHOP“,” caca“:2019 ,“ campus”:“ I”,“ tipoCurso”:“ CFE”,“ fechaInicio”:1583017200000,“ fechaFin”:1596146400000,“ fechaMatricula”:1581721200000,“ fechaMatriculaFin”:1588370400000,“ fechaIniPreinscripcion”:1580770800000,“ fechaFinin” :null,“ horasPresenciales”:0,“ horasAdistancia”:20,“ creditos”:2,“ fechaAnulado”:null,“ precioMin”:99,“ precioMax”:119,“ dondeIdioma”:“ INTERNET”,“ urlFicha” :“ ../ cursos / curso-online-de-diseno-de-paginas-web-con-dreamweaver-y-photoshop_idiomaes-cid68063.html”,“ modalidad”:“ O”,“ peso”:100,“ areasEstudio “:[” TIC“],” areaEstud ioIdioma”:[[TIC”],“ tipoCursoIdioma”:“ Curso corto”,“ modalidadIdioma”:“在线”,“ etiquetas”:null,“ tipoIdioma”:null,“ nivelIdioma”:null,“ clasificacion”:“ Claseificacion”答:永久大学,“” tipoCursoWeb“:” FE“},{” id“:68570,” acronimo“:” 20.MDADM.EPSG-68570“,” denominacion“:”MÁSTEREN DESARROLLO DE APLICACIONES SOBRE DISPOSITIVOSMÓVILES “,” caca“:2020,” campus“:” I“,” tipoCurso“:” CM2“,” fechaInicio“:1600639200000,” fechaFin“:1640905200000,” fechaMatricula“:null,” fechaMatriculaFin“:null,” fechaIniPreinscripcion “:1586210400000,” fechaFinPreinscripcion“:null,” horasPresenciales“:0,” horasAdistancia“:600,” creditos“:60,” fechaAnulado“:null,” precioMin“:2000,” precioMax“:3000,” dondeIdioma“: “ INTERNET”,“ urlFicha”:“ ../ cursos / master-en-desarrollo-de-aplicaciones-sobre-dispositivos-moviles_idiomaes-cid68570.html”,“ modalidad”:“ O”,“ peso”:92,“ areasEstudio“:[” TIC“],” areasEstudioIdioma“:[” TIC“],” tipoCursoIdioma“:”Títulopropio“,” modalidadIdioma“:”在线“,” etiquetas“:null,” tipoIdioma“:null,” nivelIdioma “:null” sificacion”:“案例A:永久性大学文凭”,“ tipoCursoWeb”:“ TP”},{“ id”:66985,“ acronimo”:“ 19.DSIC-JAVECLI”,“ denominacion”:“ CURSO ONLINE DE JAVA EN EL ENTORNO DE DESARROLLO ECLIPSE“,” caca“:2019,” campus“:” I“,” tipoCurso“:” CFE“,” fechaInicio“:1571004000000,” fechaFin“:1604012400000,” fechaMatricula“:1569708000000,” fechaMatriculaFin“ :1598824800000,“ fechaIniPreinscripcion”:1568671200000,“ fechaFinPreinscripcion”:null,“ horasPresenciales”:0,“ horasAdistancia”:20,“ creditos”:2,“ fechaAnulado”:null,“ precioMin”:99,“ precioMax”:119 ,“ dondeIdioma”:“互联网”,“ urlFicha”:“ ../ cursos / curso-online-de-java-en-el-entorno-de-desarrollo-eclipse_idiomaes-cid66985.html”,“ modalidad”:“ O “,” peso“:85,” areasEstudio“:[” TIC“],” areasEstudioIdioma“:[” TIC“],” tipoCursoIdioma“:” Curso corto“,” modalidadIdioma“:”在线“,” etiquetas“:null ,“ tipoIdioma”:null,“ nivelIdioma”:null,“ clasificacion”:“案例A:永久性大学,” tipoCursoWeb“:” FE“},{” id“:66990,” acronimo“:” 19.DSIC -JEEJSF“,” denominacion“:” CURSO ONL INE DE DESARROLLO JEE CON JSF,HIBERNATE Y SPRING“,” caca“:2019,” campus“:” I“,” tipoCurso“:” CFE“,” fechaInicio“:1571004000000,” fechaFin“:1604012400000,” fechaMatricula“: 1569189600000,“ fechaMatriculaFin”:1596232800000,“ fechaIniPreinscripcion”:1568671200000,“ fechaFinPreinscripcion”:null,“ horasPresenciales”:0:“ horasAdistancia”:20,“ creditos”:2,“ fechaAnulado”:null,“ precioMin “ precioMax”:119,“ dondeIdioma”:“ INTERNET”,“ urlFicha”:“ ../ cursos / curso-online-de-desarrollo-jee-con-jsf--hibernate-y-spring_idiomaes-cid66990.html”, “ modalidad”:“ O”,“ peso”:95,“ areasEstudio”:[“ TIC”],“ areasEstudioIdioma”:[“ TIC”],“ tipoCursoIdioma”:“ Curso corto”,“ modalidadIdioma”:“在线” ,“ etiquetas”:null,“ tipoIdioma”:null,“ nivelIdioma”:null,“ clasificacion”:“案例A:永久性大学,” tipoCursoWeb“:” FE“},{” id“:68572,” acronimo “:”“ 20.DEAA-68572”,“ denominacion”:“ DIPLOMA DEESPECIALIZACIÓNEN DESARROLLO DE APLICACIONES ANDROID”,“ caca”:2020,“ campus”:“ I”,“ tipoCurso”:“ CDE”,“ fechaInicio” :1600639200000,“ fechaFin”:164 0905200000,“ fec”insertId:“ 000000-c615e98f-c981-478d-b386-0ee5a38a874c”资源:{类型:“ cloud_function”标签:{3}}时间戳:“ 2020-04-20T09:40:30.731Z”严重性:“ INFO”标签: {execution_id:“ p60x70lwfrsi”}logName:“ projects / buscador-cfp-awvidl / logs / cloudfunctions.googleapis.com%2Fcloud-functions”跟踪:“项目/ buscador-cfp-awvidl / traces / 9eb94caf3c5b5951df9e0d954751ec33”receiveTimestamp:“ 2020-04-20T09:40:31.017539584Z”}
"TypeError: Cannot read property 'parameters' of undefined
at masInfo (/srv/index.js:122:29)
at WebhookClient.handleRequest (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:313:44)
at exports.dialogflowFirebaseFulfillment.functions.https.onRequest (/srv/index.js:173:9)
at cloudFunction (/srv/node_modules/firebase-functions/lib/providers/https.js:57:9)
at /worker/worker.js:783:7
at /worker/worker.js:766:11
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)"
您能帮我吗?
非常感谢,
最好的问候,维克多
您可能会遇到上下文的最大大小,因为您要在上面存储大量信息。我还没有找到有关上下文的记录限制,但我认为值得尝试以较小的参数数量重现该问题,以查看是否可以通过。
问题出在测试人员身上!!!!
如果我通过手机中的用户帐户使用该程序,则可以正常运行,但是如果测试人员在手机中使用该程序,则无法运行。
上下文有问题。
会发生什么? :-(
看起来参数“ listado”具有一个JavaScript数组作为值。 documentation for Context parameters表示在某些情况下,映射中的值应为复合类型(即-另一个映射),但通常应为字符串。
因此,当您认为您正在设置一个数组时,由于它不是字符串,因此可能会被清空,或者整个上下文被视为无效。