To integrate Flock with V0 by Vercel, generate an app UI with V0, create a Next.js API route that posts notifications to Flock channels using incoming webhooks, add your Flock webhook URL to Vercel environment variables, and deploy. Your app can send formatted messages, alerts, and updates to Flock team channels directly from server-side events.
Send Team Notifications from V0-Generated Apps to Flock Channels
Flock is popular among teams in India, Southeast Asia, and globally who prefer its clean interface and competitive pricing. Its incoming webhook system follows the same pattern as Slack webhooks — you create a webhook URL for a specific channel, and any application can POST a JSON payload to that URL to send a message. This simplicity makes Flock webhook integration one of the fastest integrations to implement in a Next.js API route.
The most common use cases are event-driven notifications: send a message to the #signups channel when a new user registers, ping #errors when an unhandled exception occurs in production, notify #sales when a new lead fills out a contact form, or alert #ops when a payment fails. These notifications transform silent backend events into visible team awareness without requiring anyone to log into a separate dashboard. V0 generates the frontend that triggers these events; the API routes handle sending the Flock notifications.
Beyond simple text messages, Flock supports rich message formatting through its attachment system: you can add colored sidebars, bold titles, structured fields, and buttons that link to relevant resources. A new user notification, for example, could include the user's name, email, signup source, and a direct link to their record in your database or CRM — all formatted as a clean card in the Flock channel. The Flock API also supports more advanced integrations like bot users and slash commands for two-way communication, but the incoming webhook pattern is sufficient for most notification use cases.
Integration method
Flock integrates with V0-generated Next.js apps through incoming webhooks and server-side API routes. Your app triggers a Flock webhook URL from an API route whenever it needs to send a notification — a new user signup, a critical error alert, a form submission, or a business event. The webhook URL is stored as a server-only Vercel environment variable. V0 generates the frontend UI, and the API route handles the notification dispatch to Flock channels.
Prerequisites
- A Flock account with admin access to create incoming webhook integrations at dev.flock.com/webhooks
- A Flock channel to send notifications to — create a dedicated #notifications or #alerts channel in your Flock workspace
- Your Flock incoming webhook URL — created at dev.flock.com → Incoming Webhooks → Create New
- A V0 account at v0.dev to generate the frontend UI that triggers notifications
- A Vercel account to deploy the Next.js app and store the webhook URL as an environment variable
Step-by-step guide
Create a Flock Incoming Webhook
Create a Flock Incoming Webhook
Before building any code, set up the Flock webhook that your API route will call. Go to dev.flock.com and sign in with your Flock account. Navigate to Apps → Incoming Webhooks and click 'Create New'. Choose the channel you want notifications sent to (create a dedicated #notifications, #signups, or #alerts channel first if needed), give the webhook a name like 'My App Notifications', and optionally upload a bot icon. Click Create and copy the webhook URL — it looks like https://api.flock.com/hooks/sendMessage/token_string. This URL is your secret — anyone with this URL can post messages to your Flock channel, so treat it like an API key. You can also create multiple webhooks pointing to different channels: one for #errors, one for #signups, one for #leads. Store each in a separate environment variable so your API route can route different notification types to appropriate channels. The webhook is ready to receive POST requests immediately — no further configuration needed on the Flock side.
Create a notification testing panel with three buttons: 'Send Signup Alert' (posts a test new user notification), 'Send Error Alert' (posts a test error with red color), and 'Send Lead Notification' (posts a test lead with contact info). Each button shows a loading state while posting to /api/notify/flock and displays a success or error badge. Simple admin panel design with distinct color coding per notification type.
Paste this in V0 chat
Pro tip: Create separate Flock webhooks for different notification types and different channels. Store them as FLOCK_WEBHOOK_SIGNUPS, FLOCK_WEBHOOK_ERRORS, FLOCK_WEBHOOK_LEADS in Vercel. This lets your API route route notification types to the appropriate channels without having team members @mentioned for every low-priority notification.
Expected result: A Flock incoming webhook URL is created and pointing to your chosen channel. Manually POSTing { text: 'Test message' } to the webhook URL with curl or Postman sends a message to the channel.
Create the Flock Notification API Route
Create the Flock Notification API Route
Create the API route that formats and sends Flock notifications. Flock's incoming webhook accepts a JSON POST request with a text field for simple messages, or an attachments array for rich formatted messages. The attachment format is similar to Slack's: each attachment can have a title, title_link, text, color (CSS hex or color name), and fields array for structured key-value data. Create the route at app/api/notify/flock/route.ts. The route accepts a notification type, title, message body, and optional additional data fields from the request body. It constructs the Flock payload and POSTs to the webhook URL stored in FLOCK_WEBHOOK_URL. For different notification types (error vs signup vs lead), use different colors: red (#FF4444) for errors, green (#00C851) for signups, and blue (#33b5e5) for leads. The route should be fire-and-forget from the caller's perspective — the calling route (your signup handler, your error handler) sends the notification and doesn't wait for the Flock response to complete the user-facing action. Handle this by not blocking on the Flock notification response in your main API routes.
1// app/api/notify/flock/route.ts2import { NextRequest, NextResponse } from 'next/server';34const NOTIFICATION_COLORS: Record<string, string> = {5 success: '#00C851',6 error: '#FF4444',7 warning: '#FF8800',8 info: '#33b5e5',9 lead: '#AA66CC',10};1112interface FlockField {13 title: string;14 value: string;15 short?: boolean;16}1718interface NotificationPayload {19 type?: string;20 title: string;21 message: string;22 fields?: FlockField[];23 actionUrl?: string;24 actionLabel?: string;25 channel?: 'default' | 'errors' | 'leads' | 'signups';26}2728function getWebhookUrl(channel: string): string {29 const urls: Record<string, string | undefined> = {30 errors: process.env.FLOCK_WEBHOOK_ERRORS,31 leads: process.env.FLOCK_WEBHOOK_LEADS,32 signups: process.env.FLOCK_WEBHOOK_SIGNUPS,33 default: process.env.FLOCK_WEBHOOK_URL,34 };35 return urls[channel] || urls.default || '';36}3738export async function POST(request: NextRequest) {39 const webhookUrl = process.env.FLOCK_WEBHOOK_URL;4041 if (!webhookUrl) {42 return NextResponse.json({ error: 'Flock webhook not configured' }, { status: 500 });43 }4445 let body: NotificationPayload;46 try {47 body = await request.json();48 } catch {49 return NextResponse.json({ error: 'Invalid request body' }, { status: 400 });50 }5152 const { type = 'info', title, message, fields = [], actionUrl, actionLabel, channel = 'default' } = body;5354 const targetUrl = getWebhookUrl(channel);55 const color = NOTIFICATION_COLORS[type] || NOTIFICATION_COLORS.info;5657 // Build Flock message payload with attachment58 const flockPayload: Record<string, unknown> = {59 text: '', // Required but can be empty when using attachments60 attachments: [{61 title,62 description: { type: 'text', value: message },63 color,64 views: {65 flockml: `<flockml>${message}${fields.map(f =>66 `<br/><b>${f.title}:</b> ${f.value}`67 ).join('')}${actionUrl ? `<br/><a href="${actionUrl}">${actionLabel || 'View Details'}</a>` : ''}</flockml>`,68 },69 }],70 };7172 try {73 const response = await fetch(targetUrl, {74 method: 'POST',75 headers: { 'Content-Type': 'application/json' },76 body: JSON.stringify(flockPayload),77 });7879 if (!response.ok) {80 const error = await response.text();81 console.error('Flock webhook error:', response.status, error);82 return NextResponse.json(83 { error: 'Failed to send Flock notification' },84 { status: 500 }85 );86 }8788 return NextResponse.json({ success: true });89 } catch (error) {90 console.error('Flock notification error:', error);91 return NextResponse.json({ error: 'Notification failed' }, { status: 500 });92 }93}Pro tip: Flock's webhook uses FlockML for rich message formatting (similar to HTML). The <flockml> element supports <b> for bold, <a href> for links, and <br/> for line breaks. Keep messages concise — long messages get truncated in the Flock channel preview.
Expected result: POSTing to /api/notify/flock with { type: 'success', title: 'New Signup', message: 'John Doe just signed up!' } sends a green-colored message to your configured Flock channel within 1-2 seconds.
Trigger Flock Notifications from App Events
Trigger Flock Notifications from App Events
With the notification route in place, add Flock notification calls to the app events that warrant team alerts. The pattern is straightforward: in your existing API route handler (user signup, contact form submission, payment webhook, error handler), after performing the main action, trigger the Flock notification as a non-blocking side effect. Use a Promise that doesn't await — this way the user-facing response is returned immediately without waiting for the Flock API call to complete. If you want guaranteed delivery, you can await the notification call, but this adds Flock's response time (~200-500ms) to your route's response time. For error notifications specifically, call the Flock route inside catch blocks using a try-catch that swallows errors — you don't want a failing notification to prevent your error handler from completing. Add the notification calls to your existing form submission handlers, authentication callbacks, or any other high-value events. The notification API route you built is flexible enough to handle multiple notification types, so one route handles all your Flock communications.
Update the signup form API route to call /api/notify/flock after successfully saving the user, with type 'success', title 'New Signup', and message containing the user's name and email. Also add an error notification call in the catch block with type 'error' and the error message. Show the user a success page regardless of whether the Flock notification succeeds — don't block the user experience on notification delivery.
Paste this in V0 chat
1// Example: triggering Flock notification from a signup API route2// app/api/signup/route.ts3import { NextRequest, NextResponse } from 'next/server';45async function sendFlockNotification(payload: {6 type: string;7 title: string;8 message: string;9 fields?: { title: string; value: string }[];10}): Promise<void> {11 try {12 await fetch(`${process.env.NEXT_PUBLIC_APP_URL}/api/notify/flock`, {13 method: 'POST',14 headers: { 'Content-Type': 'application/json' },15 body: JSON.stringify(payload),16 });17 } catch {18 // Silently fail — don't let notification errors break the main flow19 console.error('Flock notification failed (non-critical)');20 }21}2223export async function POST(request: NextRequest) {24 try {25 const { name, email, company } = await request.json();2627 // TODO: Save user to your database here28 // await db.users.create({ name, email, company });2930 // Send Flock notification (non-blocking)31 sendFlockNotification({32 type: 'success',33 title: 'New Signup!',34 message: `${name} from ${company || 'Unknown Company'} just signed up.`,35 fields: [36 { title: 'Email', value: email },37 { title: 'Company', value: company || 'Not provided' },38 { title: 'Signed up', value: new Date().toLocaleString() },39 ],40 }); // Note: intentionally NOT awaited4142 return NextResponse.json({ success: true });43 } catch (error) {44 // Send error notification45 sendFlockNotification({46 type: 'error',47 title: 'Signup Error',48 message: `Failed to process signup: ${error instanceof Error ? error.message : 'Unknown error'}`,49 }); // Also not awaited5051 return NextResponse.json({ error: 'Signup failed' }, { status: 500 });52 }53}Pro tip: For production apps, consider using Vercel's waitUntil() from @vercel/functions to send the Flock notification after the response is returned. This ensures guaranteed delivery without blocking the response: import { waitUntil } from '@vercel/functions'; waitUntil(sendFlockNotification(...));
Expected result: Submitting the signup form triggers a Flock notification to your channel within 1-3 seconds. The user sees an immediate success response, and your team sees a formatted Flock message with the signup details.
Add Webhook URL to Vercel and Deploy
Add Webhook URL to Vercel and Deploy
Push your project to GitHub and add the Flock webhook URL to Vercel. Open the Vercel Dashboard → Settings → Environment Variables. Add FLOCK_WEBHOOK_URL with the webhook URL you copied from dev.flock.com (it looks like https://api.flock.com/hooks/sendMessage/your_token). If you created separate webhooks for different channels, add FLOCK_WEBHOOK_ERRORS, FLOCK_WEBHOOK_SIGNUPS, and FLOCK_WEBHOOK_LEADS as well. Also add NEXT_PUBLIC_APP_URL with your Vercel deployment URL. None of the webhook URLs should have the NEXT_PUBLIC_ prefix — they are server-side secrets. After saving and deploying, test by triggering a notification from your deployed app. The message should appear in your Flock channel within 1-2 seconds. If it doesn't arrive, check the Vercel Function Logs for errors in your notification route. Common issues are the webhook URL being stored with extra whitespace, or the FLOCK_WEBHOOK_URL not being set for the correct Vercel environment (Production vs Preview).
Pro tip: You can test your Flock webhook URL directly with a curl command before deploying: curl -X POST 'YOUR_FLOCK_WEBHOOK_URL' -H 'Content-Type: application/json' -d '{"text": "Test from curl"}'. If this sends a message to Flock, your webhook URL is correct.
Expected result: Your Vercel app sends Flock notifications for configured events. New signups, errors, and other app events appear as formatted messages in your Flock channels within seconds of occurring.
Common use cases
New User Signup Notifications
When a new user registers through a V0-generated signup form, the API route sends a notification to the #signups Flock channel with the user's name, email, and signup source. The team stays aware of growth in real time without checking dashboards.
Create a user signup form with name, email, and company fields and a 'Get Started' button. When submitted, call /api/signup which registers the user AND posts a notification to Flock via /api/notify/flock. Show a success page after signup. Include loading state and error handling. Clean SaaS signup page design with blue gradient.
Copy this prompt to try it in V0
Error and Alert Monitoring
A production error monitoring setup where critical application errors in Next.js API routes trigger Flock notifications to the #alerts channel. Each alert includes the error message, the affected endpoint, and a timestamp — enabling the team to respond to production issues without setting up a full monitoring service.
Build an admin dashboard with a 'Test Alert' button that posts a sample error notification to /api/notify/flock with a red warning color, showing error type, affected component, timestamp, and environment (production/staging). Also add a 'Send Daily Summary' button that posts an aggregated daily stats notification. Dashboard admin panel design.
Copy this prompt to try it in V0
Contact Form Lead Notifications
A lead generation landing page where when a visitor submits the contact form, a formatted Flock message goes to the #leads channel with the prospect's name, company, interest area, and a direct link to reply via email. Ensures no leads are missed even if the CRM notification email gets overlooked.
Design a contact form with name, company, email, and message fields plus a 'Send Message' button. On submission, call /api/contact which saves the lead AND sends a Flock notification via POST to /api/notify/flock including all form fields plus a 'Reply via Email' button in the Flock message. Show a thank-you page after submission. Professional B2B design.
Copy this prompt to try it in V0
Troubleshooting
POST to Flock webhook returns 200 but no message appears in the channel
Cause: The webhook URL was created for a different channel than you're checking, or the Flock payload structure is wrong — specifically, Flock requires either a non-empty 'text' field or a non-empty 'attachments' array. An empty text field with no attachments sends silently without a visible message.
Solution: Verify the webhook is connected to the correct channel in dev.flock.com → Incoming Webhooks. Include either a non-empty text field or at least one attachment with content. Log the full response body from the webhook request — Flock sometimes returns descriptive error information even with a 200 status.
1// Always include a fallback text value:2const flockPayload = {3 text: title, // Non-empty fallback text4 attachments: [{ ... }],5};Webhook returns 403 or 'Invalid webhook URL'
Cause: The Flock webhook URL is incorrect, has been deleted from the Flock developer portal, or the Flock workspace the webhook was created in has been deactivated.
Solution: Verify the webhook exists and is active at dev.flock.com → Incoming Webhooks. If deleted, create a new webhook and update the FLOCK_WEBHOOK_URL in Vercel. Ensure the full URL including the token at the end is copied correctly.
FLOCK_WEBHOOK_URL is undefined in Vercel functions
Cause: The environment variable was set in .env.local for local development but not added to Vercel's dashboard environment variables, or it was added after the last deployment without triggering a redeploy.
Solution: Add FLOCK_WEBHOOK_URL in Vercel Dashboard → Settings → Environment Variables. Ensure it's set for Production (and Preview if you want notifications from preview deployments). Trigger a fresh redeploy after adding the variable.
Flock notifications delay user response time by 500ms or more
Cause: The Flock webhook call is being awaited in the main API route handler, so the user's response is blocked until Flock responds. This adds network latency to every triggered event.
Solution: Remove the await from the sendFlockNotification call so it runs asynchronously. For guaranteed delivery with no blocking, use Vercel's waitUntil() from @vercel/functions to schedule the notification after the response is sent.
1import { waitUntil } from '@vercel/functions';2// In your route handler:3waitUntil(sendFlockNotification(payload)); // Non-blocking, guaranteed delivery4return NextResponse.json({ success: true }); // Returns immediatelyBest practices
- Store Flock webhook URLs as server-side Vercel environment variables (no NEXT_PUBLIC_ prefix) — anyone with the webhook URL can post messages to your channel
- Create separate webhooks for different notification categories (errors, signups, leads) so team members can subscribe to only relevant channels
- Use Flock's color coding consistently: red for errors, green for success/signups, yellow/orange for warnings, blue for informational updates
- Make Flock notifications non-blocking by not awaiting them in user-facing API routes — use waitUntil() for guaranteed delivery without response delay
- Include actionable links in Flock messages (links to the new user's record, the failing request's trace, or the payment in your dashboard) so team members can act immediately
- Avoid sending Flock notifications for every minor event — reserve notifications for high-value or action-required events to prevent notification fatigue
- Add rate limiting or deduplication for error notifications to prevent a cascading error from flooding your Flock channel with hundreds of identical alerts
Alternatives
Use Microsoft Teams instead of Flock if your organization is in the Microsoft 365 ecosystem and needs integration with Teams meetings, SharePoint, and Microsoft workflows.
Use Mailchimp for subscriber list management and marketing campaigns instead of Flock, which is for internal team notifications.
Use Zendesk Sunshine Conversations instead of Flock if you need customer-facing omnichannel messaging rather than internal team notifications.
Frequently asked questions
Is Flock free to use for webhook integrations?
Flock has a free plan that supports up to 10,000 messages per month, with unlimited public channels and basic integrations including incoming webhooks. For teams needing unlimited messages, priority support, and advanced admin controls, paid plans start at $4.50 per user per month. Incoming webhooks are available on all plans including free.
What is the difference between Flock incoming webhooks and the Flock API?
Incoming webhooks are one-way: your app POSTs messages to Flock. They're the simplest integration and require no authentication beyond knowing the webhook URL. The Flock API is broader — it supports reading channel messages, managing users, creating bots that respond to messages, and slash commands. For sending notifications from your app, incoming webhooks are sufficient and much simpler to implement than the full API.
Can I send Flock messages with buttons or interactive elements?
Yes. Flock supports message buttons through the 'widgets' property in the attachment payload. Buttons can link to URLs (opening in the user's browser) or trigger callback URLs in your app (for two-way interaction). Button-based interactions require setting up a Flock app with interactive components rather than just incoming webhooks. For simple link buttons, use the <a href> tag in FlockML inside the attachment's views.flockml field.
How do I send Flock notifications to multiple channels with one webhook call?
You can't fan out to multiple channels with a single webhook call — each webhook URL is bound to one channel. To notify multiple channels, create a separate webhook for each channel and call each URL. Alternatively, notify one primary channel and use Flock's internal notification routing (Flock bots can forward messages between channels), though this requires a more complex bot setup than simple webhooks.
Can I format code blocks in Flock messages for error notifications?
Yes. In Flock's FlockML (used inside the views.flockml attachment field), you can use <pre> tags for preformatted code blocks and <code> for inline code. For error notifications, wrapping stack traces in <pre> tags makes them readable in the Flock channel. Keep code blocks short — very long stack traces are better linked to an external error tracking service.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation