Skip to main content
RapidDev - Software Development Agency
bolt-ai-integrationsBolt Chat + API Route

How to Integrate Bolt.new with Flock

Integrate Bolt.new with Flock by creating an app at dev.flock.com, getting an API token, and sending messages to channels via a Next.js API route. Flock's REST API supports channel messaging, user management, and bot creation with simpler setup than Slack. Outbound API calls and channel messages work in Bolt's WebContainer preview; Flock webhook events and slash command responses require a deployed public URL.

What you'll learn

  • How to create a Flock app and get an API token from dev.flock.com
  • How to send formatted messages and attachments to Flock channels from a Next.js route
  • How to create Flock bots and configure incoming webhooks for channel notifications
  • How to build a Bolt app that posts notification cards to Flock when events occur
  • Why slash command handling and interactive bot responses require a deployed URL
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate16 min read25 minutesCommunicationApril 2026RapidDev Engineering Team
TL;DR

Integrate Bolt.new with Flock by creating an app at dev.flock.com, getting an API token, and sending messages to channels via a Next.js API route. Flock's REST API supports channel messaging, user management, and bot creation with simpler setup than Slack. Outbound API calls and channel messages work in Bolt's WebContainer preview; Flock webhook events and slash command responses require a deployed public URL.

Building Flock Team Notifications and Bots from Bolt.new Apps

Flock is a team communication platform that is particularly popular among startups and technology companies in India and Southeast Asia. With approximately 5 million users and backing from Tiger Global, it competes with Slack in the SMB segment but with a significantly lower price point and a simpler integration API. For Bolt developers building apps used by teams in these regions, or teams that have chosen Flock for cost reasons, integrating notifications and bots is a practical requirement.

Flock's API is simpler than Slack's in both capability and setup. There is no complex OAuth flow for basic integrations — you create an app in Flock's developer portal, get a token, and use it to call REST endpoints. The main difference from Slack is scope: Flock's API has fewer event types, fewer interactive component options, and a smaller ecosystem of third-party integrations. For basic use cases — channel notifications, message formatting with buttons, user lookups, and simple bots — Flock's API covers everything you need.

All Flock outbound API calls (sending messages, fetching channel info) are standard HTTPS requests that work from Bolt's WebContainer preview. You can build and test notification workflows entirely without deploying. The functionality that requires a deployed public URL includes: slash command handlers (Flock sends a POST request to your server when a user runs a slash command) and interactive message buttons that trigger server-side callbacks. For unidirectional notification apps, development in the Bolt preview is entirely sufficient.

Integration method

Bolt Chat + API Route

Bolt generates the Flock integration through conversation — describe what team messaging or notification features you need and Bolt writes the API routes and React components. Flock uses token-based authentication with a simple api_token query parameter or header for all REST API calls. All outbound Flock API calls (sending messages, fetching channel info, creating bots) run through server-side Next.js routes. Slash commands and incoming webhook events from Flock require a deployed public URL since Bolt's WebContainer cannot receive incoming HTTP connections.

Prerequisites

  • A Flock account and team workspace (free plan available at flock.com)
  • A Flock app created at dev.flock.com with a bot token generated
  • The bot token from your Flock app (displayed in the app settings after creation)
  • The channel token or channel ID for the Flock channel where you want to send messages
  • A Next.js project in Bolt.new — prompt 'Create a Next.js app' if starting fresh

Step-by-step guide

1

Create a Flock app and get your API credentials

