
Hackatime Slack Bot
signup for a hackatime account and get password resets; all on on the hackclub slack!
## How do I use it?
Run the `/hackatime` command in the slack and it will prompt you to click a button to create an account if you don't have one, or to reset your password if you do.
### From a developer's perspective
There is a sweet message queue that is used to handle all hackatime slack messages. This is handled and persisted across restarts with `bun:sqlite`. To access the queue you need an admin token which you can ask me for on slack ([@krn](https://hackclub.slack.com/team/U062UG485EE)).
The queue is interacted with via a `POST` request to `/slack/message` with a `channel`, `text`, and (optionally) `blocks` json encoded in the body.
```bash
curl -X POST "https://hackatime-bot.kierank.hackclub.app/slack/message" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer NOTLEEKINGTHATLOL" \
-d '{
"channel": "U062UG485EE",
"text": "Hello from hackatime!"
}'
```
or via fetch with blocks
```typescript
await fetch("https://hackatime-bot.kierank.hackclub.app/slack/message", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.MESSAGE_QUEUE_TOKEN}`,
},
body: JSON.stringify({
channel: "U062UG485EE",
text: "Hello from hackatime!",
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: "Hello from hackatime!",
},
},
{
type: "divider",
},
{
type: "context",
elements: [
{
type: "mrkdwn",
text: "This is a message from the hackatime slack bot!",
},
],
},
],
}),
});
```
## Devving
Create a slack app as per the [manifest.yaml](manifest.yaml) and an env as below
```bash
SLACK_BOT_TOKEN=xoxb-xxx-xxxx-xxxxxx
SLACK_SIGNING_SECRET=xxxxxx
NODE_ENV=development
ADMINS=U062UG485EE
HACKATIME_API_KEY=xxxxxx
```
```bash
bun install
bun run index.ts
```
then start an ngrok
```bash
ngrok http --domain casual-renewing-reptile.ngrok-free.app 3000
```
## Screenshots
A bunch of screenshots of all the models
#### Initial Signup
Run the `/hackatime` command in slack and it will start the signup process

*First you'll see the initial signup prompt*

*No pressure - you can always cancel if you change your mind*

*Choose a secure password that meets the requirements*

*Make sure to enter a valid password!*

*Confirm your password to make sure it's entered correctly*

*Success! Your account is now created*
#### Existing Account
After you've created an account, you can reset your password if needed by again running the `/hackatime` command in slack

*The bot will recognize your existing account*

*You can easily reset your password if needed*
© 2025-present Kieran Klukas