You are browsing as a guest. Sign up (or log in) to start making projects!

2h 17m 1s logged

I gave some real commands and functions to Echo and connect it to the Hackclub workspace. By the end of the my work today , Echo had:

  • A working /echo-ask command — ask it anything, get an AI answer
  • A working /echo-help command — shows all commands
  • A working /echo-search command — live web search with cited sources
  • A working /echo-docs command — searches technical documentation
  • An onboarding event — sends a welcome message when added to any channel
  • A proper utils.js service for shared helpers

What I Did

1. Built the AI Brain services/ai.js

The first thing I needed was a way for Echo to actually think and give responses. I built a single getAIResponse() function that every command would call:

  • HackClub AI API as the backend, it let me use OpenAI and Google LLMs, and I could use it with my HackClub key
  • temperature: 0.7 I’ve used temperature attribute so make model more creative in responsing.
  • Default model gpt-4o-mini for speed and cost, but I made the model parameter swappable so different commands can use better models when needed.
  • Cool personality, I gave Echo an anime girl personality with soft expressions. This was intentional — bots that feel like characters are more fun to use and easier to remember

2. Built services/utils.js , Helpers module

Before building commands, I wrote the utilities they’d all share. I’ve used a cache logic so that commands like /echo-summary loop through 50-100 messages and need user names for each one. Without caching, that’s 100 API calls. With caching, it’s only as many unique users as exist.

3. Built command files

Then I built the files for each command in ordered manner in my project so that I can manage them easily. You can see the code of each file on my git repo

Problems I Hit and Fixed

Slack’s 3-second ack timeout: Slack requires every slash command to be acknowledged within 3 seconds or it shows a timeout error to the user. AI calls take 3-10 seconds. Solution: await ack() immediately at the top of every handler, then do the slow work after. This was the first bug I had to fix.

User IDs in messages: Slack stores messages with raw user IDs like <@U123ABC> instead of names. When I was building search, I realized the AI would receive these IDs and not know who said what. so I built resolveUserMentions() to replace them with real names before sending to the AI.


0
5

Comments 0

No comments yet. Be the first!