Home / DialogFlow ES / How to send rich responses from webhook to Dialogflow Messenger
DialogFlow ES | Website Bots

How to send rich responses from webhook to Dialogflow Messenger

Website Name Change

I have changed the name of this website from Mining Business Data to BotFlo. I am offering a 40% off discount on both my Dialogflow ES and Dialogflow CX courses till end of April 2021 for people who can help me spread the word about my new website.

Recently, I got this question on YouTube:

i have added rich responses code in my dialogflow fulfillment. but when i am testing with dialogflow messanger integration, it is not diaplaying any images, cards on dialogflow messanger. Can you tell me what version i need to use?

Based on the question, I suppose this person is using the Dialogflow fulfillment library.

I recommend people avoid using the fulfillment libraries for Dialogflow unless they are building a voice bot. Since this question is about Dialogflow Messenger, it is recommended that you don’t use the fulfillment library.

There are three reasons why I recommend you avoid the fulfillment library:

a) it makes things unnecessarily opaque

b) the fulfillment library is rarely up to date with the latest features

c) if something in the fulfillment library doesn’t work, you will end up doing MUCH MORE work than if you had just avoided it in the first place

So what do I recommend instead?

I suggest simply understanding the JSON format of the response and constructing it in your code. This way, it is much easier to maintain over time.

The steps are fairly straight forward:

1 First type out the appropriate JSON inside your Custom Payload block (i.e. first hard code the response)

2 Trigger the intent in the Dialogflow Messenger

3 From the History module, get the JSON which was sent as a response

4 Paste this JSON into your webhook response generator code (and make suitable updates so it is dynamic)

In my Dialogflow Messenger Quickstart course (paid), I provide an example of how to do this using Python.

Using this approach will give you 100% control over your own code and will actually speed up your overall bot development speed if you are using Python. Even if you are not using Python, the code is actually very simple and it should be straight forward to translate it to NodeJS.

Python Webhook Tutorial

Understanding the Custom Payload Part 1

Understanding the Custom Payload Part 2

Understanding the Custom Payload Part 3

Trigger the static response
Get response object from history
Send rich response from webhook

"The magic key I needed as a non-programmer"

The custom payload generator was the magic key I needed (as a non-programmer) to build a good demo with rich responses in DialogFlow Messenger. I've only used it for 30 minutes and am thrilled. I've spent hours trying to figure out some of the intricacies of DialogFlow on my own. Over and over, I kept coming back to Aravind's tutorials available on-line. I trust the other functionalities I learn to use in the app will save me additional time and heartburn.

- Kathleen R
Cofounder, gathrHealth

Similar Posts