DEV Community

Cover image for How to build API to deliver slack messages with no code
Kartik Grewal for Canonic Inc.

Posted on • Updated on


How to build API to deliver slack messages with no code

Every day so many people depend on slack to stay updated in their daily life. Hence, we may need to deliver some message or an alert to slack programmatically via an API in our product or webapp. This is a simple guide to show how you can achieve the same with no coding, to quickly hook up slack with your webapp.

Our goal is to create an endpoint that we can trigger to send our message on the slack.

  1. We head over to Canonic and sign in using our social accounts. Next, we click on Create New to create a project for our application. Click on next, then click on create to complete the process.

    Create new project screen

  2. A popup asking your first table name will appear. If not, you can click on the + icon in the header to create a new table. Let's name our first & only table for this project as Messages.

  3. We create a text field named "Message" as we'll need it in the API & also to store the messages we send out.

  4. We hit deploy on the top right, and we'll be provided with a hosted backend. a database & basic CRUD endpoints per table to help us create an API for our slack.

  5. Click on the API tab on the left to start adding the slack webhook. We select the createMessage block in mutations. Click on the + button. It'll open up a new webhook settings on the right hand side.

  6. Select Message type → Choose Slack from the list of providers & you'll be provided with 2 fields for settings.

  7. Trigger URL → This is the url which will be generated by slack

  8. Message Body → Message to send to slack channels.

  9. For Trigger URL → You'll need to create a webhook endpoint on Slack. Follow the slack documentation to help you through - After you complete this guide, you should have a slack webhook endpoint, something like this -

  10. For Message Body → We want to send the text found in the message field of the API to slack. So we can make use of Handlebars templates & simply write {{message}} in that field. This will extract the message field from the API payload and forward it to slack.

The above concludes the setup for the API that was required. Now let's start using this API to start sending messages to our slack channels.

Triggering Slack API:

This will require a combination of things that we need for securely connecting our application with this API.

  • Access token for our API
  • Documentation for the API

Access Tokens

  1. Click on Settings using left side menu. Go to Access tokens tab.

  2. Click on Create a new token, and provide it a suitable name and permissions. Click on Create.

  3. You've successfully generated an access token for your API. Copy it & save it some place safe as you won't be able to see it again.


Head over to the docs tab using the left-hand side, and you'll find documentation for createMessage API (the API block where we added our webhook).


After completing all the necessary steps, we're finally ready to deliver our first message to the slack using API.

  1. Let's copy the CURL command that was mentioned in the documentation. Fill in your access token and paste it into the terminal.
  2. Our curl command will look something like this.

    ➜  ~ curl '' \
      --request POST \
      --header "Content-type: application/json" \
      --header "Authorization: xxxxxx-xxxxx-xxxx" \
      --data '{
        "input": {
          "message": "Hello Slack! How are you?",

    A successful response will look like this:

    {"data":{"message":"Hello Slack! How are you?","_id":"60bf30ee2529700009fd2a4a","createdAt":"2021-06-08T08:57:18.316Z","updatedAt":"2021-06-08T08:57:18.316Z","__v":0,"id":"60bf30ee2529700009fd2a4a"},"error":null,"success":true}%

    And show up on your slack like this!

And just like that, we can setup an alerting or notification system for slack. You can also add more fields apart from message like name. This will allow you to formulate a much better structured in message body.

Hi {{ name }},

My message - {{ message }}

Enter fullscreen mode Exit fullscreen mode

Find detailed documentation for this feature here -

Also checkout how we can integrate 3rd party authentication services with your backend without coding here. Looking forward to your feedback!

Top comments (0)

Visualizing Promises and Async/Await 🤯

async await

☝️ Check out this all-time classic DEV post