question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to send custom Payload from Dialogflow fulfilment

See original GitHub issue

I am trying to send custom payload from the webhook (Firebase Cloud Function) but I am not able to achieve what I am trying. In response I wanna get something like:

"fulfillmentMessages": [
    {
      "text": {
        "text": [
          "First question."
        ]
      }
    },
    {
      "text": {
        "text": [
          "What is your name?"
        ]
      }
    },
    "payload": {
      "deplay": "13 seconds"
    }
  ]

But right now I don’t know how to add Payload in the fulfillmentMessages Array. My current code is:

let response = ['First question.', 'What is your name?'];
agent.add(response);

I have tried this

agent.add(new Payload('PLATFORM_UNSPECIFIED', JSON.stringify(json)));

But then it does not send fulfillmentMessages array. Any solution?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:11

github_iconTop GitHub Comments

26reactions
s22sucommented, Nov 20, 2019

In package.json: "dialogflow-fulfillment": "^0.5.0" —> "dialogflow-fulfillment": "^0.6.1"

Thanks @HSpens works as expected after update. Just for others who Google the same thing, the code to send custom payload is:

// const { Payload } = require("dialogflow-fulfillment");

const payload = {
  key: 'value',
  key2: 2
};

agent.add(
  new Payload(agent.UNSPECIFIED, payload, {rawPayload: true, sendAsMessage: true})
);
6reactions
ParticleDualitycommented, Mar 2, 2020

In package.json: "dialogflow-fulfillment": "^0.5.0" —> "dialogflow-fulfillment": "^0.6.1"

Thanks @HSpens works as expected after update. Just for others who Google the same thing, the code to send custom payload is:

// const { Payload } = require("dialogflow-fulfillment");

const payload = {
  key: 'value',
  key2: 2
};

agent.add(
  new Payload(agent.UNSPECIFIED, payload, {rawPayload: true, sendAsMessage: true})
);

God, man I was trying so hard to find a solution and this code resolved my issue. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fulfillments | Dialogflow CX - Google Cloud
Some integrations support a custom payload response to handle rich responses. These custom payloads are supplied in a JSON format defined in the...
Read more >
Custom payload in Dialogflow - node.js - Stack Overflow
i try to send custom payload in Dialogflow from fulfillment(nodejs). My motive is send link and its text as response to web page....
Read more >
How to setup Fulfillment Response in Dialogflow
We use a custom payload for carousel response here. Payload has two top-level fields - one types & the other is items. Type...
Read more >
CX Webhook response as custom payloads - Google Groups
to Dialogflow CX Edition users. Why my webhook payloads not showing as buttons? the object I'm sending from webhook: {. fulfillment_response: {. messages:...
Read more >
How to Send Image with Dialogflow - Level Up Coding
This article will describe how to send an image using Dialogflow ... Get Dialogflow agent fulfillment library (NodeJS) by using the following command:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found