An interactive AI-powered Slack bot that creates collaborative children's stories with your team. Users can start a story with a slash command, and the bot will generate an introduction based on random themes.
Team members can then contribute to the story in a thread, with the AI helping to guide the narrative to completion and generating a beautiful storyboard image at the end.
- Node.js 18+
- pnpm (recommended) or npm
- A Slack workspace where you can install apps
- Vercel account for deployment
git clone https://github.com/vercel/storytime-slackbot.git
cd storytime-slackbot
pnpm install-
Go to api.slack.com/apps and create a new app
-
Choose "From scratch" and select your workspace
-
In OAuth & Permissions, add these Bot Token Scopes:
chat:writefiles:writereactions:writechannels:historygroups:historyim:historympim:history
-
In Event Subscriptions:
- Enable events
- Set Request URL to:
https://your-domain.vercel.app/api/slack/webhook - Subscribe to
message.channelsworkspace event
-
In Slash Commands, create a new command:
- Command:
/storytime - Request URL:
https://your-domain.vercel.app/api/slack/command - Description: "Start a collaborative story"
- Command:
-
Install the app to your workspace and copy the Bot User OAuth Token
- Navigate to the Vercel Dashboard and go to the AI Gateway tab
- Click "API keys" in the left sidebar
- Click "Create key" to generate a new API key
- Save the API key for the next step
For more details, see the AI Gateway Authentication documentation.
Create a .env.local file:
SLACK_BOT_TOKEN=xoxb-your-bot-token-here
AI_GATEWAY_API_KEY=your_ai_gateway_api_keypnpm devThe app will be available at http://localhost:3000.
For local development with Slack webhooks, use a tool like ngrok to expose your local server:
ngrok http 3000Then update your Slack app's webhook URLs to use the ngrok URL.
After deployment, update your Slack app configuration:
- Event Subscriptions Request URL:
https://your-app.vercel.app/api/slack/webhook - Slash Command Request URL:
https://your-app.vercel.app/api/slack/command
- First, invite the bot to your channel: Type
@Storytime Bot(or whatever you named your app) in the channel and Slack will give you the option to invite it - In any Slack channel where the bot is present, type
/storytime - The bot will generate a story introduction with random themes
- Reply in the thread to add your part of the story
- The bot will respond with encouragement and continue the narrative
- After 2-3 iterations, the bot will conclude the story
- A beautiful storyboard image will be generated and shared
Note: The bot must be invited to a channel before the /storytime slash command will work in that channel.
The /storytime command supports several optional flags:
| Flag | Alias | Description |
|---|---|---|
--theme |
-t |
Story theme (can be specified multiple times). Defaults to 2 random themes if fewer than 2 are provided. |
--model |
-m |
Text generation model. Default: meta/llama-4-scout |
--image-model |
-i |
Image generation model. Default: google/gemini-3-pro-image |
--image-style |
-s |
Art style for the generated storyboard image (e.g., "Dr. Seuss", "coloring book", "watercolor"). |
--panels |
-p |
Number of panels in the final storyboard image (integer, 2–12). Default: 4–5 panels. |
--thinking-emoji |
-e |
Emoji shown while processing. Default: thinking_face 🤔 |
The --model and --image-model flags accept AI Gateway model specifiers (e.g., anthropic/claude-sonnet-4, openai/gpt-4.1-mini, google/gemini-2.5-flash).
Examples:
/storytime
/storytime -t Pirates
/storytime -t Pirates -t Space
/storytime -t Magic -t Dragons -t Friendship
/storytime -t Adventure -m anthropic/claude-sonnet-4
/storytime -t Fantasy -s "Dr. Seuss"
/storytime -s "coloring book"
/storytime -p 8
/storytime -t Pirates -s watercolor -p 6
The included local.ts script allows you to test the core story generation logic locally without using Slack or Vercel Workflows.
# Default (2 random themes)
pnpm tsx local.ts
# With custom themes
pnpm tsx local.ts -t Pirates -t Space
# With custom model
pnpm tsx local.ts -t Magic -m anthropic/claude-sonnet-4The local script accepts the same --theme, --model, --image-model, --image-style, and --panels flags as the Slack command.