Navigate to dev.flock.com in your browser and sign in with your Flock account. If you do not have a Flock developer account, you will need to create one — it uses the same credentials as your Flock workspace login. Once signed in, click Create App. Fill in the app name (e.g., 'Bolt Integration'), description, and choose an icon if desired. After creating the app, navigate to the Bot section in your app settings. Enable the Bot feature and configure the bot username — this is the name that will appear in Flock channels when your integration sends messages. Flock bots can post messages to channels, respond to direct messages, and handle slash commands. In the Token section of your app, generate a Bot Token. This is the credential your server will use to call the Flock API. Copy it — it looks like a long alphanumeric string. Store it as FLOCK_BOT_TOKEN in your Bolt project's .env.local file. To send messages to a specific channel, you need the channel's token. You can find channel tokens in Flock's admin settings: go to your Flock workspace → Admin → Apps & Integrations → API → Channel Tokens. Each channel has a unique token that identifies it in API calls. Alternatively, you can fetch channels programmatically via GET https://api.flock.com/v2/channels.list with your bot token. Store your primary notification channel's token as FLOCK_CHANNEL_TOKEN in .env.local. The Flock REST API base URL is https://api.flock.com/v2/ and all endpoints accept the token as either a query parameter (?token=your_token) or as an Authorization: Bearer header. The Bearer header approach is cleaner for server-side use.

Bolt.new Prompt

Set up Flock API integration in my Next.js app. Add FLOCK_BOT_TOKEN and FLOCK_CHANNEL_TOKEN to .env.local as placeholders. Create lib/flock.ts with a flockFetch helper that adds the Authorization Bearer header to all requests to the Flock API base URL https://api.flock.com/v2. Also export a sendFlockMessage helper that accepts channelToken, text, and optional attachments.

Paste this in Bolt.new chat

.env.local
1// .env.local
2FLOCK_BOT_TOKEN=your_bot_token_here
3FLOCK_CHANNEL_TOKEN=your_channel_token_here
4
5// lib/flock.ts
6export async function flockFetch(
7 endpoint: string,
8 method: 'GET' | 'POST' = 'GET',
9 body?: Record<string, unknown>
10): Promise<Response> {
11 const token = process.env.FLOCK_BOT_TOKEN!;
12 const url = `https://api.flock.com/v2${endpoint}`;
13
14 return fetch(url, {
15 method,
16 headers: {
17 Authorization: `Bearer ${token}`,
18 'Content-Type': 'application/json',
19 },
20 ...(body ? { body: JSON.stringify(body) } : {}),
21 });
22}
23
24type FlockAttachment = {
25 title?: string;
26 description?: string;
27 color?: string;
28 actions?: Array<{ name: string; url: string }>;
29};
30
31export async function sendFlockMessage(
32 channelToken: string,
33 text: string,
34 attachments?: FlockAttachment[]
35) {
36 const body: Record<string, unknown> = {
37 token: channelToken,
38 text,
39 ...(attachments ? { attachments: JSON.stringify(attachments) } : {}),
40 };
41
42 return flockFetch('/chat.sendMessage', 'POST', body);
43}

Pro tip: Flock provides two token types: bot tokens (for sending messages as a bot) and user tokens (for acting as a specific user). Use bot tokens for automated notifications and integrations — they don't expire and represent the app rather than a person.

Expected result: Your Flock app is created at dev.flock.com, .env.local contains FLOCK_BOT_TOKEN and FLOCK_CHANNEL_TOKEN, and the flockFetch/sendFlockMessage utilities are ready to use.

2

Send formatted messages and notification widgets to Flock

Flock supports rich message formatting through its Widgets system — JSON objects that define structured cards with titles, descriptions, color accents, and action buttons. Widgets are passed as the attachments parameter (a JSON-stringified array) when calling chat.sendMessage. A Flock widget object can have: title (bold heading), description (body text, supports basic HTML-like formatting), color (hex color for the left accent stripe, e.g., '#28a745' for green), and actions (an array of button objects with name and url). Widgets are more visually structured than plain text messages and are ideal for notifications that need to convey status, include data, and provide a direct link. The chat.sendMessage endpoint accepts these key parameters: token (the channel token for the target channel), text (plain text message shown above any attachment widgets), attachments (JSON-stringified array of widget objects), and sendAs (optional, to override the bot display name for this message). All Flock API calls in this step are outbound POST requests from your server-side Next.js route to Flock's API servers. They work perfectly in Bolt's WebContainer — no CORS issues, no deployment required. You can test sending messages to your Flock channel directly from the development preview and verify they appear in Flock in real time. This is useful for iterating on message formatting quickly: change the widget JSON, trigger the API call from Bolt's preview, and immediately see how the message looks in Flock.

