> Canonical URL: https://codingcat.dev/post/slap-someone-with-slack-commands

# Slap Someone with Slack Commands

✏️ Blog PostMay 26, 2022[![](/logos/firebase/firebase-symbol.png)![](/logos/firebase/firebase-symbol.png)Firebase](/topic/firebase)

# Slap Someone with Slack Commands

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/4de2886f45d64abc1a19a86840c19c552349aee1-1920x1080.png?w=1920&h=1080&q=82&fit=max&auto=format)[@CodingCatDev62.5K / 100K Subscribers Goal](https://www.youtube.com/@codingcatdev?sub_confirmation=1)[Subscribe on YouTube→](https://www.youtube.com/@codingcatdev?sub_confirmation=1)[Watch on YouTube App ↗](https://www.youtube.com/watch?v=3A4iucpZiwo&list=UUnKZ8gEb78zXKMi1ns-IQ2g)[![Alex Patterson](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/a606dfaa381aab08ddbe16a33fe1d3e1fb37c927-400x400.jpg?w=96&h=96&q=82&fit=max&auto=format)Alex Patterson](/author/alex-patterson)

## Slappy Slack

So one of the Purr-fect Peeps on the channel wanted a fun `/slap` command added to our Slack channel. I basically said, challange accepted! A quick Google search led me down the right path and found [Spicefactory Slapbot](https://spicefactory.co/blog/2015/12/09/slapbot-for-slack-good-old-slap-available-again/). I cloned this and then started making some tweaks!

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/209d5451d3f7202fc72d218d3617e7a1870a8b2b-696x213.png?w=696&q=82&fit=max&auto=format)

## Installation

> Note you could run this as a stand alone node server, but I chose to utilize Firebase Cloud Functions since the plan is to add some Machine Learning later.

Before continuing I am committing the files `.firebaserc` and `firebase.json`, mainly so I can keep making changes. For your project you will want to delete these files before you begin with the project setup and Firebase initialization.

## Initialize Firebase

Copied! 🐾

```
firebase init
```

When presented with your choices arrow down and hit space bar on `Functions: Configure and deploy Cloud Functions`.

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/a48bc8f8492abb28aafc7debe062dc1ef680730f-1038x234.png?w=1038&q=82&fit=max&auto=format)

If you would like to start using a new project select `Create a new project`, for more info checkout [Firebase Init Docs](https://firebase.google.com/docs/cli).

After that you can select Javascript

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/028341c6d936199008e066ef60ac38051ee2310e-1122x238.png?w=1122&q=82&fit=max&auto=format)

For the final settings select N (No) for everything except "Do you want to install dependencies with npm now?", for this Y (Yes).

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/4e92635c5f8127a5708d6b50ea2675ff93d69827-1332x932.png?w=1332&q=82&fit=max&auto=format)

Now that you have this complete you should see two new files `.firebaserc` and `firebase.json`.

## Deploy Functions

As it stands right now, this will allow you to test locally (not the intent of this lesson). What we really want is to deploy this to Firebase so that Slack can access it. Since our project should all be setup at this point we just use the deploy command.

In order for us to access an external network you will need to switch your Firebase Subscription for this project, I recommend the Blaze plan as you will not get charged until you go over 125K Invocations a month, I don't know about your slack fans but that would be very impressive! You can select Modify project at the bottom left of the screen and it should open a modal like below.

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/a236466a713e13c2303da4f1617e7d753af91bce-815x607.png?w=815&q=82&fit=max&auto=format)

Now it is time to deploy our function:

Copied! 🐾

```
firebase deploy
```

It should result in a successful creation of a cloud function with this output:

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/a8ed8155e21617645685efa34d0a1a2802784017-1078x502.png?w=1078&q=82&fit=max&auto=format)

You can check in the [Firebase Console](https://console.firebase.com/) under Develop->Functions

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/7e1b4dfe96b2aab43b1b5bcb24cf04ab6944a8c2-450x364.png?w=450&q=82&fit=max&auto=format)

