400 error trying to send Discord message with embeds

This topic was automatically generated from Slack. You can find the original thread here.

Nick Nelson : Happy Sunday! I was looking at formatting a message to send to a discord webhook. I followed the format that you have on the website but I keep getting a 400 error saying it can’t interpret that as a string. I don’t know if it’s maybe because I’m using variable names next to title: and description: but they’re string variables so I would’ve thought that’d be fine. Thanks in advance!

Dylan Sather (Pipedream) : Hi , would you mind sharing your workflow with dylan@pipedream.com? Just click the Share button in the top-right corner. I can take a look to help you troubleshoot

Nick Nelson : There you go! Sorry for the slower response than you gave! Started making dinner

Dylan Sather (Pipedream) : No problem. I believe you’ll need to pass the data in {{steps.generate_message.msg}} to the Embeds parameter, not the Message parameter.

The Message param expects a simple string like “Hello world”. If you want the title / description to be interpreted and displayed in the Discord message, the Embeds param will do that for you.

Go ahead and try removing the Message param and try adding this to Embeds:

Nick Nelson : I had actually tried that, but I did again just now and this is what happens when I do that

Nick Nelson :

Dylan Sather (Pipedream) : Can you try turning structured mode off and entering the same exported value in the Embeds field?

Nick Nelson : Will do!

Nick Nelson : That did it

Nick Nelson : Thank you

Nick Nelson : Actually, follow up since I’ve got you. If you know off the top of your head… the embedded picture isn’t showing. Is that even possible via sending the message the way that I am?

Dylan Sather (Pipedream) : I believe you may want it in the field image.url, based on a read of the format here: https://discordjs.guide/popular-topics/embeds.html#using-an-embed-object

Dylan Sather (Pipedream) : I am not a Discord embeds expert haha but hopefully the reference helps

Nick Nelson : I’ll read up more on it. Thank you again. I appreciate your getting that to work. It looks a lot better having that formatting for sure

Nick Nelson : One final question (for now). Let’s say I’m looking at two different locations and if the message comes from one location vs the other I want to stop the script and not send the message. I tried using $end in a couple places but it didn’t seem to stop the script. Sorry for the nooby questions. I’ll keep looking through the documentation as well

Dylan Sather (Pipedream) : No worries. $end() should stop the execution of the workflow as soon as that line is run. Could you try adding a console.log message just above the $end to see if that runs? My first guess is that your code may not be hitting that condition, and that’s why $end isn’t getting triggered.

Nick Nelson : Nevermind I’m dumb

Nick Nelson : I didn’t have the () at the end of end

Nick Nelson : Alrighty, now I’ll really leave you alone for now. Have a great night and thank you so much for your help!

Dylan Sather (Pipedream) : No problem, reach out anytime!