This is very simplistic and fast written tool that allows me to relay messages from the discord bot to an POST webhook, like for N8N.
You define the commands in the appsettings.json file with the target endpoint and needed information.
When you then send the command in the channel or direct message it to your bot, the command will be picked up and be translated to a http post request with the following model:
public class HttpPayload
{
[JsonPropertyName("command")]
public required string Command { get; set; }
[JsonPropertyName("argument")]
public string? Argument { get; set; }
[JsonPropertyName("userId")]
public required ulong UserId { get; set; }
[JsonPropertyName("userName")]
public required string UserName { get; set; }
[JsonPropertyName("channelId")]
public required ulong ChannelId { get; set; }
[JsonPropertyName("isDirectMessage")]
public required bool IsDirectMessage { get; set; }
}Every thing after the command will we sent as argument in the payload for the endpoint to process.
The endpoint then can sendback no content or an string that the bot will then send back to the discord channel as reaction on the initial command.
"Discord": {
"ClientId": "<your bot client id>",
"Token": "<your bot token>",
"CommandPrefix": "!" // optional: the prefix for the message to react on
},
"Commands": [{
"Command": "webhooktest",
"WebhookUrl": "<your post endpoint>",
"AllowedChannelIds": [], // optional: channel ids in which the command is allowed
"HelpText": "Sends a test message to the configured webhook."
}]This project uses https://netcord.dev/ for the discord bot implementation part.