This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

CloudwaysCDN — a powerful solution that offers superior performance and satisfied global audience for your business. Read More

How to Build a Slack Bot Using Laravel

Updated on  29th September

3 Min Read
Reading Time: 3 minutes

Today, I demonstrate how you can build a simple “Hello World” Slackbot by using Laravel. Slack is a cloud-based team collaboration tool co-founded by Stewart Butterfield, Eric Costello, Cal Henderson, and Serguei Mourachov.

It offers a lot of IRC-like features including persistent chat rooms (channels) organized by topic, as well as private groups and direct messaging. Today, we will be building up a Slack bot using Laravel.

how to build laravel powered slack bot

Let’s have a quick look at what do we require before starting the project.

Here are some prerequisites:

  • You must have a Slack account.
  • You must have an active Cloudways Hosting server. (This one’s optional, though.)
  • You must have a working Laravel app.

Step 1: Get the Package

First, you have to install the necessary package for handling the Slack messages.

Now, let’s add Maknz\Slack\Laravel\ServiceProvider to the provider array in config/app.php:

Then add facade to your aliases array:

Finally, publish the Config file:

Step 2: Setup Config

Use the following syntax to edit the slack.php file:

Now, let’s get the webhook URL so the stack could be integrated with the Laravel app. Click on Gear ⚙ icon and add an app or integration from your Slack room.


Click the Build button in the top corner.


Now, click Make a Custom Integration.


Next, click Incoming Webhooks.


The webhook URL would look like:


Copy this URL. Next, edit config/slack.php to set up the endpoint.

Change this:

To this:

Remember to input your Channel and User Name.

Step 3: Make the Routes

For this app, I will create a simple triggering route that will push the Hello World message onto the Slackbot.

Step 4: Make the Controller

This will be a simple controller that contains the actual logic to push the message to the Slackbot.

Save the file. Once done, it is time to test the bot.

Go to the link of the app that might look something:

The Slackbot would serve the Hello World message.

Try cURLing again and again and you will see the Hello World message popping again and again. 🙂

I hope that you have set up the Slackbot without any issues. If you have a question or would like to add to the discussion, please add a comment below.

Share your opinion in the comment section. COMMENT NOW

Noor Ali

Noor Ali is an Associate Software Engineer at Cloudways. He loves to solve technical problems through programming and mathematics.

Create Laravel apps without the worry of server management.

Deploy your app on optimized PHP hosting servers for Laravel.

Get Our Newsletter
Be the first to get the latest updates and tutorials.