How can I remove tweet link from discord webhook?

Whenever I search tweet mentions and try to use a discord webhook it always posts the link too when I use {{steps.trigger.event.full_text}}.

Is there any way to remove this link from the end so I don’t get both the text and then an annoying embed sent to discord?

Hello, @eddiephillips. First of all, welcome to the Pipedream community!

For me to be able to help you, would you mind describing the trigger and actions in your workflow? Screenshots would be a great help!

1 Like

I have the trigger set to search tweets from a specific journalist. Then after this I have a discord webhook that posts the text and image from that tweet to my discord server.

At the moment as the link to the tweet is included at the end of the tweet using {{steps.trigger.event.full_text}} but I can’t figure out a way to remove this from the message in discord so I don’t get a repeat of the tweet in the embed like you can see in the last image.

Thanks for the quick reply!

1 Like

Hi @eddiephillips. This seems like a feature on Discord called Auto-Embed. To disable the Auto-Embed feature on a specific message, you’ll need to wrap all the link with < > (Source).

For example:

To add the <> around the link, I suggest you add a custom Node action to wrap all the links with <> in
the steps.trigger.event.full_text.

The code

// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
  async run({ steps, $ }) {
    // Return data to use it in future steps
    const fullText = steps.trigger.event.full_text
    const urlRegex = /(http|https):\/\/([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?/g
    const transformedFullText = fullText.replace(urlRegex, (link) => {
      return `<${link}>`
    })

    return transformedFullText
  },
})

Then on your Discord send message action, use the $return_value from your node step

I have tested and it works fine on my end

2 Likes

Mate you’re an absolute star, it’s working perfectly! Thanks so much for the help.

2 Likes