Bolt.new Prompt

Create the Flock notification API route. Build app/api/flock/notify/route.ts that accepts a POST with title, message, severity (info/success/warning/error), and optional actionUrl plus actionLabel. Send a formatted Flock widget message to FLOCK_CHANNEL_TOKEN channel. Use color coding: success=#28a745, error=#dc3545, warning=#ffc107, info=#17a2b8. Include the action button if actionUrl is provided.

Paste this in Bolt.new chat

app/api/flock/notify/route.ts
1// app/api/flock/notify/route.ts
2import { NextRequest, NextResponse } from 'next/server';
3import { sendFlockMessage } from '@/lib/flock';
4
5const SEVERITY_COLORS: Record<string, string> = {
6 success: '#28a745',
7 error: '#dc3545',
8 warning: '#ffc107',
9 info: '#17a2b8',
10};
11
12export async function POST(request: NextRequest) {
13 const {
14 title,
15 message,
16 severity = 'info',
17 actionUrl,
18 actionLabel,
19 } = await request.json();
20
21 if (!title || !message) {
22 return NextResponse.json(
23 { error: 'title and message are required' },
24 { status: 400 }
25 );
26 }
27
28 const channelToken = process.env.FLOCK_CHANNEL_TOKEN!;
29 const color = SEVERITY_COLORS[severity] ?? SEVERITY_COLORS.info;
30
31 const attachment: Record<string, unknown> = {
32 title,
33 description: message,
34 color,
35 };
36
37 if (actionUrl && actionLabel) {
38 attachment.actions = [{ name: actionLabel, url: actionUrl }];
39 }
40
41 const response = await sendFlockMessage(
42 channelToken,
43 `${title}`,
44 [attachment as { title?: string; description?: string; color?: string; actions?: Array<{ name: string; url: string }> }]
45 );
46
47 if (!response.ok) {
48 const error = await response.json();
49 return NextResponse.json({ error }, { status: response.status });
50 }
51
52 const data = await response.json();
53 return NextResponse.json({ success: true, uid: data.uid });
54}

Pro tip: Flock's attachments parameter must be a JSON-stringified string (not an object) in the request body when using form encoding. When sending as JSON with Content-Type application/json, pass it as a plain array. The sendFlockMessage helper above handles stringification automatically.

Expected result: POST /api/flock/notify with a title, message, and severity sends a color-coded widget message to your Flock channel. The message appears in Flock within 1–2 seconds with the correct accent color and optional action button.

3

Fetch channel information and user details

Beyond sending messages, the Flock API provides endpoints to read channel data and look up users — useful for dashboards that show team activity or for routing messages to the right channel dynamically. To list all channels your bot has access to, call GET /channels.list with your bot token. The response includes an array of channel objects with their id, name, and member count. This is how you discover the channel tokens for different channels in your workspace without going through the admin UI. To fetch details about a specific channel including its members, call GET /channels.info?token={botToken}&channelId={id}. For user information, GET /users.info?token={botToken}&userId={id} returns the user's name, email, profile picture, and online status. For direct messages, use chat.sendMessage with a userId instead of a channel token in the token parameter — Flock routes the message as a direct message to that user. This requires the bot to have been added to the workspace and the user to have messaged the bot first (or be in a shared channel). These API calls are all outbound HTTPS GET and POST requests that work from Bolt's WebContainer. Build your channel listing and user directory features entirely in the development preview before deploying. The data is real — it reflects your actual Flock workspace structure — so you can verify the API responses match what you expect before writing the frontend components.

Bolt.new Prompt

