Sending Attachments in Discord Messages Using Pipedream Workflow Automation

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

Hi, currently using Pipedream to automate workflows in a Discord server. Specifically, I’m trying to send a message to a Discord channel that includes an attachment from a previous event.
However, I haven’t been able to find a way to do this through the existing features and documentation. Is it possible to send an attachment in a message from a previous event to Discord through Pipedream ?

Hi , I think your question is a great case for Pipedream bot to help. I’ll pass your question to the Pipedream bot now. Please feel free to ask it any question

Hi, currently using Pipedream to automate workflows in a Discord server. Specifically, I’m trying to send a message to a Discord channel that includes an attachment from a previous event.
However, I haven’t been able to find a way to do this through the existing features and documentation. Is it possible to send an attachment in a message from a previous event to Discord through Pipedream ?

Yes, it’s possible to send an attachment in a message to Discord using Pipedream. You can use the “Send Message With File” action in Pipedream to achieve this. Here’s how to use it: 1. Search for the Discord app from the step menu. 2. Select the “Send Message With File” action. 3. Connect your Discord account. To include an attachment from a previous event, you’ll need to pass the file URL or file content from the previous event to the “Send Message With File” action. Make sure the file is accessible and in a supported format by Discord. If you need more advanced options, you can use the “Send Message (Advanced)” action and follow similar steps. For more information on Discord actions in Pipedream, you can visit these links: - Send Message With File: https://pipedream.com/apps/discord/actions/send-message-with-file - Send Message (Advanced): https://pipedream.com/apps/discord/actions/send-message-advanced

Thank you

Hi just wanted to give an update on the issue I’m currently facing. Right now, I’m only able to pick up the attachment ID from the last Discord message, and I’m not able to retrieve the file path or file link. This means that I’m having trouble accessing the file that was attached to the message.So when i try to send message it only sends attachment id to discord instead of sending attachment to discord

so you want to download the attachment from a discord message and send the attachment to another message?

yes

how to download discord attachment using attachment id?

To download a Discord attachment using the attachment ID, you’ll first need to get the attachment URL from the message event. Once you have the attachment URL, you can download the file using an HTTP request. Here’s a Pipedream component that demonstrates how to download an attachment using the attachment URL: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { attachmentUrl: { type: "string", label: "Attachment URL", }, }, async run({ $ }) { const response = await axios($, { method: "GET", url: this.attachmentUrl, responseType: "arraybuffer", // Use this to download binary files }); // Do something with the downloaded file, e.g., save it to a storage service or send it to another Discord channel }, }); To use this component, you’ll need to provide the attachmentUrl prop, which you can obtain from the message event in your Discord workflow. If you don’t have the attachment URL yet, you may need to modify your workflow to capture the attachment URL when a new message with an attachment is received.

how to get the attachment URL when a new message with an attachment is received?

To get the attachment URL when a new message with an attachment is received in Discord, you can use the “New Message (Instant)” trigger in your Pipedream workflow. Here’s how to set it up: 1. Create a new Pipedream workflow. 2. Search for the Discord app from the trigger menu. 3. Select the “New Message (Instant)” trigger. 4. Connect your Discord account. 5. Follow the instructions on the trigger configuration screen. You may need to generate a test event from Discord to get real data to test your workflow. Once the trigger is set up, you can access the attachment URL from the message event. In the steps object, you can find the attachments array, which contains the attachment objects with their URLs. Here’s an example of how to access the attachment URL: ```
const attachmentUrl = steps.trigger.event.attachments[0].url;