Dialogflow-fulfillment-nodejs: Agent is not working in alpha deployment but is working in test deployment

Created on 10 Feb 2019  路  9Comments  路  Source: dialogflow/dialogflow-fulfillment-nodejs

const { WebhookClient } = require("dialogflow-fulfillment");
const agent = new WebhookClient({ request, response });

agent.context.get('context').parameters.param <= The get api does not work in alpha deployment

Most helpful comment

Yes. We did a workaround by modify the contexts.js in dialogflow-fulfilment library.

      const name = context['name'].split('/')[6];

in _processV2InputContexts is changed to

      const splittedName = context['name'].split('/');
      const name = splittedName[splittedName.indexOf('contexts') + 1];

Reference:
https://github.com/dialogflow/dialogflow-fulfillment-nodejs/issues/187#issuecomment-508493169

All 9 comments

I also encounter similar problem.
agent.context.get('actions_intent_permission') is working on development, but once it goes to alpha testing agent.context.get('actions_intent_permission') returns undefined. My Google action review gets rejected due to this error.

This may give more context about the issue.

I debug Context value in alpha and test environment.
Context in alpha release has different values (almost nothing) compare to that in test simulator environment. It seems that there are a bug in alpha release environment (or changes in json response format) which makes agent.context.get('actions_intent_permission') return undefined.

Please find context value in alpha and test environment below. This is the value after a user responds to actions_intent_PERMISSION intent (asking full name and precise location).

Context in alpha release

Context {
  contexts:
   { '-': { name: '-', lifespan: undefined, parameters: undefined } },
  session:
   '<SESSION_STRING>',
  inputContexts:
   { '-': { name: '-', lifespan: undefined, parameters: undefined } } }

Context in test simulator environment

Context {
  contexts:
   { actions_capability_screen_output:
      { name: 'actions_capability_screen_output',
        lifespan: undefined,
        parameters: undefined },
     actions_intent_permission:
      { name: 'actions_intent_permission',
        lifespan: undefined,
        parameters: [Object] },
     actions_capability_audio_output:
      { name: 'actions_capability_audio_output',
        lifespan: undefined,
        parameters: undefined },
     google_assistant_input_type_keyboard:
      { name: 'google_assistant_input_type_keyboard',
        lifespan: undefined,
        parameters: undefined },
     actions_capability_web_browser:
      { name: 'actions_capability_web_browser',
        lifespan: undefined,
        parameters: undefined },
     actions_capability_media_response_audio:
      { name: 'actions_capability_media_response_audio',
        lifespan: undefined,
        parameters: undefined } },
  session:
   '<SESSION_STRING>',
  inputContexts:
   { actions_capability_screen_output:
      { name: 'actions_capability_screen_output',
        lifespan: undefined,
        parameters: undefined },
     actions_intent_permission:
      { name: 'actions_intent_permission',
        lifespan: undefined,
        parameters: [Object] },
     actions_capability_audio_output:
      { name: 'actions_capability_audio_output',
        lifespan: undefined,
        parameters: undefined },
     google_assistant_input_type_keyboard:
      { name: 'google_assistant_input_type_keyboard',
        lifespan: undefined,
        parameters: undefined },
     actions_capability_web_browser:
      { name: 'actions_capability_web_browser',
        lifespan: undefined,
        parameters: undefined },
     actions_capability_media_response_audio:
      { name: 'actions_capability_media_response_audio',
        lifespan: undefined,
        parameters: undefined } } }

Please advise. Thank you.

Found that this is caused by #187.

Hey @philipskokoh - did you end up solving this issue? We are facing the same problem

Yes. We did a workaround by modify the contexts.js in dialogflow-fulfilment library.

      const name = context['name'].split('/')[6];

in _processV2InputContexts is changed to

      const splittedName = context['name'].split('/');
      const name = splittedName[splittedName.indexOf('contexts') + 1];

Reference:
https://github.com/dialogflow/dialogflow-fulfillment-nodejs/issues/187#issuecomment-508493169

Yes. We did a workaround by modify the contexts.js in dialogflow-fulfilment library.

      const name = context['name'].split('/')[6];

in _processV2InputContexts is changed to

      const splittedName = context['name'].split('/');
      const name = splittedName[splittedName.indexOf('contexts') + 1];

Reference:
#187 (comment)

Hey @philipskokoh - Thanks mate! that fixed our issue!!
But we now have the issue further down the conversation flow - the Context setting now works, but when it gets down to the next level (we have two levels of the contextual dialog) it ends up with the same issue (Context levels not being populated correctly in request from google actions)

Any advice?

Sorry, I do not have such use cases. I can't suggest any solution / workaround for this case.

Yes. We did a workaround by modify the contexts.js in dialogflow-fulfilment library.

      const name = context['name'].split('/')[6];

in _processV2InputContexts is changed to

      const splittedName = context['name'].split('/');
      const name = splittedName[splittedName.indexOf('contexts') + 1];

Reference:
#187 (comment)

Thanks @philipskokoh,
Does that mean you have necessarily to deploy your own Webhook and cannot use DialogFlow inline editor?
Thanks,
Jean-Jacques

Hi @JeanJacques31 , I do not use Dialogflow inline editor in the first place.
I think deploying your own Webhook gives your more flexibility than using inline editor. Dialogflow inline editor is only useful for simple use case in my opinion. Once your dialog becomes complex, it's better to have our own Webhook.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jzxhuang picture jzxhuang  路  6Comments

drishit96 picture drishit96  路  6Comments

SiddAjmera picture SiddAjmera  路  8Comments

omfd picture omfd  路  6Comments

sarupbanskota picture sarupbanskota  路  3Comments