0
votes

I have a problem with Action on google and my alpha - beta test users and the production version. I am using the Dialogflow-V2, when I use my app in a test mode, with the simulator or with my phone linked with my dev account everything works fine and I don't have any problem.

But I have tested my project with alpha - beta test users. I sent the Opt-in Link to my users, they can accept to be alpha - beta testers and they can launch the agent with the Invocation sample.

The Welcome intent launch is ok and then the problem appear, when use the context, because in the logs of request body exist, but it doesn't exit in the Fulfillment.

Any context exits. Also I change the Array context and now I use a parameter with only one word. I have the same problem.

package.json

{
  "name": "dialogflowCFPUPVASISTENTE",
  "description": "This is the dialogflowCFPUPVASISTENTE 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:dialogflowCFPUPVASISTENTE",
    "deploy": "firebase deploy --only functions:dialogflowCFPUPVASISTENTE"
  },
  "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",
    "crypto-js": "^4.0.0",
    "google-auth-library": "^5.10.0"
  }
} 

index.js

 const numero = agent.parameters.numero;
conole.log(numero);
console.log('prueba6666666 cursos1 context');


//prueba
let contexto_busqueda = agent.context.get('busqueda1');
console.log(contexto_busqueda);  //HERE is UNDEFINED WHEN USE TESTER PHONE
let busqueda = contexto_busqueda.parameters.busqueda;

dialogflowFirebaseFulfillment (request body) with context "busqueda1" simple parameter "busqueda"

