dialogflow / dialogflow-fulfillment-nodejs

Dialogflow agent fulfillment library supporting v1&v2, 8 platforms, and text, card, image, suggestion, custom responses
Apache License 2.0
597 stars 281 forks source link

Not getting context & parameter data in return request which is sent in previous response. #272

Closed rajatlutade closed 4 years ago

rajatlutade commented 4 years ago

We are using "dialogflow-fulfillment" npm package of version "^0.6.1" to build the dialogflow v2 based FB bot, however, we are sending the custom payload with context and its lifespan as well as with context param data as well below, To send the below object we using built-in function of the package app.response_.json(responseJSON) responseJSON:- {"fulfillmentMessages":[{"text":{"text":[" Hello Rajat. Welcome back to Pizza Hut! Let’s find the best pizza for you."]},"platform":"FACEBOOK"},{"quickReplies":{"title":"","quickReplies":["New Order","Reorder"]},"platform":"FACEBOOK"}],"outputContexts":[{"name":"projects/pizza-hut-test-b2523/agent/sessions/af1d6905-604a-40a8-90e1-08275040107e/contexts/test","lifespan":3,"parameters":{"key1":123}}]}

Well, the custom payload is working fine and showing message response on FB but again in the next return request, we are expecting to get the "outputContext" object in the request to webhook through dialogflow. But we not getting that context data in request to webhook. Context object is missing. Object to be get:-> "outputContexts":[{"name":"projects/pizza-hut-test-b2523/agent/sessions/af1d6905-604a-40a8-90e1-08275040107e/contexts/test","lifespan":3,"parameters":{"key1":123}}]}

Next request payload: {"responseId":"6758b38f-995e-44a9-80e5-67148cc7f1f3-2a4c0c5e","queryResult":{"queryText":"New Order","action":"getOrderType","parameters":{"orderType":"NEW_ORDER"},"allRequiredParamsPresent":true,"outputContexts":[{"name":"projects/pizza-hut-test-b2523/agent/sessions/af1d6905-604a-40a8-90e1-08275040107e/contexts/get_order","parameters":{"orderType":"NEW_ORDER","orderType.original":"New Order"}},{"name":"projects/pizza-hut-test-b2523/agent/sessions/af1d6905-604a-40a8-90e1-08275040107e/contexts/generic","lifespanCount":4,"parameters":{"facebook_sender_id":"1958790894231009","orderType":"NEW_ORDER","orderType.original":"New Order"}}],"intent":{"name":"projects/pizza-hut-test-b2523/agent/intents/4887fde6-c6a3-437b-bd18-fd3397687f36","displayName":"get-order-type"},"intentDetectionConfidence":1,"languageCode":"en"},"originalDetectIntentRequest":{"source":"facebook","payload":{"data":{"recipient":{"id":"112608265447380"},"message":{"mid":"7Z0I-rxMasidBazLQMK1uba05nTmmWy9em_VWzaNhiHxImBsFiYBCcuezWJJQv_lWFBj6cSdK079R81vVDugyQ","quick_reply":{"payload":"New Order"},"text":"New Order"},"timestamp":1570292451493,"sender":{"id":"1958790894231009"}},"source":"facebook"}},"session":"projects/pizza-hut-test-b2523/agent/sessions/af1d6905-604a-40a8-90e1-08275040107e"} Where in above request payload, the "test" context send from webhook in the response is missing, and only new contexts which set in the dialogflow intent "get-order-type" we are getting.

Please ASAP let us know how to resolve this issue? Please take this as a priority we are moving to production and facing this issue.

rajatlutade commented 4 years ago

use lifespanCount instead of lifespan