Slack API Webhooks

Hey! I have created a simple Slack API module that allows you to send Webhooks to your slack server. This will go through a step by step tutorial on creating your webhook then configuring it to the module. It is fairly simple so lets get started!

Step 1

Go to Slack API: Applications | Slack and create and app, name it and choose a workspace!

Step 2

Now lets make the web hook known as a webhook, click Incoming Webhooks

Step 3
Enable the webhook my pressing the switch on the top right.

image

Step 4

At the bottom press Add New Webhook to Workspace

image

Step 5

Choose the channel you want to add the webhook to.

image

Press Authorize

You should then get this message in the channel that you authorized the webhook in.

image

Module Steps

Step 6

Insert the module inside of your game in ServerScriptService

Step 7

Create a script in ServerScriptService and add the following code

local SlackAPI = require(game:GetService("ServerScriptService"):WaitForChild("SlackAPI"))

This code allows us to interact with our module!

Step 8

Create the webhook integration

Let us look into our webhook links by going back to the page where we initially created our webhook. You should now see a new webhook there! Press Copy

image

My URL is: https://hooks.slack.com/services/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

I don’t exactly know the names for each individual part of the URL so I decided to make my own. this is what each one represents.

id1: TG1MF5V0D
id2: BG2UHGD46
id3: UAVmxDDjNKwypTUEapNaaZjc

Now that we understand what each part of the URL stands for let us create the webhook, to do this the function is SlackAPI.new(id1, id2, id3) so our code would look like:

local SlackAPI = require(game:GetService("ServerScriptService"):WaitForChild("SlackAPI"))

local Webhook = SlackAPI.new("TG1MF5V0D","BG2UHGD46","UAVmxDDjNKwypTUEapNaaZjc")

Step 9
This is the last and easiest step of all! To send a webhook all you need to do is take the Webhook and use the :Send function so to send something like Hello! you just would use the code Webhook:Send(“Hello1”) and it would send! Your code should look like this:

local SlackAPI = require(game:GetService("ServerScriptService"):WaitForChild("SlackAPI"))

local Webhook = SlackAPI.new("TG1MF5V0D","BG2UHGD46","UAVmxDDjNKwypTUEapNaaZjc")

Webhook:Send("Hello!")

NOTE: All of the webhook data was erased on uploading this tutorial. Attempting to use the same data will result in errors.

21 Likes

A similar process works with Discord Webhooks, but you need a separate website to do the work, like Zapier. Kind of wish Discord also had more freedom and ease of use when it came to bots and webhooks, but alas, we are out of luck.

(Obviously Discord is about to kick the can for legal reasons, but it’s always worth knowing)

I know discord has a similar process and I personally like discord more, I just wanted to create this for those who do use slack.