Get User Lead data in Slack using Slack Bots
Tags: automation, customers, slack, lead
Published: 2021-03-19 17:03:13

We are going to build a bot that sends you messages in the Slack Channel. Slack is a cool future no-email place.

I am using slack to 

- Monitor client’s orders on my website. 
- Receive website visitors’ messages from Crisp in Slack.

Other use cases can be

- Receive website downtime notifications 
- Receive meeting reminders
- View your todo task lists and update them
- Collect customer story and store it in Google Sheet. (as claimed by Slack)

But we are going to create a slack hook that sends messages to your slack channel.  Let’s go !! 🔥

### Step 1 : Create your Slack Bot API

![image](https://nocodeapi.com/static/e881ca5f681f9f591be8ba1ca365d253/321ea/create-slack.png)

- Go to slack website api creator — [click here](https://api.slack.com/apps?new_app=1)
- Click on `Create New App`
- A popup appears. Here write your `App Name` and  select your `Development Work Space`
- Click `Create App`

### Step 2 : Select `Bots` button

![image](https://nocodeapi.com/static/07460e524804f7b6bd31637e20eb2147/6fe44/bots-permissions.png)

- We are going to update the bottom 2 x boxes — Bots & Permissions
- First Click on `Bots` box and it will take you to `App Home` page

### Step 3 : Click on `Review Scopes to Add`

![image](https://nocodeapi.com/static/5b117fd16c6cafa0a9cf93b50a8eb95f/0a47e/review-scopes.png)

### Step 4 : Add Bot Scopes

- It will open `OAuth & Permissions` page
- Click on `Add an OAuth Scope` under Scopes section and add following Scopes 
- `channels:read`, `chat:write`, `groups:read`, `groups:write`

![image](https://nocodeapi.com/static/443947009f432bc2e343bfb1b52f916c/ba4d9/kinds-scopes.png)

### Step 5 : Now Click on `Install to Workspace` at the top of your page 

![image](https://nocodeapi.com/static/997a28bbffff335f534bd167dcd2bf32/cd039/install-oauth.png)

### Step 6 : It will show you a pop up, Click `Allow`.

![image](https://nocodeapi.com/static/e0bc1ccd0004a905a22f4046c1679666/508ef/allow-bot.png)

### Step 7 : `Copy` your Bot User OAuth Access Token and save it for Step 9

![image](https://nocodeapi.com/static/7bd91388dfbbbaa52c13789bff432476/30d00/copy-token.png)

### Step 8 : Invite bot to your slack channel

- Go to your Slack Channel where you want to receive notifications and write `/invite @your_bot_name`
- You will see a response message `was added to #channel by your_name` like the one below

![image](https://nocodeapi.com/static/e723731f5cbb5be1895d92ab34b62949/321ea/invite-bot.png)

### Step 9 : Make your endpoint on NoCodeAPI

- Sign in to [nocodeapi.com](https://app.nocodeapi.com/login/) 
- Go to Marketplace and click on `Slack Hooks API`
- Click on `Make Slack Hooks API`
- On the side bar that just appeared > write your custom bot `name` > paste the `access token` you got in Step 7 > click on `refresh list` and > select your `channel` in slack

![image](https://nocodeapi.com/static/32ff5b3a2361e9aa0837fb88a0b69a09/50978/create-api.png)

### Step 10 : Send a message to your channel using playground

- Open the playground by clicking on `Use this API` button located above your endpoint.

![open_playground](https://res.cloudinary.com/miscellaneous/image/upload/v1616172668/nocodeapi/open_playground.png)

- Try sending a `text` message or `object` message to your slack channel using inbuilt `playground`. Like the one below 👇

![run_playground](https://res.cloudinary.com/miscellaneous/image/upload/v1616172670/nocodeapi/run_playground.png)

- You should receive your message in your Slack channel like below

![slack_msg](https://res.cloudinary.com/miscellaneous/image/upload/v1616172824/nocodeapi/slack_msg.png)

### 💌 Bonus Step 11 : Make your nodejs app

```javascript
const axios = require("axios")

// highlight-start
const data = {
  name: "Mohd Danish",
  email: "info@nocodeapi.com",
  message: "I love this telegram hook API",
  other: "other value.",
}
// highlight-end

axios({
  method: "post",
  url: "<api_endpoint>", // highlight-line
  data: data,
})
  .then(function (response) {
    // handle success
    console.log(response)
  })
  .catch(function (error) {
    // handle error
    console.log(error)
  })
```

- Copy above code in your nodejs playground and change the highlighted part.
- `data` - you can send any size of json object.
- `<api_endpoint>` - your slack nocode api endpoint. (It is listed on your nocodeapi dashboard).
- `npm start` your app to see this message in your slack channel.

### Video Tutorial

{% youtube VXuK0asipm4 %}

### This is it

I hope you learnt to create your own slack bots. If you fall in trouble, don’t hesitate to contact us on our telegram channel at [this link](https://t.me/NoCodeAPI). We will be happy to help you out.

Give us a thumbs up (or follow) on [twitter](https://twitter.com/nocodeapi). 

Thanks for the read. Happy Coding !! ✌️