I successfully built and deployed a massive upgrade to Slacky Wacky, adding four powerful new features! Here is exactly how I implemented them:
-
Conversational Memory:
I usedbetter-sqlite3to 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();
}
-
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}\` }
}
]
});
-
Live Web Dashboard & Reverse Proxy:
I integrated an Express server intoindex.jsto 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 port3000:
app.get('/', (req, res) => {
res.send(\`<h1>Slack Bot Live Dashboard</h1><p>Latest Latency: \${latestLatency} ms</p>\`);
});
-
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!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.