dialogflow-fulfillment-nodejs icon indicating copy to clipboard operation
dialogflow-fulfillment-nodejs copied to clipboard

Agent is not working in alpha deployment but is working in test deployment

Open ajjgabriel opened this issue 6 years ago • 9 comments

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

ajjgabriel avatar Feb 10 '19 15:02 ajjgabriel

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.

philipskokoh avatar Feb 12 '19 04:02 philipskokoh

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.

philipskokoh avatar Feb 12 '19 04:02 philipskokoh

Found that this is caused by #187.

philipskokoh avatar Feb 12 '19 05:02 philipskokoh

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

juno-vate avatar Oct 10 '19 09:10 juno-vate

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

philipskokoh avatar Oct 10 '19 10:10 philipskokoh

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?

juno-vate avatar Oct 14 '19 07:10 juno-vate

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

philipskokoh avatar Oct 15 '19 03:10 philipskokoh

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

JeanJacques31 avatar Sep 21 '20 14:09 JeanJacques31

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.

philipskokoh avatar Sep 22 '20 06:09 philipskokoh