Add Flock channel management to my app. Create app/api/flock/channels/route.ts that fetches all channels the bot has access to from the Flock API. Return each channel's id, name, memberCount, and a boolean indicating if the bot is already a member. Build a simple ChannelSelector dropdown component that uses this data for routing notifications to different channels.

Paste this in Bolt.new chat

app/api/flock/channels/route.ts
1// app/api/flock/channels/route.ts
2import { NextResponse } from 'next/server';
3import { flockFetch } from '@/lib/flock';
4
5export async function GET() {
6 const response = await flockFetch('/channels.list');
7
8 if (!response.ok) {
9 return NextResponse.json({ error: 'Flock API error' }, { status: response.status });
10 }
11
12 const data = await response.json();
13
14 const channels = (data.channels ?? []).map((c: Record<string, unknown>) => ({
15 id: c.uid,
16 name: c.name,
17 memberCount: c.memberCount ?? 0,
18 description: c.description ?? '',
19 }));
20
21 return NextResponse.json({ channels, total: channels.length });
22}

Pro tip: Store frequently used channel tokens in environment variables (e.g., FLOCK_ENGINEERING_CHANNEL, FLOCK_GENERAL_CHANNEL) rather than fetching them dynamically on every request. Channel tokens are stable and don't change unless the channel is deleted.

Expected result: GET /api/flock/channels returns a list of all channels in your Flock workspace that the bot has access to, with their IDs, names, and member counts.

4

Set up slash commands and interactive responses after deployment

Flock's slash commands allow users to trigger actions in your Bolt app directly from Flock's message input. When a user types /your-command in Flock, Flock POSTs a request to your server with the command name and any arguments. Your server processes the request and responds with a message to display in the channel. Like all incoming HTTP connections, slash command requests from Flock cannot reach Bolt's WebContainer — the WebContainer has no public URL and runs inside a browser tab. You must deploy your app to Netlify or Vercel first, then register your slash command endpoint. To register a slash command: go to your Flock app at dev.flock.com → your app → Slash Commands. Add a new slash command with the name (e.g., 'status'), description, and the endpoint URL (https://your-deployed-app.netlify.app/api/flock/slash). Flock will POST to this URL when any workspace member runs the command. Your slash command handler receives a POST request with query parameters: token (a verification token to confirm the request came from Flock), userId, userName, channelId, text (the arguments after the command name), and flockEvent. Return a JSON response with text and optional attachments — this response is posted to the channel where the command was used. For interactive buttons on messages (buttons that trigger server-side actions when clicked), Flock uses Action URLs — URLs embedded in the button definition that Flock calls when the button is clicked. These also require a deployed server endpoint. Add action URLs to your Flock widget attachments after deploying.

Bolt.new Prompt

Create a Flock slash command handler. Build app/api/flock/slash/route.ts that handles POST requests from Flock slash commands. Verify the token query parameter matches FLOCK_SLASH_TOKEN env variable. Parse the 'text' parameter for the command argument. For the 'status' command, return a widget message with current app status. For unknown commands, return a help text message. This endpoint requires deployment to work.

Paste this in Bolt.new chat

app/api/flock/slash/route.ts
1// app/api/flock/slash/route.ts
2import { NextRequest, NextResponse } from 'next/server';
3
4export async function POST(request: NextRequest) {
5 // Flock sends slash command data as URL-encoded form or query params
6 const { searchParams } = new URL(request.url);
7 const token = searchParams.get('token');
8 const userId = searchParams.get('userId') ?? '';
9 const text = searchParams.get('text') ?? '';
10 const channelId = searchParams.get('channelId') ?? '';
11
12 // Verify this request came from Flock
13 if (token !== process.env.FLOCK_SLASH_TOKEN) {
14 return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
15 }
16
17 const command = text.trim().toLowerCase();
18
19 if (command === 'status' || command === '') {
20 return NextResponse.json({
21 text: 'App Status',
22 attachments: JSON.stringify([
23 {
24 title: 'System Status',
25 description: 'All systems operational',
26 color: '#28a745',
27 actions: [
28 { name: 'View Dashboard', url: process.env.NEXT_PUBLIC_BASE_URL ?? '#' },
29 ],
30 },
31 ]),
32 });
33 }
34
35 // Default: show help
36 return NextResponse.json({
37 text: 'Available commands:\n• `/bolt status` — Check app status\n• `/bolt help` — Show this message',
38 });
39}

