How to Build a Slack Bot

Sdílet
Vložit
  • čas přidán 6. 07. 2024
  • Slack is a great chat and communication tool used by small and large businesses as well as personal use. Slack has a great API and great official Node JS clients that help you automate many features of Slack. If you're thinking of building a bot for Slack, be sure to follow this step by step tutorial on how to build a Slack bot in JavaScript using the Slack API and the Node Slack SDK. With this SDK, we can connect to the Slack Web API and even hook into events using the RTM API and build a bot in just a few minutes that you can add to your Slack server today.
    Video Notes: technotim.live/posts/slack-bot/
    If you need help cloning this repo, or setting up your developer machine, see my other video:
    • Setting Up Windows for...
    GitHub Repo github.com/techno-tim/techno-...
    00:00 Intro
    00:22 Why
    00:37 What is Slack
    00:59 What We're Going to Build
    01:31 Create a Slack Workspace
    01:53 Create a Slack App
    02:31 Add App Features to Our Slack App
    03:08 Customize Our Bot Display
    03:23 Start Writing Code
    04:05 Configure Your Machine for JavaScript Development
    04:37 Install Dependencies
    06:01 Get Slack OAuth Access Token
    07:11 Start Our Bot
    07:31 Send Message From Bot
    08:30 Bot Spam Channel
    09:30 Bot Online Message
    10:39 Hello Command Using Events
    11:27 Invite Bot to Channel
    12:16 !hello Command Logic
    14:25 Bot Mentions with userId
    15:30 Bot Feature Complete
    15:41 Conclusion
    16:18 Stream Highlight - Battlefield 1942 Tank Repairs - Such a classic game!
    Support me on Patreon: / technotim
    Sponsor me on GitHub: github.com/sponsors/timothyst...
    Subscribe on Twitch: / technotim
    Become a CZcams member: / @technotim
    Merch Shop: l.technotim.live/shop
    Gear Recommendations: l.technotim.live/gear
    Get Help in Our Discord Community: l.technotim.live/discord
    2nd channel: / @technotimtalks
    (Affiliate links may be included in this description. I may receive a small commission at no cost to you.)
    Techno Tim Kits:
    ► 4K CZcams Kit - kit.co/TechnoTim/4k-youtube-kit
    ► Pro Level Live Streaming Kit - kit.co/TechnoTim/pro-level-li...
    ► Budget Gaming Streaming PC 2020- kit.co/TechnoTim/budget-gamin...
    ► Performance Virtualization Server- kit.co/TechnoTim/performance-...
    ► Budget NAS Server- kit.co/TechnoTim/budget-nas-s...
    ► Coding & Gaming Keyboards- kit.co/TechnoTim/coding-gamin...
    ► Coding & Gaming Mice- kit.co/TechnoTim/coding-gamin...
    ⏯ Recommended Videos ⏯
    ► 20 Ways to Use a Virtual Machine (and other ideas for your homelab) • 20 Ways to Use a Virtu...
    ► Remote Gaming with Promox • Remote Gaming! (and Vi...
    ► Let's Build a Discord Bot Using DiscordJS - Moderator Bot • Let's Build a Discord ...
    #SlackBot #SlackAPI #Coding #OpenSource #TechnoTim #HomeLab
    Description tags: OAuth, Real time messaging API, interactive messages, events API, incoming webhooks, npm, yarn, robot, Slack Apps, create new app, workspace, how to build a slack bot, slackbot, javasctip slackbot, slackbot tutorial,
    Thank you for watching!
  • Věda a technologie

Komentáře • 85

  • @TechnoTim
    @TechnoTim  Před 4 lety +4

    Do you use Slack at home or at work?
    Btw, if you're new here, welcome! Be sure to subscribe for more content like this! 🚀

    • @joshbowden983
      @joshbowden983 Před 3 lety

      Both!

    • @LesCarbonaro
      @LesCarbonaro Před 3 lety

      Literally just got started with Slack bots today, and your tutorial just hit the spot! Not too much to overwhelm a total newbie, at the same time taking care not to leave out any important details. How can I build on this to have the bot reply to @mybot , as opposed to ! messages? Thanks again for putting this together.

  • @bedar89
    @bedar89 Před 3 lety +3

    Your videos are always perfect and simple enough for everybody! You have a new fan

  • @creechavo
    @creechavo Před 4 lety +4

    I started watching you yesterday, namely the video where u show how to do a video card passthrough on proxmod. Good video that one. I appreciate guys like this. Goes into all the details. Keep doing your thing man. Im subbing.

  • @elneto264
    @elneto264 Před 3 lety +3

    would love to see a part 2!

  • @mollycain1360
    @mollycain1360 Před 2 lety

    Techno Tim; LOVE, LOVE, LOVE your videos! Thank you. 💜

  • @ShadowHunter5000
    @ShadowHunter5000 Před 3 lety

    I've only started following your videos fairly recently. Keep it up, I am sure your channel will grow!! 🤖

  • @MythicEcho
    @MythicEcho Před 3 lety +4

    After clicking Bots 2:39, the Add Legacy option is not available...

  • @Lysiak.Yevhenii
    @Lysiak.Yevhenii Před 3 lety

    Thanks a lot ! Very good explanation !

  • @Eventyret
    @Eventyret Před 3 lety

    Love the video!
    Thank you for this!

  • @rbsdl
    @rbsdl Před 3 lety

    It was really cool. Thanks!!

  • @shilpavahinipati4814
    @shilpavahinipati4814 Před 2 lety

    great Video, part 2, please!

  • @michaeloska3113
    @michaeloska3113 Před 4 lety

    Your video re amazing, hope your chanel get millions of sub , you deserve it, good luck mate

    • @TechnoTim
      @TechnoTim  Před 4 lety +1

      Thank you so much! I'd be fine with a few hundred thousand ;)

  • @janisshin
    @janisshin Před rokem

    Nice video. One suggestion: I would add an annotation/link to your "Setting Up Windows for JavaScript Development THE RIGHT WAY" video at 03:23 Start Writing Code. I hadn't seen your description while watching your video for the first time and I was immediately lost at that chapter.

  • @tiagoalexandrino8286
    @tiagoalexandrino8286 Před 3 lety

    Hello!
    Thank you so much for this great Tutorial!
    Unfortunately, i'm having a small problem... When i type "!Hello" at Slack, the Bot answers me the same message 5 times in a row... and i can't understand why. Could you give me a little help please?
    Thanks in advance!

  • @prakhargupta7125
    @prakhargupta7125 Před 3 lety

    Great man! I love it♥️

  • @saracamilalauramanzaneda2776

    I love it! It works very well.

  • @amberthorpe1492
    @amberthorpe1492 Před 3 lety

    Great video! Do you have a recommendation for how to keep the bot running when you close your terminal?

    • @TechnoTim
      @TechnoTim  Před 3 lety

      You would have to run something like PM2 or put it in a Docker container.

  • @alokpradhan9875
    @alokpradhan9875 Před 3 lety

    Nice tutorial but rtm-api is deprecated . Can you create same tutotial in socket Mode using @Slack/bolt package? Thanks and happy Learning!!

  • @adrianjason13
    @adrianjason13 Před 3 lety

    Hey man. Grateful to have found your tutorial! Really helpful. I've got an issue though. My bot is not appearing as online even though I got the "Always Show My Bot as Online" enabled. Any thoughts? Thanks and cheers!

    • @TechnoTim
      @TechnoTim  Před 3 lety

      Thank you! Not sure, firewall?

  • @aningako
    @aningako Před 4 lety

    Thank you for sharing.

    • @TechnoTim
      @TechnoTim  Před 4 lety

      Thanks for stopping by! Hope you liked it!

  • @fionnlive581
    @fionnlive581 Před 4 lety +1

    Nice Tim, keep it up :D

    • @TechnoTim
      @TechnoTim  Před 4 lety

      Thanks! 😀

    • @fionnlive581
      @fionnlive581 Před 4 lety

      @@TechnoTim Wow, thanks for responding, I really like your channel :D

    • @TechnoTim
      @TechnoTim  Před 4 lety

      Thank you! Feel free to suggest some content you’d like to see!

    • @fionnlive581
      @fionnlive581 Před 4 lety

      @@TechnoTim Hey, I'd suggest maybe reviewing some Discord bots and providing some info to start your own server. I have my own bot, Pwn, let me know if you wanna check it out :D

  • @joshbowden983
    @joshbowden983 Před 3 lety

    Where do you host your bot?

  • @martincarrascofilippi5223

    I'm working on a bot that sends request to my private API to create some data on my DB and they are mounted both on the same server. Do you recommend this or should I mount both of them as different applications?

    • @TechnoTim
      @TechnoTim  Před 3 lety

      I would probably separate these

  • @ljohnso16
    @ljohnso16 Před 3 lety

    I used to program a lot of PHP code, and am familiar with server side code, but how do i install this on a web server so i can run it in production not just on my main machine. Your tutorial for how to configure my windows environment was nice, a few version updates made me search for a few answer but i got there.

    • @TechnoTim
      @TechnoTim  Před 3 lety +1

      You could containerize it (put it inside of a docker image) then run docker on a server. See my GitHub for an example. The techno-react has an example of how to build it in CI and do all of this as well as deploy to kubernetes

  • @mirageleung1575
    @mirageleung1575 Před rokem

    i think the RTM API is deprecated now?

  • @estongreub1796
    @estongreub1796 Před rokem

    Hey Techno Tim,
    After starting up the bot at 8:39, I get the following error message:
    */
    TypeError: Cannot read properties of null (reading 'message')
    at Object.callback (/Users/estongreub/Desktop/sherlocktest/node_modules/@slack/rtm-api/dist/RTMClient.js:397:89)
    at callback (node:internal/streams/writable:555:21)
    at afterWrite (node:internal/streams/writable:500:5)
    at onwrite (node:internal/streams/writable:480:7)
    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:106:10)
    /*
    Do you know what I can do next?

  • @vinodkumarSubramaney
    @vinodkumarSubramaney Před 3 lety

    Legacy Bot user is no more available. Do you know whats the alternative ?

    • @TechnoTim
      @TechnoTim  Před 3 lety

      It still works for me, I just tested the documentation.

  • @YouGotH4ck3d
    @YouGotH4ck3d Před rokem

    @3:29 what software is that

  • @PrateekJain348
    @PrateekJain348 Před 2 lety

    Hey do we have 2nd part of this ?

  • @creechavo
    @creechavo Před 4 lety

    One question. Can you do a video in how to host/create a game server in proxmox if it's possible to do it in that. If not then with a reliable solution to host gaming servers on one server machine.

    • @TechnoTim
      @TechnoTim  Před 4 lety

      If they have a docker image for the game you want to serve, this is the route I always take czcams.com/video/oILc0ywDVTk/video.html

    • @creechavo
      @creechavo Před 4 lety

      Thanks man appreciate it.

  • @krige
    @krige Před 3 lety

    Very good video! I think it would helped in the beginning of the video to explain the general architecture, how it works and how the components interact with each other

  • @alexanders9763
    @alexanders9763 Před 4 lety +1

    Hey Tim, great Video. Could you maybe make a Video about the Ticketsystem „Zammad“ or about the knowledgebase System „xWiki“?

    • @TechnoTim
      @TechnoTim  Před 4 lety

      What about it would you like to see?

    • @alexanders9763
      @alexanders9763 Před 4 lety

      @Techno Tim: Hey Tim, thanks for reply so fast. I thougt about, the installation process on containers like LXC with Ubuntu/Cent OS/Debian or on Docker/Kubernetes managed by rancher. Maybe LXC is the better choice for this. Also a quick overview about the Software/Systems and maybe some free features or extensions wich could be interesting for all People would be great. This could be interessting for all, i think.

    • @TechnoTim
      @TechnoTim  Před 4 lety

      @@alexanders9763 OOC, why would LXC better than Docker for this? I haven't heard of this yet, I will look into it! Thank you!

    • @alexanders9763
      @alexanders9763 Před 4 lety

      @Techno Tim: Hey Tim, please correct me if I‘m wrong, but as far as I know, lxc containers or vm’s are the better choice as docker for a ticket system or a knowledgebase in point of it-security. But maybe i‘m wrong, and there is an easy way of hardening docker, wich I actually don’t know, because i‘m not an Docker expert.

  • @hassanakbar2943
    @hassanakbar2943 Před 3 lety

    rtm-api:RTMClient:1 A websocket error occurred: read ECONNRESET
    any help on this

  • @ggitsjd
    @ggitsjd Před 2 lety

    I can't seem to find the ~ directory from within VSCode. I have the folder created, but I have no idea where my linux stuff resides on the Windows machine. Any ideas?

    • @TechnoTim
      @TechnoTim  Před 2 lety

      I think you can access WSL folders in windows by going to \\wsl$\:

    • @ggitsjd
      @ggitsjd Před 2 lety

      @@TechnoTim appreciate the reply. Will try this out today. Thanks!

  • @webmandman
    @webmandman Před 2 lety +1

    Yo TechnoTime, its been a year since you published this. and I don't see a classic app option. What gives?

    • @webmandman
      @webmandman Před 2 lety

      and there is no option for legacy bot user.

    • @craigobee8200
      @craigobee8200 Před 2 lety

      @@webmandman have you found a way around this yet?

  • @myselfsugam
    @myselfsugam Před 3 lety

    Till 7:16 everything is fine but when I run this yarn start, I got this error: rtm-api:RTMClient:1 unable to RTM start: An API error occurred: not_allowed_token_type. Any Idea?

    • @TechnoTim
      @TechnoTim  Před 3 lety

      Sounds like you didn't give it the right token or the right scopes!

    • @carterhagans4796
      @carterhagans4796 Před 3 lety

      same and ik i gave the right token but ik i gave scopes on the api that are referenced in my js but still getting the same error

  • @JeDeXxRioProKing
    @JeDeXxRioProKing Před 4 lety

    LIKE --> Comment , before Watching video I know it will be something good

  • @JohnWeland
    @JohnWeland Před rokem

    I need ot build a bot for work. I have been tasked with sending out a DSU message in out "bench" channel and then everyone on the bench is supposed to reply in thread for that day. And then I cross reference the people that responded with a list of people that should have responded like... taking attendance.
    I imagine this bot would when I comes online (in the bench channel) would grab everyone in that channel and remember them, if a person joins it adds them to its memory if they leave it removed them.
    Then every day it would start a message in the bench channel then message each person in it memory asking for their DSU when they reply it would take that message reply and put it as a response in the thread to it create for that day.
    I imagine it to have a command that could be rand that would spit out a csv for everyone in that week and whether or not they participated and on what days.

  • @sachinthaheshan389
    @sachinthaheshan389 Před 2 lety

    🤩💯

  • @conallogribin
    @conallogribin Před 3 lety

    TIL what a template string was xD

  • @theunbanned4553
    @theunbanned4553 Před rokem

    For the first 3min you showed how to make a Slack server, what is completely common sense, because probably everyone already got a Slack server, that's why they're here. But when you start writing code, you tell nothing about how to write code. I've never done this, I've no idea what you're using to make that. This is not really beginner friendly.

  • @justadev____7232
    @justadev____7232 Před 3 lety

    Legacy bot user is no longer available.

    • @TechnoTim
      @TechnoTim  Před 3 lety

      it's still available, I just tested it. Look at my docs in the description for a link

    • @maysnoseknowsus
      @maysnoseknowsus Před 3 lety

      How about if we can’t use legacy bot user since it have a lot of permission and want to define the scope with new app creation will it work?

    • @bulataleev1056
      @bulataleev1056 Před 3 lety

      @@TechnoTim looks like now events api is required right? rtm on slack_events not working anymore?

    • @zlamline
      @zlamline Před 3 lety

      @@bulataleev1056 use "GitHub Repo" link in description - then "Slack API - Create a classic app" link in Info section to create legacy bot (works on Mar 19, 2021)

  • @0cool966
    @0cool966 Před 3 lety

    I don't like these cut down videos where people don't how did you get to the screens where you are adjusting setting. This is really terrible way to teach someone something.

    • @TechnoTim
      @TechnoTim  Před 3 lety

      0cool sorry you feel that way. The code is in my github.

  • @loganrobert5811
    @loganrobert5811 Před 3 lety

    This video isn't all that helpful anymore. It would be nice to get one that isn't a classic app.