{
textPayload: "Dialogflow Request body: {"responseId":"5c2cb699-3ca5-4062-9e12-7dc31f0b15b6-eec93b43","queryResult":{"queryText":"el curso 2","action":"MasInfoIntent","parameters":{"numero":2},"allRequiredParamsPresent":true,"outputContexts":[{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/enviar_email1","lifespanCount":5,"parameters":{"idtoken":"xxxxx","palabra":"Java","palabra.original":"Java","numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/info_curso1","lifespanCount":5,"parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/actions_capability_web_browser","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/actions_capability_audio_output","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/actions_capability_account_linking","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/actions_capability_media_response_audio","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/actions_capability_screen_output","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/google_assistant_input_type_voice","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/busqueda1","lifespanCount":4,"parameters":{"palabra":"Java","palabra.original":"Java","busqueda":"Java","numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/__system_counters__","parameters":{"no-input":0,"no-match":0,"numero":2,"numero.original":"2"}}],"intent":{"name":"projects/cfpupv-ojcaew/agent/intents/b74cc78e-8c1c-420e-ba0d-3b6da6e18dd9","displayName":"MasInfoIntent"},"intentDetectionConfidence":1,"languageCode":"es"},"originalDetectIntentRequest":{"source":"google","version":"2","payload":{"user":{"locale":"es-ES","lastSeen":"2020-04-24T11:37:19Z","idToken":"xxxxx"
insertId: "000001-5cbd2792-582d-45b5-a99c-62c51c1daae8"
resource: {
type: "cloud_function"
labels: {3}
}
timestamp: "2020-04-24T11:37:39.685Z"
severity: "INFO"
labels: {
execution_id: "o8obosdy5d5z"
}
logName: "projects/cfpupv-ojcaew/logs/cloudfunctions.googleapis.com%2Fcloud-functions"
trace: "projects/cfpupv-ojcaew/traces/b0fb3fa3c628d8cbaef2b73c09b64775"
receiveTimestamp: "2020-04-24T11:37:40.571089537Z"
}

dialogflowFirebaseFulfillment (request body) with context "busqueda1" simple parameter "busqueda" IS WORKING

{
textPayload: "Dialogflow Request body: {"responseId":"a3703a6d-9fca-4e4d-91f3-ecb58212a0f3-eec93b43","queryResult":{"queryText":"el curso 3","action":"MasInfoIntent","parameters":{"numero":3},"allRequiredParamsPresent":true,"outputContexts":[{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/enviar_email1","lifespanCount":5,"parameters":{"idtoken":"xxxxx","palabra":"java","palabra.original":"java","numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/info_curso1","lifespanCount":5,"parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/actions_capability_screen_output","parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/actions_capability_account_linking","parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/actions_capability_media_response_audio","parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/actions_capability_audio_output","parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/google_assistant_input_type_voice","parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/busqueda1","lifespanCount":4,"parameters":{"palabra":"java","palabra.original":"java","busqueda":"java","numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/__system_counters__","parameters":{"no-input":0,"no-match":0,"numero":3,"numero.original":"3"}}],"intent":{"name":"projects/cfpupv-ojcaew/agent/intents/b74cc78e-8c1c-420e-ba0d-3b6da6e18dd9","displayName":"MasInfoIntent"},"intentDetectionConfidence":1,"languageCode":"es"},"originalDetectIntentRequest":{"source":"google","version":"2","payload":{"user":{"locale":"es-ES","lastSeen":"2020-04-24T12:07:58Z","idToken":"xxxxx","userVerificationStatus":"VERIFIED"},"conversation":{"conversationId":"ABwppHEYyiNzdo2"
insertId: "000001-3770d84b-b3e1-4610-a4e1-91f9c27573a5"
resource: {
type: "cloud_function"
labels: {3}
}
timestamp: "2020-04-24T12:08:09.311Z"
severity: "INFO"
labels: {
execution_id: "0hxf6o3oumx8"
}
logName: "projects/cfpupv-ojcaew/logs/cloudfunctions.googleapis.com%2Fcloud-functions"
trace: "projects/cfpupv-ojcaew/traces/ee0e462e5b7fcab9b45d7ef9acdcebe8"
receiveTimestamp: "2020-04-24T12:08:10.552786312Z"
}

"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)"

I think this is a problem of permissions in google cloud platform. Any idea?

Permissions cloud

Do I need another permission for alpha tester and production for using contexts?

https://cloud.google.com/dialogflow/docs/fulfillment-inline-editor

https://cloud.google.com/dialogflow/docs/fulfillment-webhook

If I use other alpha tester the project doesn't work, because although the dialogflow context exist in the request body of google cloud platform in the program is undefined. Do I must do something in action google to use the program in alpha testing or production?

Can you help me?

3
Hi! Welcome to stackoverflow. Can you provide some more information such as screenshots of what is working and what is not? This helps us in providing an answer for you. For more info, please see the how to ask a good question section. stackoverflow.com/help/how-to-askJordi
Hi Victor, thanks for providing the code you are using. Looking at the code it seems as if the cursos context is unavailable or has expired. This should normally work fine for each device. I see a if(results!==null && results.length>0) statement before the context is set. Are you sure the context is being set by the buscarCursos function when you use your phone?Jordi
Hi Jordi, I have written the code of dialogflowFirebaseFulfillment (request body) then I have called the masInfo function 'el curso 2', you can see the context is being set using my phone, but then it said undefined when find 'parameters'.Asistente CFP
There are some oddities about the details in that request as you've pasted it. It ends very suddenly in the middle of the first parameter in the first context.Prisoner
Did this latest request body come from a user that was doing Alpha or Beta testing, or did it come from the developer? (Either way - can you make sure there are example request bodies from users where it is working and where it isn't?)Prisoner

3 Answers

2
votes

you might be hitting a maximum size for the context as you are storing a lot of information on it. I haven't been able to find a documented limit for the contexts, but I think is worth trying to reproduce the problem with a smaller parameter count to see if it goes through.

0
votes

It looks like the parameter "listado" has a JavaScript array as the value. The documentation for Context parameters indicate that the value in the map should either be a composite type (ie - another map) in some limited cases, but generally should be a string.

So it may be possible that while you think you're setting an array - when it is read back in, since it isn't a string, it is being emptied out or the entire context is considered invalid.

0
votes

Answer of Action Google Assitant Support:

Thank you for providing the requested information and for adding my account as an Alpha tester. Based on these, we can understand that the "parameters" property caused the Action to crash. Upon checking the code snippet provided, we noticed that you used "agent" instead of "conv". What you can do is update "agent" to "conv". The reason for this is agent is more of for other integrations of Dialogflow. This is also coordinated with the Dialogflow team and they suggested the same. Please refer to the code snippets below on how to get the value of a parameter directly or in a context in webhook.

// Handle the Dialogflow intent named 'Curso Intent' without context.
// The intent collects a parameter named 'numero'.
app.intent('Curso Intent', (conv, {numero}) => {
    const numero = numero;
});


// Handle the Dialogflow intent named 'Curso Intent' with context "curso_out".
// The intent collects a parameter named 'numero'.
app.intent('Curso Intent', (conv, {conv}) => {
    const cCursoOut = conv.contexts.get('curso_out');
    const pCursoOut = cCursoOut.parameters;
    const numero = pCursoOut.numero;
});

Using 'conv' the project works perfectly !!!!!!!!!!!!

Thank yoy very much