Pro tip: Flock's slash command handler must respond within 3 seconds or Flock shows a timeout error in the channel. For operations that take longer (database queries, external API calls), respond immediately with an acknowledgment message and post the full result asynchronously.

Expected result: After deploying and registering the slash command in dev.flock.com, typing /bolt status in a Flock channel triggers a POST to your deployed endpoint and returns a status widget card in the channel.

Common use cases

App event notification system for team channels

Send formatted notifications to a Flock channel when important events occur in your Bolt app — new user signups, form submissions, payment completions, or error alerts. Messages use Flock's rich text formatting and attachment widgets to display structured data with action buttons.

Bolt.new Prompt

Create a /api/flock/notify route that sends a formatted message to a Flock channel when called. The message should have a title, body text, a color-coded widget (green for success, red for error), and an optional button with a link. Test it by sending a sample notification from the UI.

Copy this prompt to try it in Bolt.new

Deployment pipeline status updates

Post build and deployment status messages to your engineering team's Flock channel automatically. When a Vercel deployment succeeds or fails, your webhook handler posts a card to Flock with the project name, status, commit message, and a link to the deployment.

Bolt.new Prompt

Build a /api/flock/deploy-status route that accepts POST with projectName, status (success/failed), deploymentUrl, commitMessage, and branch. Send a Flock widget message with an appropriate title, color-coded status badge, and 'View Deployment' button to the FLOCK_CHANNEL_TOKEN env variable.

Copy this prompt to try it in Bolt.new

Daily digest bot for team metrics

Create a scheduled bot that sends a daily summary message to a Flock channel with key metrics from your app — daily active users, signups, revenue, or support tickets. The bot runs on a schedule and pulls data from your database before formatting it into a Flock message.

Bolt.new Prompt

Create a /api/flock/daily-digest route that fetches summary metrics from /api/metrics/daily and sends a formatted Flock message with today's stats: new signups count, active users, and top page. Format numbers with proper commas and percentage changes from yesterday. Add a 'View Dashboard' button.

Copy this prompt to try it in Bolt.new

Troubleshooting

Message sending returns 'invalid_token' error even with a freshly generated bot token

Cause: The bot token is being used to send to a channel token that the bot does not have access to, or the tokens were confused — bot token used as channel token or vice versa. Flock has separate bot tokens (for authentication) and channel tokens (for identifying target channels).

Solution: Verify that FLOCK_BOT_TOKEN is the bot authentication token from dev.flock.com and FLOCK_CHANNEL_TOKEN is the destination channel token from your Flock admin settings. These are different values. In the sendFlockMessage function, the Authorization header uses the bot token while the body token field uses the channel token.

typescript
1// Correct: bot token in header, channel token in body
2const body = {
3 token: channelToken, // destination channel
4 text: message,
5};
6fetch(url, {
7 headers: { Authorization: `Bearer ${botToken}` }, // authentication
8});

Slash command returns a 404 or connection refused error in Flock when the command is invoked

Cause: The slash command endpoint URL is pointing to the Bolt WebContainer preview URL, which is not publicly accessible from Flock's servers, or the endpoint path does not match what was registered in dev.flock.com.

