Published on February 12th, 2018
I've been building a small Laravel app for our church the past couple of days.
I was looking for the app to take a request and then alert X number of people within the church.
I'd first started to play around with Nexmo SMS but that doesn't enable you to notify multiple folks in a single message request, we'd need to send multiple messages and so our overall cost would increase to run the app.
I then started to think about using native push notifications on iOS and Android but that would come with the overhead of needing a native app for each platform. While I dig React Native, I've no desire to manage another dependency for the app. So what if I was able to hook into a communications app that people loved to use and has a sweet API? Enter Slack.
Notifications within Laravel are just lovely to use and quick to setup. I was able to have our webform take our request and post that request to the designated Slack channel via a webhook within 5 minutes.
While that worked sweet, it didn't send any notification to users in the channel. According to the Laravel docs you can customise the
from methods. However, I found that
->to('@channel') didn't work.
As it turns out, we can instead change the content method using a Slack API keyword
<!channel> like this:
->content("Hey <!channel> someone has posted to the web form")
Hey presto, our users in that channel get a nice Slack notification.
I get that
@channel notifications in Slack can be annoying generally but in this scenario it'll work wonders for the guys on that team to deal with incoming requests without needing to check the Laravel app itself.