Firestore Strange Behaviour

google-assistant

#1

Orignally titled: Google Cloud Functions Fulfilment, but I think the strange behaviour is form Firestore

Recently I’ve been having trouble deploying my fulfillment code to Google Cloud Functions. Things worked fine before. The process I use to deploy is right from this tutorial: (https://www.jovo.tech/tutorials/deploy-to-google-cloud#create-google-cloud-function):

Now when deploying a new fulfillment function I immediately see the error: My test app isn’t responding right now. Try again soon.

I tried quite a few sanity checks but I keep getting the same error, this is making me suspect there is a problem with how I am deploying the cloud function.

Note: I am testing with working Google Action, I am just changing the fulfilment URL which results in error.

  1. npm run bundle, and upload the zip bundle from the source code of a working fulfilment function, does not work if uploaded as a new function.

  2. Same thing as above except change a few lines so it’s not the exact same source code.

  3. Use the “Copy” button in the console on the working function and make a new function with a different name. Still doesn’t work :frowning:

Maybe package updates?

Maybe has to do with Google Cloud change where functions require authorization by default (where public before). However copying the function in the console, produces the same error.

At this point I really have no idea what to do. Any help would be appreciated.

Here are the entries in the Google Stackdriver logs.

{ "responseId": "4b446446-c48d-4550-ba77-e395d0fb2c0c-5b26cf67", "queryResult": { "queryText": "GOOGLE_ASSISTANT_WELCOME", "parameters": {}, "allRequiredParamsPresent": true, "outputContexts": [ { "name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/actions_capability_audio_output" }, { "name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/actions_capability_media_response_audio" }, { "name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/actions_capability_account_linking" }, { "name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/actions_capability_screen_output" }, { "name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/actions_capability_web_browser" }, { "name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/google_assistant_input_type_keyboard" }, { "name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/google_assistant_welcome" } ], "intent": { "name": "projects/danamic-brief-yftiph/agent/intents/35bde14d-8470-489c-896a-e7e50c08a924", "displayName": "Default Welcome Intent" }, "intentDetectionConfidence": 1, "languageCode": "en" }, "originalDetectIntentRequest": { "source": "google", "version": "2", "payload": { "user": { "locale": "en-US", "lastSeen": "2019-07-09T15:47:00Z", "userStorage": "{\"userId\":\"a37a4dec-9267-4924-bb99-90479fd217ea\"}", "userVerificationStatus": "VERIFIED" }, "conversation": { "conversationId": "ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4", "type": "NEW" }, "inputs": [ { "intent": "actions.intent.MAIN", "rawInputs": [ { "inputType": "KEYBOARD", "query": "Talk to my test app" } ] } ], "surface": { "capabilities": [ { "name": "actions.capability.AUDIO_OUTPUT" }, { "name": "actions.capability.MEDIA_RESPONSE_AUDIO" }, { "name": "actions.capability.ACCOUNT_LINKING" }, { "name": "actions.capability.SCREEN_OUTPUT" }, { "name": "actions.capability.WEB_BROWSER" } ] }, "isInSandbox": true, "availableSurfaces": [ { "capabilities": [ { "name": "actions.capability.AUDIO_OUTPUT" }, { "name": "actions.capability.SCREEN_OUTPUT" }, { "name": "actions.capability.WEB_BROWSER" } ] } ], "requestType": "SIMULATOR" } }, "session": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4" }
Expand all | Collapse all {
 insertId:  "000000-3f468e76-293f-4d35-afce-19361d741560"  
 labels: {…}  
 logName:  "projects/wyzefind-jovo-integration/logs/cloudfunctions.googleapis.com%2Fcloud-functions"  
 receiveTimestamp:  "2019-07-09T15:48:49.774132959Z"  
 resource: {…}  
 severity:  "INFO"  
 textPayload:  "{
	"responseId": "4b446446-c48d-4550-ba77-e395d0fb2c0c-5b26cf67",
	"queryResult": {
		"queryText": "GOOGLE_ASSISTANT_WELCOME",
		"parameters": {},
		"allRequiredParamsPresent": true,
		"outputContexts": [
			{
				"name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/actions_capability_audio_output"
			},
			{
				"name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/actions_capability_media_response_audio"
			},
			{
				"name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/actions_capability_account_linking"
			},
			{
				"name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/actions_capability_screen_output"
			},
			{
				"name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/actions_capability_web_browser"
			},
			{
				"name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/google_assistant_input_type_keyboard"
			},
			{
				"name": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4/contexts/google_assistant_welcome"
			}
		],
		"intent": {
			"name": "projects/danamic-brief-yftiph/agent/intents/35bde14d-8470-489c-896a-e7e50c08a924",
			"displayName": "Default Welcome Intent"
		},
		"intentDetectionConfidence": 1,
		"languageCode": "en"
	},
	"originalDetectIntentRequest": {
		"source": "google",
		"version": "2",
		"payload": {
			"user": {
				"locale": "en-US",
				"lastSeen": "2019-07-09T15:47:00Z",
				"userStorage": "{\"userId\":\"a37a4dec-9267-4924-bb99-90479fd217ea\"}",
				"userVerificationStatus": "VERIFIED"
			},
			"conversation": {
				"conversationId": "ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4",
				"type": "NEW"
			},
			"inputs": [
				{
					"intent": "actions.intent.MAIN",
					"rawInputs": [
						{
							"inputType": "KEYBOARD",
							"query": "Talk to my test app"
						}
					]
				}
			],
			"surface": {
				"capabilities": [
					{
						"name": "actions.capability.AUDIO_OUTPUT"
					},
					{
						"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
					},
					{
						"name": "actions.capability.ACCOUNT_LINKING"
					},
					{
						"name": "actions.capability.SCREEN_OUTPUT"
					},
					{
						"name": "actions.capability.WEB_BROWSER"
					}
				]
			},
			"isInSandbox": true,
			"availableSurfaces": [
				{
					"capabilities": [
						{
							"name": "actions.capability.AUDIO_OUTPUT"
						},
						{
							"name": "actions.capability.SCREEN_OUTPUT"
						},
						{
							"name": "actions.capability.WEB_BROWSER"
						}
					]
				}
			],
			"requestType": "SIMULATOR"
		}
	},
	"session": "projects/danamic-brief-yftiph/agent/sessions/ABwppHEEPote5ZUyL7TnQjwUoP_VNuhN8L2lwSW12ROpnEr2aLGFpnr5kk0MT7g-Ip-Jl4FUpzrmSusZl_xJVdvd2A4"
}"  
 timestamp:  "2019-07-09T15:48:43.744Z"  
 trace:  "projects/wyzefind-jovo-integration/traces/da2360cab4be0264b4ef35a0951ccd87"  
}

#2

I was looking into the issue some more and changing FileDB to firebase causes the error. This strange behaviour is occurring with code that was working fine before. I can’t tell the exact date it started since I haven’t worked with JOVO for about 2 weeks.

When using FileDB the test app works fine. Switching to Firestore causes strange behaviour. First time running “Talk to my test app” results in “My test app isn’t responding right now. Try again soon.”

Under the first part of the logged response there is the message:
Local server did not return a valid JSON response:
Undefined

Right below the proper response is shown in the console.

{
        "responseId": "ce453a8d-4213-4e15-b76f-e339d47127a7-5b26cf67",
        "queryResult": {
                "queryText": "GOOGLE_ASSISTANT_WELCOME",
                "parameters": {},
                "allRequiredParamsPresent": true,
                "outputContexts": [
                        {
                                "name": "projects/jovo-sanity-check-ksgxnt/agent/sessions/ABwppHGQiZbWkyxVYteuEqsAHj9l3OvkO_iJtGCc59FMArFHuIZ6wqf9NUHj8rc2ve-FqaCoPu3p2-_WT07Kovya1ZrnHNMR/contexts/actions_capability_account_linking"
                        },
                        {
                                "name": "projects/jovo-sanity-check-ksgxnt/agent/sessions/ABwppHGQiZbWkyxVYteuEqsAHj9l3OvkO_iJtGCc59FMArFHuIZ6wqf9NUHj8rc2ve-FqaCoPu3p2-_WT07Kovya1ZrnHNMR/contexts/actions_capability_screen_output"
                        },
                        {
                                "name": "projects/jovo-sanity-check-ksgxnt/agent/sessions/ABwppHGQiZbWkyxVYteuEqsAHj9l3OvkO_iJtGCc59FMArFHuIZ6wqf9NUHj8rc2ve-FqaCoPu3p2-_WT07Kovya1ZrnHNMR/contexts/actions_capability_web_browser"
                        },
                        {
                                "name": "projects/jovo-sanity-check-ksgxnt/agent/sessions/ABwppHGQiZbWkyxVYteuEqsAHj9l3OvkO_iJtGCc59FMArFHuIZ6wqf9NUHj8rc2ve-FqaCoPu3p2-_WT07Kovya1ZrnHNMR/contexts/actions_capability_audio_output"
                        },
                        {
                                "name": "projects/jovo-sanity-check-ksgxnt/agent/sessions/ABwppHGQiZbWkyxVYteuEqsAHj9l3OvkO_iJtGCc59FMArFHuIZ6wqf9NUHj8rc2ve-FqaCoPu3p2-_WT07Kovya1ZrnHNMR/contexts/actions_capability_media_response_audio"
                        },
                        {
                                "name": "projects/jovo-sanity-check-ksgxnt/agent/sessions/ABwppHGQiZbWkyxVYteuEqsAHj9l3OvkO_iJtGCc59FMArFHuIZ6wqf9NUHj8rc2ve-FqaCoPu3p2-_WT07Kovya1ZrnHNMR/contexts/google_assistant_input_type_keyboard"
                        },
                        {
                                "name": "projects/jovo-sanity-check-ksgxnt/agent/sessions/ABwppHGQiZbWkyxVYteuEqsAHj9l3OvkO_iJtGCc59FMArFHuIZ6wqf9NUHj8rc2ve-FqaCoPu3p2-_WT07Kovya1ZrnHNMR/contexts/google_assistant_welcome"
                        }
                ],
                "intent": {
                        "name": "projects/jovo-sanity-check-ksgxnt/agent/intents/1197b65c-3a47-4ad8-9f3a-c946680cae53",
                        "displayName": "Default Welcome Intent"
                },
                "intentDetectionConfidence": 1,
                "languageCode": "en"
        },
        "originalDetectIntentRequest": {
                "source": "google",
                "version": "2",
                "payload": {
                        "user": {
                                "locale": "en-US",
                                "lastSeen": "2019-07-11T13:50:34Z",
                                "userStorage": "{\"userId\":\"dacbae17-9a4d-4932-8875-792d6eb215cb\"}",
                                "userVerificationStatus": "VERIFIED"
                        },
                        "conversation": {
                                "conversationId": "ABwppHGQiZbWkyxVYteuEqsAHj9l3OvkO_iJtGCc59FMArFHuIZ6wqf9NUHj8rc2ve-FqaCoPu3p2-_WT07Kovya1ZrnHNMR",
                                "type": "NEW"
                        },
                        "inputs": [
                                {
                                        "intent": "actions.intent.MAIN",
                                        "rawInputs": [
                                                {
                                                        "inputType": "KEYBOARD",
                                                        "query": "Talk to my test app"
                                                }
                                        ]
                                }
                        ],
                        "surface": {
                                "capabilities": [
                                        {
                                                "name": "actions.capability.ACCOUNT_LINKING"
                                        },
                                        {
                                                "name": "actions.capability.SCREEN_OUTPUT"
                                        },
                                        {
                                                "name": "actions.capability.WEB_BROWSER"
                                        },
                                        {
                                                "name": "actions.capability.AUDIO_OUTPUT"
                                        },
                                        {
                                                "name": "actions.capability.MEDIA_RESPONSE_AUDIO"
                                        }
                                ]
                        },
                        "isInSandbox": true,
                        "availableSurfaces": [
                                {
                                        "capabilities": [
                                                {
                                                        "name": "actions.capability.SCREEN_OUTPUT"
                                                },
                                                {
                                                        "name": "actions.capability.AUDIO_OUTPUT"
                                                },
                                                {
                                                        "name": "actions.capability.WEB_BROWSER"
                                                }
                                        ]
                                }
                        ],
                        "requestType": "SIMULATOR"
                }
        },
        "session": "projects/jovo-sanity-check-ksgxnt/agent/sessions/ABwppHGQiZbWkyxVYteuEqsAHj9l3OvkO_iJtGCc59FMArFHuIZ6wqf9NUHj8rc2ve-FqaCoPu3p2-_WT07Kovya1ZrnHNMR"
}
Local server did not return a valid JSON response:
undefined
{
        "fulfillmentText": "Hello World! What's your name?",
        "outputContexts": [],
        "payload": {
                "google": {
                        "expectUserResponse": true,
                        "richResponse": {
                                "items": [
                                        {
                                                "simpleResponse": {
                                                        "ssml": "<speak>Hello World! What's your name?</speak>"
                                                }
                                        }
                                ]
                        },
                        "noInputPrompts": [
                                {
                                        "ssml": "<speak>Please tell me your name.</speak>"
                                }
                        ],
                        "userStorage": "{\"userId\":\"dacbae17-9a4d-4932-8875-792d6eb215cb\"}"
                }
        }
}

Running the invocation again, without restarting the server, results in things working fine.

Same console log minus the:
Local server did not return a valid JSON response:
undefined

When deploying the version that uses Firebase as a cloud function it doesn’t work no matter how many times you invoke it. Once again, i’m seeing this behaviour in code the was deployed fine before so i’m not sure how to fix it.

Here is the repository I was playing with. Master uses Firestore and there is a FileDB branch.


#3

Hi @Marko_Arezina! The Firestore DB integration was built by @Kaan_Kilic, maybe he can take a look and see what could be the problem