Embed objects in Discord Webhooks

I get an error message about my script. I read the documentation and applied it to my script, but it still doesn’t work. I wanted to write a Discord webhook message in Embed using structured mode. I also looked at the other topics and they didn’t answer my question. I hope there is enough data for you to tell what I did wrong.

Error message

{
  "embeds": [
    "0"
  ]
}
at null.createError (/opt/ee/node_modules/axios/lib/core/createError.js:16:15)
at null.settle (/opt/ee/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/opt/ee/node_modules/axios/lib/adapters/http.js:236:11)
at IncomingMessage.emit (events.js:412:35)
at null.endReadableNT (internal/streams/readable.js:1334:12)
at process.processTicksAndRejections (internal/process/task_queues.js:82:21)

params

{
  "username": "Fall Guys",
  "avatar_url": "https://cdn.discordapp.com/avatars/787639153168351284/c48818d37c6b12c06244f1231f4aeaa1.webp?size=80",
  "content": "Kleiner Test",
  "embeds": [
    {
      "author": {
        "name": "{{steps.trigger.raw_event.author}}",
        "url": "",
        "icon_url": ""
      },
      "title": "{{steps.trigger.raw_event.title}}",
      "url": "{{steps.trigger.raw_event.permalink}}",
      "description": "Daran wird gearbeitet",
      "color": 65463,
      "fields": [
        {
          "name": "CENSORED",
          "value": "<a:dc_loading:850458386905563206> [Discord Server](CENSORED)",
          "inline": true
        }
      ],
      "thumbnail": {
        "url": "CENSORED"
      },
      "image": {
        "url": "{{steps.trigger.raw_event["rss:enclosure"]["@"].url}}"
      },
      "footer": {
        "text": "Bereitgestellt von CENSORED",
        "icon_url": "https://www.pngall.com/wp-content/uploads/2017/05/Copyright-Symbol-Free-PNG-Image.png"
        "timestamp": "{{steps.trigger.raw_event.pubdate}}"
      }
    }
  ]
}

code

const url = auths.discord_webhook.oauth_uid
let content = params.message
const { embeds, username, avatar_url } = params

if (!content && !embeds) {
  throw new Error("This action expects a message OR an embeds param. Please enter one or the other from the params menu above")
}

return await require("@pipedreamhq/platform").axios(this, {
  method: "POST",
  url,
  headers: {
    "Content-Type": "application/json"
  },
  data: {
    username,
    avatar_url,
    content,
    embeds
  }
})

@switchplay7149 thanks for reaching out. The formatting of your Embeds param is slightly off, and that causes Discord to return an error message. You’ll need to change two things:

  1. Wrap the entire JSON in the Embeds param with {{ }}, like so:
{{ {
  "username": "Fall Guys",
  ...
} }}
  1. Everywhere you have a line that references a variable like this:
"name": "{{steps.trigger.raw_event.author}}",

you’ll want to remove the quotation marks and {{ }} around the variable:

"name": steps.trigger.raw_event.author,

The way you have it now, Pipedream sends the literal value "{{steps.trigger.raw_event.author}}" instead of the actual value that variable references (e.g. “Luke”).

Let me know if that helps.

Als ich ihren Schritten gefolgt bin, habe ich einen SyntaxError erhalten.

error

SyntaxError: Unexpected identifier
    at _pd_deep_evaluate (/opt/nodejs/node_modules/@pipedreamhq/execution-environment/params_evaluator.js:57:36)
    at _pd_deep_evaluate (/opt/nodejs/node_modules/@pipedreamhq/execution-environment/params_evaluator.js:38:7)
    at MessagePort.<anonymous> (/opt/nodejs/node_modules/@pipedreamhq/execution-environment/params_evaluator.js:11:9)
    at MessagePort.[nodejs.internal.kHybridDispatch] (internal/event_target.js:399:24)
    at MessagePort.exports.emitMessage (internal/per_context/messageport.js:18:26)

modified parms

{{ {
  "username": "Fall Guys",
  "avatar_url": "https://cdn.discordapp.com/avatars/787639153168351284/c48818d37c6b12c06244f1231f4aeaa1.webp?size=80",
  "content": "Kleiner Test",
  "embeds": [
    {
      "author": {
        "name": steps.trigger.raw_event.author,
        "url": "",
        "icon_url": ""
      },
      "title": steps.trigger.raw_event.title,
      "url": steps.trigger.raw_event.permalink,
      "description": "Daran wird gearbeitet",
      "color": 65463,
      "fields": [
        {
          "name": "CENSORED",
          "value": "<a:dc_loading:850458386905563206> [Discord Server](CENSORED)",
          "inline": true
        }
      ],
      "thumbnail": {
        "url": "CENSORED"
      },
      "image": {
        "url": steps.trigger.raw_event["rss:enclosure"]["@"].url
      },
      "footer": {
        "text": "Bereitgestellt von CENSORED",
        "icon_url": "https://www.pngall.com/wp-content/uploads/2017/05/Copyright-Symbol-Free-PNG-Image.png"
        "timestamp": steps.trigger.raw_event.pubdate
      }
    }
  ]
} }}

Should it really start with {{ { and end with } }}? I don’t know my way around, but it looks { {{ more logical to me, or have I forgotten a detail again?

Maybe that’s it?