Skip to content

maakle/bombo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bombo Slack Bot

A simplified Slack bot that generates custom Bombo character stickers using AI image generation. This bot is built with TypeScript and follows a simple, straightforward structure similar to the Python example.

Features

  • Simple Structure: No complex services or abstractions - just the core functionality
  • AI Image Generation: Uses Replicate's FLUX 1.1 Pro model to generate Bombo stickers
  • Slack Integration: Built with Slack Bolt framework for easy deployment
  • Socket Mode: Runs in socket mode for easy development and deployment

Commands & Chat

  • /generate [prompt] - Generate a custom Bombo sticker based on your description
  • @mention Bombo in any channel to chat with him — he replies in-thread
  • DM Bombo directly for a private conversation

Bombo remembers the last 20 messages per channel, so he has context for the current conversation.

Environment Variables

Create a .env file with the following variables:

SLACK_BOT_TOKEN=your_slack_bot_token
SLACK_APP_TOKEN=your_slack_app_token
REPLICATE_API_TOKEN=your_replicate_api_token
OPENAI_API_KEY=your_openai_api_key
...

Stackhero Object Storage Setup

This bot stores generated images in Stackhero Object Storage (compatible with Amazon S3) for better performance and reliability. To set this up:

1. Provision the Add-on

Add Stackhero Object Storage to your Heroku app:

heroku addons:create ah-s3-object-storage-stackhero --app <your-app-name>

2. Create a Dedicated User

For security, create a dedicated user instead of using root credentials:

  1. Open the Stackhero dashboard:
heroku addons:open ah-s3-object-storage-stackhero
  1. Select your MinIO service and click "Console"
  2. Login with root credentials (retrieve with heroku config:get STACKHERO_MINIO_ROOT_ACCESS_KEY)
  3. Go to "Users" → "Create a user"
  4. Set access key, secret key, and select "readwrite" policy

3. Add Environment Variables

Add these variables to your .env file:

STACKHERO_MINIO_HOST=your-minio-host-here
STACKHERO_MINIO_ACCESS_KEY=your-access-key-here
STACKHERO_MINIO_SECRET_KEY=your-secret-key-here
STACKHERO_MINIO_BUCKET=bombo-images  # Optional, defaults to 'bombo-images'

4. Local Development

For local development, you can retrieve the config variables:

heroku config:get STACKHERO_MINIO_HOST
heroku config:get STACKHERO_MINIO_ACCESS_KEY
heroku config:get STACKHERO_MINIO_SECRET_KEY

Installation

  1. Install dependencies:
pnpm install
  1. Set up your environment variables in .env

  2. Run the bot:

# Production
pnpm start

# Development
pnpm dev

# Development with watch mode
pnpm dev:watch

How It Works

The bot now follows an enhanced flow with image storage:

  1. User types /generate [description]
  2. Bot acknowledges the command and posts a "generating" message
  3. Bot calls Replicate's FLUX 1.1 Pro model with the user's prompt
  4. Bot downloads the generated image and stores it in Stackhero Object Storage
  5. Bot serves the stored image URL for better performance and reliability
  6. If there's an error, the bot updates the message with error details

Architecture

The bot now includes:

  • Storage Service (src/services/storage.ts) - Handles image storage in Stackhero Object Storage
  • Chat Service (src/services/chat.ts) - Manages Bombo's conversational AI via OpenAI GPT-4o, with per-channel history
  • Bombo Persona (src/knowledge/bombo-persona.ts) - Knowledge base defining Bombo's personality, speech style, and world knowledge
  • Main Bot Logic (src/index.ts) - Orchestrates image generation, chat, and Slack event handling
  • Environment-based configuration - Includes storage credentials
  • Error handling with proper fallbacks

Chat Feature

Bombo uses GPT-4o with a rich system prompt that gives him:

  • A distinct vintage/comic personality with Italian flair
  • Awareness of his role in the workspace
  • Conversational memory (sliding window of 20 messages per channel)
  • Knowledge of what he can do (/generate stickers)

Bombo Character

Bombo is a round-faced, joyful man with a big mustache, wearing a felt hat, buttoned shirt, vest, and suspenders. The AI model generates him in a vintage comic book style with transparent backgrounds, perfect for use as stickers.

Development

The bot automatically detects development mode when NODE_ENV=development is set, which enables:

  • Enhanced logging for debugging
  • Performance timing
  • Additional development commands (/dev-test)
  • Debug log level

Slack App Permissions

To enable chat, make sure the following scopes are added in your Slack App settings:

Bot Token Scopes:

  • app_mentions:read — receive @mention events
  • chat:write — post messages
  • im:history — read DM history (for DM conversations)
  • users:read — look up display names

Event Subscriptions (Socket Mode):

  • app_mention
  • message.im

Deployment

The bot is designed to run in Slack's Socket Mode, making it easy to deploy without exposing webhooks. Simply run the bot and it will connect to Slack automatically.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors