dialogflow / dialogflow-fulfillment-nodejs

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

Suggestion and Payload do not work with new Dialogflow Facebook callback url #306

Open ioannist opened 4 years ago

ioannist commented 4 years ago

Dialogflow has announced that all Facebook integrations have to switch to a new callback URL of the type: https://dialogflow.cloud.google.com/v1/integrations/facebook/webhook/####################

Old URLs still work, but they will automatically forward to the new URL at the end of June 2020.

I was testing the new callback URL and I found that my Payload and Suggestion responses do not work.

const { WebhookClient, Payload, Suggestion } = require('dialogflow-fulfillment');
const agent = new WebhookClient({ request, response });
agent.add(new Payload(agent.FACEBOOK, validCarouselObject));

The responses work fine with the old URL (went back and forth multiple times). Any idea what may be causing this?

ioannist commented 4 years ago

Had a chat with Dialogflow support team on this one. Their response:

Regarding the payload object in the nodejs fulfillment library, I was able to reproduce your issue but have to conduct further investigation to narrow the scope of the issue. At the moment, I can confirm that if you provide the custom payload response in the intent's Response section, it will correctly send the payload and display the roulette. This may be feasible for you if the contents of the roulette are static or fixed.

ioannist commented 4 years ago

Solved this today (last day before the switch)

For Payload, we have to turn on the sendAsMessage flag

    agent.add(
      new Payload(agent.FACEBOOK, carousel, {
        sendAsMessage: true,
        rawPayload: false,
      })
    );

For Suggestions, unfortunately, there is no flag. The only solution I found was to reconstruct the Suggestion as a Quick Reply (for Facebook) and send it as a Payload with the sendAsMessage flag set to true.

    agent.add(
      new Payload(agent.FACEBOOK,
      {
        "text": "Pick a color:",
        "quick_replies": [ ... ] // see https://developers.facebook.com/docs/messenger-platform/reference/buttons/quick-replies
      },
      {
        sendAsMessage: true,
        rawPayload: false,
      })
    );
imasif commented 2 years ago

@ioannist can you put carousal code here, please?

hammad-air commented 1 year ago

Currently, I am facing issue when I add agent.add(new Suggestion('Yes')).

It is not working when i check it on DialogFlow Messenger (Website chatbot integration one)