MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How To Send Slack Notification with Laravel

It seems like a topic for basic Laravel developer, but while it’s easy to send emails, but the whole system of various notifications is much deeper, and worth studying. Sub-topics:

In the older version of Laravel, Slack notification was built-in configured with the framework. But on this 5.8.x version, they have created a separate package for Slack Notification. First of all, we have to install that package in our application.

composer require laravel/slack-notification-channelCode language: JavaScript (javascript)

Configure Incoming Webhooks

First, you need to install the Slack Application, we have to get the Slack webhook URL. For that login, to your Slack application and after login you will land on the main screen now on the left panel

Slack sidebar with the Apps section and its plus sign for adding apps highlighted

In Your Slack Application, you can see a + sign in the left corner, Add Apps, Click on the icon, you will land on an app search page where you need to search incoming-webhook in the search bar.

Slack Apps search for incoming webhooks showing the Incoming Webhooks app with an Add button

Now install the incoming-webhook application Now go to the setting tab inside the incoming-webhook app which you just install into your slack application. you need to provide the channel name there and you’ll get a Webhook URL.

Slack incoming webhook setup instructions showing the Webhook URL, redacted, and options for sending messages
Webhook URL

Copy the Webhook URL From the slack website and past it into the very bottom or wherever you like in the .env file which is in your laravel application’s root file

Laravel .env file with a SLACK_HOOK variable set to the Slack webhook URL highlighted
.envfile for pusher

That’s what you need from the Slack app, Now you have to configure your laravel application. For that, you need to create a notification section in laravel. For that, you just need to run this command in your commander.

php artisan make:notification TestNotificationCode language: CSS (css)

The above command will create a Notifications folder on the app folder from where you can find the TestNotification file. So let’s open and start adding it.

Now add the Slack in a new method’s returned array and create your first slack notification in the new method named toSlack().

public function toSlack($notifiable)
    {
        $message = "Famous Hello World!";
        
        return (new SlackMessage)
                ->from('Ghost', ':ghost:')
                ->to('#channel-name')
                ->content('Fix service request by '.$message);
    }Code language: PHP (php)

 Now its time to trigger this notification.

Notification::route('slack', env('SLACK_HOOK'))
      ->notify(new TestNotification());Code language: PHP (php)

Complete code for Notification

Paste the above code to send the notification to your slack channel and that’s all.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals

Related Posts

4 Open Source Alternatives to Slack for Team Chat: IRC, Let’s Chat, Mattermost, and Rocket.Chat

If you want Slack-like team communication with more control, these four open source options are a practical starting point. This guide compares their strengths, trade-offs, and how to run a short technical pilot.

Read More

Top 10 Collaboration Platforms Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, collaboration platforms are more essential than ever. As remote and hybrid work environments continue to thrive, having the right collaboration tool can be the…

Read More

Complete Tutorial: How to Enable Slack Notifications and Sound Alerts on Mac and Windows

Slack notifications are useful only when they actually reach you. Many people enable notifications inside Slack but still miss messages because macOS Focus, Windows Do Not Disturb,…

Read More

Top 10 AI DevOps ChatOps Assistants: Features, Pros, Cons & Comparison

Introduction AI DevOps ChatOps Assistants help engineering, DevOps, SRE, platform, and operations teams automate workflows, monitor infrastructure, manage incidents, query systems, execute runbooks, analyze logs, and collaborate…

Read More

How Chatbots Help DevOps Teams Work Faster and Smarter

If you’re in DevOps, your day usually feels like alerts firing nonstop, someone pinging you about a deployment, a pipeline breaking for no obvious reason, and a…

Read More

Top 10 Chat Apps: Features, Pros, Cons & Comparison

Introduction Chat apps have become an essential part of how people and organizations communicate in today’s digital-first world. At their core, chat apps are software platforms that…

Read More