← Discord Webhook

Send Message With File with Discord Webhook API

Pipedream makes it easy to connect APIs for Discord Webhook and + 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
Trusted by 200,000+ developers from startups to Fortune 500 companies:
Trusted by 200,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 File URL
    7. 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

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.0.1
Key:discord_webhook-send-message-with-file

Code

const discordWebhook = require("../../discord_webhook.app.js");
const axios = require("axios");
const fs = require("fs");

module.exports = {
  key: "discord_webhook-send-message-with-file",
  name: "Send Message With File",
  description: "Post a message with an attached file",
  version: "0.0.1",
  type: "action",
  props: {
    discordWebhook,
    message: {
      propDefinition: [
        discordWebhook,
        "message",
      ],
      optional: true,
    },
    threadID: {
      propDefinition: [
        discordWebhook,
        "threadID",
      ],
    },
    username: {
      propDefinition: [
        discordWebhook,
        "username",
      ],
    },
    avatarURL: {
      propDefinition: [
        discordWebhook,
        "avatarURL",
      ],
    },
    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: content,
      avatarURL,
      threadID,
      username,
      fileUrl,
      filePath,
    } = 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);

    // No interesting data is returned from Discord
    const resp = await this.discordWebhook.sendMessageWithFile({
      content,
      avatarURL,
      threadID,
      username,
      file,
    });

    $.export("$summary", "Message sent successfully");

    return resp;
  },
};

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

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

About Pipedream

Stop writing boilerplate code, struggling with authentication and managing infrastructure. Start connecting APIs with code-level control when you need it — and no code when you don't.

Into to Pipedream
Watch us build a workflow
Watch us build a workflow
4 min
Watch now ➜
"The past few weeks, I truly feel like the clichéd 10x engineer."
@heyellieday
Powerful features that scale
Manage concurrency and execution rate
Manage concurrency and execution rate

Queue up to 10,000 events per workfow and manage the concurrency and rate at which workflows are triggered.

Process large payloads up to 5 terabytes
Process large payloads up to 5 terabytes

Large file support enables you to trigger workflows with any data (e.g., large JSON files, images and videos) up to 5 terabytes.

Return custom responses to HTTP requests
Return custom responses to HTTP requests

Return any JSON-serializable response from an HTTP triggered workflow using $respond().

Use most npm packages
Use most npm packages

To use any npm package, just require() it -- there's no npm install or package.json required.

Maintain state between executions
Maintain state between executions

Use $checkpoint to save state in one workflow invocation and read it the next time your workflow runs.

Pass data between steps
Pass data between steps

Return data from any step to inspect it in a human-friendly way and reference the data in future steps via the steps object.