Search code examples
dialogflow-cx

DialogFlow Messenger Formatted Text using Custom Payload


How do we send a formatted text like italicized text to the Dialog Flow Messenger using the Custom Payload

when we try the following Custom Payload, it does not format the text properly,

{
  "richContent": [
    [
      {
        "type": "description",
        "title": "Description title",
        "text": [
          "This is text line 1.",
          "<I>This is text line 2.</I>"
        ]
      }
    ]
  ]
}

Thanks in advance!


Solution

  • It might be not formatting correctly because you are using a different JSON formatting for a custom payload, your JSON format should look something like this:

    {
      "facebook": {
        "attachment": {
          "type": "",
          "payload": {}
        }
      },
      "slack": {
        "text": "",
        "attachments": []
      }
    }
    

    You can read more about rich responses and custom payloads in this documentation that Google provides.

    Edit: To italicize text, add one asterisk or underscore before and after a word or phrase

    {
      "richContent": [
        [
          {
            "type": "description",
            "title": "Description title",
            "text": [
              "This is text line 1.",
              "_This is text line 2._"
            ]
          }
        ]
      ]
    }