Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Dialogflow Messenger and richcontent from a webhook

Hi,

I'm trying to add a fulfilment response using Webhook.

I built a kind of simple Python API with Flask to provide a rich content answer to Dialogflow.

The problem is that Dialogflow accepts only messages and not richcontents from my API. ( not rendering, for example, chips).

Here is my code :

 

def answer_webhook():
    message= {"fulfillment_response": {
      
        "messages": [
        {
          "text": {
            "text": "My text here"
          }
        }
      ],"richContent": [
    [
      {
        "type": "description",
        "title": "Description title",
        "text": [
          "This is text line 1.",
          "This is text line 2."
        ]
      }
    ]
  ]
      
    }
    }
    return Response(json.dumps(message), 200, mimetype='application/json')

 

I tried different ways to write or construct the JSON, but nothing works 

Could you please advise, knowing that I'm testing on an embedded Dialogflow Messenger UI

Thanks

Yassine

0 1 810
1 REPLY 1

 Hi @yassinekoubaa 

Welcome to Google Cloud Community.

The format of the response you are providing back to Dialogflow appears to be the potential source of the problem. As a message object rather than a separate element in the fulfillment_response, the richContent field should be included. The richContent can be added to your code as a message object. You may create a code wherein the richContent is included as a payload in a separate message object, along with the regular text message object.

Verify that the Dialogflow API version you're using supports rich content. Dialogflow API versions 2 and higher are the only ones that enable rich content.