Support » Plugin: Notification - Custom Notifications and Alerts for WordPress » Un-encoded post_content in JSON

  • hellotrio

    (@hellotrio)


    I’m trying to send a published post with it’s post title and post content via a JSON webhook to Discord. Here is the JSON:

    {
      "content": "",
      "embeds": [
        {
          "title": "**{post_title}**",
          "description": "{post_content}",
          "color": null
        }
      ]
    }

    This is the output from the notification log:

    {
      "content": "",
      "embeds": [
        {
          "title": "**Answer**",
          "description": "The correct answer is C. On initial contact with Approach, aircraft are expected to make their approach request. \n \n 6.8.3 — […] If the aircraft has already been cleared to descend via the STAR from a previous Controller, it will be visible on their flight progress strip (see 6.6.11 above), Approach Controllers should respond with “Continue as Filed, Expect the [approach type/runway] at [location]” if they wish the aircraft to continue as previously cleared. If the aircraft was previously receiving vectors, was not approved for descent via the STAR or the Controller wants to issue vectors/altitude assignments, then “Expect Vectors for the [approach type/runway] at [location]” should be used instead. In the absence of Center, aircraft who have already begun their initial descent via a STAR may continue their descent with the response “Continue as Filed, Expect the [approach type/runway] at [location]” without a specific descent via clearance […]",
          "color": null
        }
      ]
    }

    And this is what the notification looks like in Discord: https://ibb.co/g42QV4B

    Two issues.

    1. Line-breaks aren’t being added so I have to manually add \\n to the blog post so that the notification will add the line breaks, which isn’t ideal.

    2. For some reason, and I’ve searched everywhere for how to fix this, the post_content is un-encoding characters once it is being sent to Discord. See the screenshot from Discord above.

    How can I resolve these two issues?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Kuba Mikita

    (@kubitomakita)

    Have you tried to use {post_content_html} merge tag? That could help with the encoding and line breaks because it will be formatted at that time

    Thread Starter hellotrio

    (@hellotrio)

    Yes, I tried that. It adds the line-breaks but it also includes the html <p> tags and any other html tags. Once those are added Discord doesn’t accept it and the notification isn’t sent.

    Plugin Author Kuba Mikita

    (@kubitomakita)

    I see, that makes sense.

    I can see two possible solutions:

    • Create a custom merge tag that’ll process the post content into format that’s consumable by Discord. You could even use lib like “HTML to Markdown” to make it fully automatic and support text formats, links, etc.
    • Use our Notification : Discord extension that already has the HTML entity decoding functions implemented but we could also introduce the Markdown conversion within our support

    I hope this helps!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.