Solution: Deploy your app to Netlify or Vercel first, then register the slash command endpoint with your deployed domain URL (e.g., https://your-app.netlify.app/api/flock/slash). The Bolt preview URL ending in .webcontainer-api.io is only accessible from your local browser session.

Channel messages appear but with no formatting — plain text instead of colored widget cards

Cause: The attachments parameter is not being JSON-stringified correctly, or the attachment object structure does not match Flock's expected format. Flock silently drops malformed attachments and sends only the plain text.

Solution: Ensure the attachments value is a JSON-stringified string when passed in the request body: attachments: JSON.stringify([{ title, description, color }]). Verify the color field uses a valid hex color with the # prefix (e.g., '#28a745'). Test the attachment JSON structure with the Flock API playground at dev.flock.com.

typescript
1// Correct: JSON-stringified attachments
2const body = {
3 token: channelToken,
4 text: 'Notification',
5 attachments: JSON.stringify([{ title: 'Alert', description: 'Details here', color: '#dc3545' }]),
6};

Best practices

  • Store FLOCK_BOT_TOKEN and FLOCK_CHANNEL_TOKEN as server-side environment variables only — never use NEXT_PUBLIC_ prefix as they would be exposed in the browser bundle and allow anyone to post to your Flock channels.
  • Cache frequently used channel tokens in separate environment variables (FLOCK_ENGINEERING_CHANNEL, FLOCK_ALERTS_CHANNEL) rather than fetching them from the API on every request — channel tokens are stable identifiers.
  • Respond to Flock slash commands within 3 seconds — if your logic takes longer, send an immediate acknowledgment response and post the full result asynchronously via a separate sendFlockMessage call.
  • Test all channel notification logic (message formatting, widget colors, action buttons) in Bolt's WebContainer preview — sending messages to Flock channels is an outbound HTTPS call that works without deployment. Only deploy when you need slash commands or interactive button callbacks.
  • Use severity color coding consistently in your notification widgets — standardize colors across your team (green for success, red for errors, yellow for warnings) so team members can visually parse alerts at a glance.
  • Include a direct action URL in notification widgets whenever possible — a 'View Details' button linking to the relevant page in your Bolt app reduces the friction of investigating alerts and makes notifications more actionable.
  • Verify incoming slash command requests using the FLOCK_SLASH_TOKEN parameter — check it against your stored token to confirm requests are genuinely from Flock before processing them.

Alternatives

Frequently asked questions

Does Bolt.new have a native Flock integration?

No. Flock is not one of Bolt's native connectors. You build the integration manually using Next.js API routes and the Flock REST API. Bolt's AI can generate the boilerplate code when you describe what messaging features you need, but you manage the Flock app registration and credentials yourself.

Can I send Flock messages from Bolt's development preview without deploying?

Yes. Sending messages to Flock channels and fetching channel data are outbound API calls that work perfectly from Bolt's WebContainer — they are standard HTTPS requests to Flock's API servers. The features that require deployment are slash command handlers and interactive button callbacks, which need Flock to be able to POST requests back to your server. For unidirectional notification integrations, development in the Bolt preview is fully functional.

How is Flock different from Slack for API integration?

Flock's API is simpler with fewer steps to get a token and start sending messages, but it has a smaller feature set. Flock's interactive components (action buttons, slash commands) are more limited than Slack's Block Kit. Flock's webhook and event subscription systems are less comprehensive than Slack's Events API. For basic notifications and simple bots, Flock is faster to integrate; for complex interactive workflows, Slack has better developer tooling and documentation.

What are Flock channel tokens and where do I find them?

Flock uses two types of tokens: bot tokens (for authentication, obtained from dev.flock.com) and channel tokens (for identifying message destinations, found in your Flock workspace admin settings). To find channel tokens, go to your Flock workspace → Admin → Integrations → API → Channel Tokens. Each channel has a unique token that you use in the token field of the chat.sendMessage body. The bot token goes in the Authorization header.

Does Flock have a free plan for API integrations?

Yes. Flock's free plan includes 10,000 message history, unlimited channels, and access to the REST API. Custom app integration and bot creation through dev.flock.com work on the free plan. Flock's Pro plan ($4.50/user/month) adds unlimited message history, video calls, and additional admin features but the API access is available on all plans.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.