### Example of local testing

Copied! 🐾

```
firebase serve
```

This command will output where the emulator is running.

Copied! 🐾

```
=== Serving from '/Users/ajonp/Documents/Web/slapbot'... ⚠ Your requested "node" version "8" doesn't match your global version "10" ✔ functions: Emulator started at http://localhost:5000 i functions: Watching "/Users/ajonp/Documents/Web/slapbot/functions" for Cloud Functions... ✔ functions[api]: http function initialized (http://localhost:5000/ajonp-slack-slap/us-central1/api).
```

So if you want to throw some curl commands at it you could like:

Copied! 🐾

```
curl -X POST \ 'https://us-central1-ajonp-slack-slap.cloudfunctions.net/api/slap?callback=YOURCALLBACK' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -H 'cache-control: no-cache' \ -d 'user_name=ajonp&text=slappy&channel_id=1234&undefined='
```

## Slack Configuration

Go to Slack services section https://<your_slack_team>.slack.com/apps. For example [https://ajonp-com.slack.com/apps](https://ajonp-com.slack.com/apps).

### Incoming Webhook

First we need a way to have Slack accept our `/slap` messages coming back into Slack's system for our account. We will add an inbound Webhook to allow this interaction to succeed.

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/4e18324b0e972c3499a8938e5069afb1ab3c6af7-396x173.png?w=396&q=82&fit=max&auto=format)
- Choose any channel to post to (don't worry, bot will use the channel you type in when you do your slapping)
- Copy and paste tha token part of the URL that you got (it will be something like :

Copied! 🐾

```
https://hooks.slack.com/services/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
```

- So it would be the `/T2UR5KNQ2/BMNTDRAG0/mPToTmuARk2BqYhn93Izzbbb` portion as we will need this for our slash command.

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/a2549243a75e11832e2e0db6cac66e02a9897e01-2266x1678.png?w=1600&q=82&fit=max&auto=format)

### Slash Command App

Now we need to add and app for the slash command configuration.

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/c355871c478b8fdb79d3791f90a17379433b6dd5-872x286.png?w=872&q=82&fit=max&auto=format)

Put in the URL your service url or you can use ours -> `https://us-central1-ajonp-slack-slap.cloudfunctions.net/api/slap?callback=YOURCALLBACK`.

Now you have a working bot with whom you can interact, but it is a private communication between you and him, so you could say that it is not that fun. Let's make it more fun!

- Take the part after `services`, as in the above example it will be -> `/T2UR5KNQ2/BMNTDRAG0/mPToTmuARk2BqYhn93Izzbbb`
- Go back to Slash Command and edit the URL to add the token part from above so it should be at the end something like

Copied! 🐾

```
https://us-central1-ajonp-slack-slap.cloudfunctions.net/api/slap?callback=/T2UR5KNQ2/BMNTDRAG0/mPToTmuARk2BqYhn93Izzbbb.
```

BTW replace `https://us-central1-ajonp-slack-slap.cloudfunctions.net/api` with your url, or feel free to use this one.

## Usage in Slack

In the easiest form you can just type:

This will tell slapbot to give Chris a big ol' slap with a fish emoji. You can also supply your own emoji by typing:

In this example, Chris will be slapped by the emoji ????. LOL!

By default, the bot will also include some banter at the end. Read on to learn how to configure this.

## Configuring the bot behaviour

- To edit the random banter strings, change the `banterArray` variable in `helpers.js`.
- To remove the banter, remove the `banter` variable from the `text` property of `botPayload` in `server.js`.
- To change the bot name or icon, change the `user_name` and `icon_emoji` property of `botPayload` in `server.js`.
- To change the default emoji, change the `DEFAULT_EMOJI` variable in `constants.js`.

Congratulations, enjoy slapping!

## Resources, Links & Official Documentation

