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

49m 27s logged

I successfully built and deployed a massive upgrade to Slacky Wacky, adding four powerful new features! Here is exactly how I implemented them:

  1. Conversational Memory:
    I used better-sqlite3 to set up a lightweight database. When a user asks a question, the bot retrieves their last 10 messages so the Groq API has multi-turn context:
const db = new Database('chat_history.db');
db.exec(\`
  CREATE TABLE IF NOT EXISTS messages (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id TEXT,
    role TEXT,
    content TEXT
  )
\`);
function getHistory(userId) {
  return db.prepare('SELECT role, content FROM messages WHERE user_id = ? ORDER BY id DESC LIMIT 10').all(userId).reverse();
}
  1. Block Kit UI:
    I refactored all responses into structured Slack Block Kit elements for a much cleaner look:
await respond({
  blocks: [
    {
      type: "section",
      text: { type: "mrkdwn", text: \`*Answer:*\\n\${groqAnswer}\` }
    }
  ]
});
  1. Live Web Dashboard & Reverse Proxy:
    I integrated an Express server into index.js to log system metrics and API latency in real time. I then configured a custom reverse proxy domain (sandeepkurma.hackclub.app) inside the dashboard pointing to target port 3000:
app.get('/', (req, res) => {
  res.send(\`<h1>Slack Bot Live Dashboard</h1><p>Latest Latency: \${latestLatency} ms</p>\`);
});
  1. Multimodal Image Support:
    I added logic to check for image file extensions (jpg, png, etc.) in the user’s message. If found, the bot automatically switches the model to `llama-3.2-11b-vision-preview` and formats the request content structure:
const modelToUse = containsImage ? 'llama-3.2-11b-vision-preview' : 'llama-3.3-70b-versatile';

Everything is fully verified, tested, and running 24/7 on my container!

0
2

Comments 0

No comments yet. Be the first!