← Discord Webhook

Send Message With File with Discord Webhook API

Pipedream makes it easy to connect APIs for Discord Webhook and 900+ other apps remarkably fast.

Trigger workflow on
HTTP requests, schedules and app events
Next, do this
Send Message With File with the Discord Webhook API
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜
Trusted by 250,000+ developers from startups to Fortune 500 companies:
Trusted by 250,000+ developers from startups to Fortune 500 companies

Developers Pipedream

Getting Started

Create a workflow to Send Message With File with the Discord Webhook API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the Send Message With File action
    1. Connect your Discord Webhook account
    2. Optional- Configure Message
    3. Optional- Configure Thread ID
    4. Optional- Configure Username
    5. Optional- Configure Avatar URL
    6. Optional- Configure Include link to workflow
    7. Optional- Configure File URL
    8. Optional- Configure File Path
  2. Select a trigger to run your workflow on HTTP requests, schedules or app events
  3. Deploy the workflow
  4. Send a test event to validate your setup
  5. Turn on the trigger

Integrations

Send Message With File with Discord Webhook API on New Requests (Payload Only) from HTTP / Webhook API
HTTP / Webhook + Discord Webhook
 
Try it
Send Message With File with Discord Webhook API on New Item in Feed from RSS API
RSS + Discord Webhook
 
Try it
Send Message With File with Discord Webhook API on New Message from Discord API
Discord + Discord Webhook
 
Try it
Send Message With File with Discord Webhook API on New Message In Channels from Slack API
Slack + Discord Webhook
 
Try it
Send Message With File with Discord Webhook API on New Message in Channel from Discord Bot API
Discord Bot + Discord Webhook
 
Try it

Details

This is a pre-built, open source component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Send Message With File on Discord Webhook
Description:Post a message with an attached file
Version:0.2.1
Key:discord_webhook-send-message-with-file

Code

import common from "../send-message-common.mjs";
import axios from "axios";
import fs from "fs";

export default {
  ...common,
  key: "discord_webhook-send-message-with-file",
  name: "Send Message With File",
  description: "Post a message with an attached file",
  version: "0.2.1",
  type: "action",
  props: {
    ...common.props,
    message: {
      propDefinition: [
        common.props.discordWebhook,
        "message",
      ],
      optional: true,
    },
    fileUrl: {
      type: "string",
      label: "File URL",
      description:
        "The URL of the file to attach. Must specify either **File URL** or **File Path**.",
      optional: true,
    },
    filePath: {
      type: "string",
      label: "File Path",
      description:
        "The path to the file, e.g. `/tmp/myFile.csv`. Must specify either **File URL** or **File Path**.",
      optional: true,
    },
  },
  async run({ $ }) {
    const {
      message,
      avatarURL,
      threadID,
      username,
      fileUrl,
      filePath,
      includeSentViaPipedream,
    } = this;

    if (!fileUrl && !filePath) {
      throw new Error("This action requires either File URL or File Path. Please enter one or the other above.");
    }

    const file = fileUrl
      ? (await axios({
        method: "get",
        url: fileUrl,
        responseType: "stream",
      })).data
      : fs.createReadStream(filePath);

    try {
      // No interesting data is returned from Discord
      await this.discordWebhook.sendMessageWithFile({
        avatarURL,
        threadID,
        username,
        file,
        content: includeSentViaPipedream
          ? this.appendPipedreamText(message ?? "")
          : message,
      });
      $.export("$summary", "Message sent successfully");
    } catch (err) {
      const unsentMessage = this.getUserInputProps();
      $.export("unsent", unsentMessage);
      throw err;
    }
  },
};

Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
Discord WebhookdiscordWebhookappThis component uses the Discord Webhook app.
Messagemessagestring

Enter a simple message up to 2000 characters. This is the most commonly used field. However, it's optional if you pass embed content.

Thread IDthreadIDstring

If provided, the message will be posted to this thread

Usernameusernamestring

Overrides the current username of the webhook

Avatar URLavatarURLstring

If used, it overrides the default avatar of the webhook. Note: Consecutive posts by the same username within 10 minutes of each other will not display updated avatar.

Include link to workflowincludeSentViaPipedreamboolean

Defaults to true, includes a link to this workflow at the end of your Discord message.

File URLfileUrlstring

The URL of the file to attach. Must specify either File URL or File Path.

File PathfilePathstring

The path to the file, e.g. /tmp/myFile.csv. Must specify either File URL or File Path.

Authentication

Discord Webhook uses OAuth authentication. When you connect your Discord Webhook account, Pipedream will open a popup window where you can sign into Discord Webhook and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Discord Webhook API.

Pipedream requests the following authorization scopes when you connect your account:

webhook.incomingemailidentify

About Discord Webhook

Use this app to send messages to a channel using Discord's incoming webhooks

More Ways to Use Discord Webhook

Actions

Send Message with the Discord Webhook API

Send a simple message to a Discord channel

 
Try it
Send Message (Advanced) with the Discord Webhook API

Send a simple or structured message (using embeds) to a Discord channel

 
Try it