- **Watch on YouTube: ** [Slap Someone with Slack Commands Full Video](https://www.youtube.com/watch?v=3A4iucpZiwo) (plus [Subscribe to CodingCat.dev](https://www.youtube.com/@CodingCatDev?sub_confirmation=1))
- **🎥 YouTube: ** [https://link.ajonp.com/youtube](https://link.ajonp.com/youtube)
- **🌎 Site: ** [https://link.ajonp.com/😺](https://link.ajonp.com/😺)
- **📦 GitHub: ** [https://link.ajonp.com/github](https://link.ajonp.com/github)
- **🎓Lessons: ** [https://link.ajonp.com/lessons](https://link.ajonp.com/lessons)
- **🗞AJ’s Week in Web: ** [https://link.ajonp.com/week-in-web](https://link.ajonp.com/week-in-web)
- **💬 Slack: ** [https://link.ajonp.com/slack](https://link.ajonp.com/slack)
- **🐦 Twitter: ** [https://link.ajonp.com/twitter](https://link.ajonp.com/twitter)
- **💬 Slack: ** [https://bit.ly/ajonp-slack-invite](https://bit.ly/ajonp-slack-invite)
- **🐦 Twitter: ** [https://bit.ly/ajonp-twitter](https://bit.ly/ajonp-twitter)
- [**Firebase Documentation:**](https://firebase.google.com/docs) Firestore, Data Connect, Authentication, App Check, and Cloud Functions
- [**MDN JavaScript Reference:**](https://developer.mozilla.org/en-US/docs/Web/JavaScript) ECMAScript specifications, Web APIs, and runtime fundamentals
- [**GitHub Documentation:**](https://docs.github.com/) Pull requests, GitHub Actions CI/CD, and repository security

## Related CodingCat.dev Tutorials & Podcast Episodes

- [**RxFire in Svelte 3 using Firebase Firestore and Authentication**](/post/rxfire-in-svelte-3-using-firebase-firestore-and-authentication): Introduction to Svelte3, Firebase, and RxFire. RxFire provides a set of observable creation methods. You simply call a function with some parameters to receive ...
- [**RxFire in ReactJS using Firebase Firestore and Authentication**](/post/rxfire-in-reactjs-using-firebase-firestore-and-authentication): Introduction to Create React App, Firebase, and RxFire. RxFire provides a set of observable creation methods. You simply call a function with some parameters to...
- [**Notion to Hashnode and Dev.to using Pub/Sub Cloud Functions**](/post/notion-to-hashnode-and-devto-using-pubsub-cloud-functions): Depending on your goals cross posting with a canonical url can increase your user engagements 10x. I will show you an easy way to take your Notion articles out ...

## Frequently Asked Questions (FAQ)

### What are the main takeaways from Slap Someone with Slack Commands?

Deploying Firebase Cloud Function to use with Slack slash commands. Sending someone a /slap!. Slap Someone with Slack Commands: 🎓 Lesson: https://ajonp.com/lessons/slap-someone-with-slack-commands/ 🎥 YouTube: https://link.ajonp.com/youtube
🌎 Site: https://link.ajonp.com/😺
📦 GitHub: https://link.ajonp.com/github
🎓Lessons: https://link.ajonp.com/lessons
🗞AJ’s Week in Web: https://link.ajonp.com/week-in-web
💬 Slack: ht, how to add a slash command for slack what five fingers say that face slap the goal of this video is to cover how to add a slack custom command for this it's pretty funny one we're gonna do slash slap and the way that you can execute it is by including slash slap and then you do at someone so in this case Oh Doug and then if you don't add anything at the end it will just add the hand or the slap it... Throughout this post, Alex Patterson breaks down real-world implementation details for Firebase, JavaScript, GitHub so developers can apply these patterns directly in production.

### How do you implement Firebase best practices in production?

When adopting Firebase and JavaScript in a production stack, start by validating your configuration against the [**Firebase Documentation**](https://firebase.google.com/docs) (Firestore, Data Connect, Authentication, App Check, and Cloud Functions). Focus on incremental adoption, automated testing, and observability so your team can measure performance and developer velocity improvements at each stage.

### Where can I watch the full Slap Someone with Slack Commands walkthrough and find related code resources?

You can watch the complete video session for [**Slap Someone with Slack Commands**](https://www.youtube.com/watch?v=3A4iucpZiwo) on the [**CodingCat.dev YouTube channel**](https://www.youtube.com/@CodingCatDev?sub_confirmation=1). For a deeper dive into Firebase, check out our related guide: [**RxFire in Svelte 3 using Firebase Firestore and Authentication**](/post/rxfire-in-svelte-3-using-firebase-firestore-and-authentication).

## ✏️ Video Summary

Slap Someone with Slack Commands: 🎓 Lesson: https://ajonp.com/lessons/slap-someone-with-slack-commands/

🎥 YouTube: https://link.ajonp.com/youtube
🌎 Site: https://link.ajonp.com/😺
📦 GitHub: https://link.ajonp.com/github
🎓Lessons: https://link.ajonp.com/lessons
🗞AJ’s Week in Web: https://link.ajonp.com/week-in-web
💬 Slack: ht — how to add a slash command for slack what five fingers say that face slap the goal of this video is to cover how to add a slack custom command for this it's pretty funny one we're gonna do slash slap and the way that you can execute it is by including slash slap and then you do at someone so in this case Oh Doug and then if you don't add anything at the end it will just add the hand or the slap it...

✏️ Visual Architecture Diagram

## how this post connects together.

Follow AJ from first principles to production-ready architecture.

Let’s build it!✏️ Visual Diagram: Slap Someone with Slack Commands✓ Good PatternVISUAL DIAGRAM[Diagram Walkthrough]Step-by-step diagram breakdown for Slap Someone with Slack Commands: start with Slap Someone with Slac, implement Hands-On Implementation, and ship to production.AAA Contrast Verified

## related deep dives.

[All Blog Posts&rarr;](/blog)[![The Firebase plugin is now available in Codex: Web Architecture & Implementation Guide](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/4e2c8e99f437cb576972d406ec32394a82a19480-1200x630.svg?w=1200&q=82&fit=max&auto=format)](/post/firebase-2026-09-firebase-plugin-for-codex)September 29, 2026[![](/logos/firebase/firebase-symbol.png)![](/logos/firebase/firebase-symbol.png)Firebase](/topic/firebase)[AI & MCP Agents](/topic/ai)

### [The Firebase plugin is now available in Codex: Web Architecture & Implementation Guide](/post/firebase-2026-09-firebase-plugin-for-codex)

Alex Patterson's hands-on web engineering breakdown of "The Firebase plugin is now available in Codex" (2026-09-28). Learn how to wire up Firebase, Google Cloud, Web Dev, AI in production web apps.

[![Alex Patterson](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/a606dfaa381aab08ddbe16a33fe1d3e1fb37c927-400x400.jpg?w=96&h=96&q=82&fit=max&auto=format)Alex Patterson](/author/alex-patterson)[![Sanity Knowledge Bases](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/38b0f021c51d97043c8a1ebf31d505a0ea877b7c-2752x1536.jpg?w=1920&q=82&fit=max&auto=format)](/post/sanity-knowledge-bases)October 17, 2026[![](/logos/sanity/Sanity-Symbol--black_on_transparent.svg)![](/logos/sanity/Sanity-Symbol--white_on_transparent.svg)Sanity](/topic/sanity)[Cloudflare](/topic/cloudflare)

### [Sanity Knowledge Bases](/post/sanity-knowledge-bases)

Eliminate query-time guessing in your AI agents. Learn how Sanity Context Knowledge Bases compile structured datasets, crawled documentation websites, and uploaded files ahead of time, resolve conflicting facts, and serve a compact outline over Context MCP.

[![Alex Patterson](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/a606dfaa381aab08ddbe16a33fe1d3e1fb37c927-400x400.jpg?w=96&h=96&q=82&fit=max&auto=format)Alex Patterson](/author/alex-patterson)