How to connect Meteor with Slack?

Sending messages via Web Hooks to Slack

About Meteor & Slack

Meteor is a full-stack JavaScript platform for developing modern web and mobile applications. On the other hand, Slack is a team communication tool. intended to replace email communication between teams. It’s very easy and efficient to develop applications using Meteor. In this article, I am going to explain how you can send messages from you Meteor App to a Slack Channel.

Use Cases

First of all, let’s talk about possible use cases of this combination. You can send messages from your app to a channel on various different occasions such as:

  1. New User Registration
  2. New Bookings
  3. Payment Checkout
  4. So on… (You got the idea!!)

Procedure

  • You can start via creating a new incoming webhook integration in your Slack Team. You need to be a team owner for doing the same.
  • Select a channel in which you want your messages to be delivered. You can choose either an existing channel or create a new one.
Snapshot 1: Choosing Slack Channel
  • Now, copy the webhook URL provided in the next step.
Snapshot 2: Webhook URL
  • Now, create a Meteor Method in your app, where you can send a message to the specified webhook URL.
Code Snippet 1: Meteor Method
  • You can call this method with a message which can be a simple JSON object in the following form:
let message = { 'text': 'I am Aman Gupta'}
  • However, you can send complex messages with the help of message formatting provided via Slack.
  • You can call you Meteor Method in the following manner:
Meteor.call('notifications.slack', message);

You can follow this simple boilerplate to start sending messages from your Meteor App to a Slack Channel. You can also send these messages using simple javascript modules instead of Meteor Methods. Also, you can generalize this method and extend it to other frameworks, languages also. I hope you will find this technique helpful.


If you liked this article, be sure to recommend it and help spread good ideas as far and wide as possible just like the broadness of Technology. Please also leave your responses below :-)

Aman Gupta is Co-founder & CEO of YourMarch. He is working with his team on this disruptive platform to bring governance and technology on the same plate. He is very passionate about the way technology can be used to disrupt old models of democracy where the contribution of citizens was limited.

In his free time, you can find him playing games, lots of games :-). You can follow him on Twitter, Facebook or connect with him on LinkedIn.