Skip to main content
RapidDev - Software Development Agency
lovable-integrationsEdge Function Integration

How to Integrate Lovable with Flock

Integrate Flock with Lovable by building a Supabase Edge Function that proxies the Flock REST API using a bot token stored in Cloud Secrets. The Edge Function sends messages to channels, creates direct messages, and manages contacts. Pair this with Flock's incoming webhook support to route notifications from your Lovable app directly into team channels without complex OAuth flows.

What you'll learn

  • How to create a Flock app and obtain a bot token for REST API access and an incoming webhook URL for simple message posting
  • How to build a Supabase Edge Function that sends messages to Flock channels and direct messages using bot token authentication
  • How to use Flock's incoming webhook URL for simple notification delivery without the full REST API
  • How to build a notification system in Lovable that routes app events to specific Flock channels
  • How to create rich message attachments with Flock's message formatting for more informative team notifications
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate15 min read40 minutesProductivityMarch 2026RapidDev Engineering Team
TL;DR

Integrate Flock with Lovable by building a Supabase Edge Function that proxies the Flock REST API using a bot token stored in Cloud Secrets. The Edge Function sends messages to channels, creates direct messages, and manages contacts. Pair this with Flock's incoming webhook support to route notifications from your Lovable app directly into team channels without complex OAuth flows.

Send Team Notifications and Messages to Flock from Lovable

Flock is a popular team messaging platform particularly prevalent in South Asian markets and among teams that prefer a lighter-weight alternative to Slack. It offers the same core features — channels, direct messages, file sharing, video calls — at a lower price point with a simpler setup. Building a Flock integration in Lovable enables your custom application to send notifications, alerts, and status updates directly into your team's Flock channels without team members needing to constantly check a separate dashboard.

Unlike Slack, which has a native connector in Lovable with automatic OAuth token management and gateway architecture, Flock requires manual setup of a bot or webhook integration. Flock's developer platform provides two integration paths: incoming webhooks (the simplest approach, for sending messages to a specific channel) and the REST API (for more complex operations like sending to multiple channels, managing contacts, and building interactive bots). For most Lovable integration use cases — sending notifications when form submissions occur, alerting teams when error thresholds are crossed, or routing customer inquiries into a support channel — the incoming webhook approach is sufficient and far simpler to implement.

The Edge Function pattern keeps your Flock token server-side while allowing the Lovable frontend to trigger notifications by calling the Edge Function. This maintains the security separation between the browser and your messaging credentials, consistent with Lovable's blue zone / red zone security model.

Integration method

Edge Function Integration

Flock has no native Lovable connector unlike Slack, which has a gateway architecture with automatic OAuth token management. Flock integration requires building a Supabase Edge Function proxy that uses either a Flock bot token (for API calls) or an incoming webhook URL (for sending messages). Both credentials are stored in Cloud Secrets and the Edge Function handles all authenticated Flock API communication, keeping tokens out of browser code.

Prerequisites

  • A Flock account with team admin access to create apps and bots
  • A Flock app created at dev.flock.com with either a bot token or incoming webhook URL
  • The Flock channel IDs where you want to send messages (visible in channel settings or from the API)
  • A Lovable project with Lovable Cloud enabled
  • Basic familiarity with Lovable's Cloud → Secrets panel

Step-by-step guide

1

Create a Flock app and obtain your bot token or webhook URL

Flock provides two ways to integrate with external apps: incoming webhooks (simplest, one-way message posting to a specific channel) and bot tokens (more flexible, full API access). For most Lovable notification use cases, start with an incoming webhook — it requires no OAuth flow and works with a simple HTTP POST request. Navigate to dev.flock.com in your browser and sign in with your Flock account. In the developer portal, you can create either a Webhook or a full App. For a webhook, click 'Add Webhook' or 'Incoming Webhooks', select the channel where you want messages to appear, and Flock generates a unique webhook URL in the format https://api.flock.com/hooks/sendMessage/YOUR-UNIQUE-TOKEN. Copy this URL. For a bot token (which allows sending to multiple channels and using the full REST API), click 'Create an App' in the dev.flock.com portal. Give it a name, description, and icon. After creation, navigate to the App's bot settings to generate a bot token. The bot token is a longer string that starts with something like 'fe8e...' and is passed as the 'token' parameter in Flock API requests. The Flock API base URL is https://api.flock.com/v2/ for REST API calls, and the message sending endpoint is https://api.flock.com/v2/chat.sendMessage. Store the bot token or webhook URL immediately — you will add it to Cloud Secrets next.

Pro tip: If you only need to send notifications to a single channel, the incoming webhook approach is much simpler than a full bot integration. The webhook URL embeds the channel destination, so no channel ID parameter is needed — just POST your message body to the URL.

Expected result: You have either a Flock incoming webhook URL (for single-channel notifications) or a Flock bot token (for multi-channel API access), ready to add to Cloud Secrets.

2

Store Flock credentials in Cloud Secrets

Open the Cloud tab in your Lovable project by clicking the '+' icon next to the Preview panel. Navigate to the Secrets section. Add your Flock credentials based on which integration approach you chose. For the incoming webhook approach: click 'Add new secret', name it FLOCK_WEBHOOK_URL, and paste your webhook URL as the value. Click Save. This is all you need for simple single-channel message sending. For the bot token approach: add FLOCK_BOT_TOKEN with your bot token value, and FLOCK_DEFAULT_CHANNEL with the channel ID you want to send to by default. Flock channel IDs are in the format 'g:xxxxxxxx' for group channels and 'd:xxxxxxxx' for direct messages — find them in the Flock URL when viewing a channel, or via the API. Your Flock credentials provide write access to your team's messaging channels. Lovable's security layer blocks approximately 1,200 hardcoded API keys from being committed daily — always use Cloud Secrets rather than pasting credentials into React code or chat prompts.

Pro tip: Store both FLOCK_WEBHOOK_URL and FLOCK_BOT_TOKEN if you want to support both simple webhook posting and more advanced API operations. The Edge Function can use whichever is appropriate for each action.

Expected result: FLOCK_WEBHOOK_URL and/or FLOCK_BOT_TOKEN appear in your Cloud → Secrets panel. The credentials are encrypted and ready for the Edge Function.

3

Create the Flock Edge Function

Build the Edge Function that handles all Flock API communication. This function supports both the simple webhook approach (for posting to a single predetermined channel) and the full bot API approach (for sending to any channel, fetching channel lists, or managing contacts). The frontend calls this function whenever it needs to send a Flock notification — the function handles authentication and API formatting. Flock messages support a rich attachment format similar to Slack's message attachments: you can include a title, description, color-coded side bar, and action buttons. The Edge Function should accept a structured payload from the frontend and format it correctly for Flock's API.

Lovable Prompt

Create a Supabase Edge Function called 'flock-proxy' at supabase/functions/flock-proxy/index.ts. Read FLOCK_WEBHOOK_URL, FLOCK_BOT_TOKEN, and FLOCK_DEFAULT_CHANNEL from Deno.env.get(). Accept POST requests with action and payload fields. Implement: 'send_webhook' — POST the payload.message (plain text or JSON with attachments) to FLOCK_WEBHOOK_URL; 'send_message' — POST to https://api.flock.com/v2/chat.sendMessage with token=FLOCK_BOT_TOKEN, channel=payload.channel or FLOCK_DEFAULT_CHANNEL, and text=payload.text, plus optional attachments array from payload.attachments; 'send_attachment' — send a rich attachment message with payload fields: channel, title, description, color ('#FF0000', '#00CC00', etc.), and optional actions array with each action having label and url; 'list_channels' — GET https://api.flock.com/v2/channels.list with token param returning channel names and IDs. Include CORS headers and error handling.

Paste this in Lovable chat

supabase/functions/flock-proxy/index.ts
1// supabase/functions/flock-proxy/index.ts
2import { serve } from 'https://deno.land/std@0.168.0/http/server.ts';
3
4const corsHeaders = {
5 'Access-Control-Allow-Origin': '*',
6 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
7};
8
9serve(async (req) => {
10 if (req.method === 'OPTIONS') {
11 return new Response('ok', { headers: corsHeaders });
12 }
13
14 try {
15 const webhookUrl = Deno.env.get('FLOCK_WEBHOOK_URL');
16 const botToken = Deno.env.get('FLOCK_BOT_TOKEN');
17 const defaultChannel = Deno.env.get('FLOCK_DEFAULT_CHANNEL');
18
19 const { action, payload = {} } = await req.json();
20
21 switch (action) {
22 case 'send_webhook': {
23 if (!webhookUrl) throw new Error('FLOCK_WEBHOOK_URL not configured');
24 const body = typeof payload.message === 'string'
25 ? { text: payload.message }
26 : payload.message;
27 const res = await fetch(webhookUrl, {
28 method: 'POST',
29 headers: { 'Content-Type': 'application/json' },
30 body: JSON.stringify(body),
31 });
32 const data = await res.text();
33 return new Response(JSON.stringify({ result: data }), {
34 headers: { ...corsHeaders, 'Content-Type': 'application/json' },
35 });
36 }
37 case 'send_message': {
38 if (!botToken) throw new Error('FLOCK_BOT_TOKEN not configured');
39 const params = new URLSearchParams({
40 token: botToken,
41 channel: payload.channel || defaultChannel || '',
42 text: payload.text || '',
43 });
44 if (payload.attachments) {
45 params.set('attachments', JSON.stringify(payload.attachments));
46 }
47 const res = await fetch(`https://api.flock.com/v2/chat.sendMessage?${params}`);
48 const data = await res.json();
49 return new Response(JSON.stringify(data), {
50 headers: { ...corsHeaders, 'Content-Type': 'application/json' },
51 });
52 }
53 case 'send_attachment': {
54 if (!botToken) throw new Error('FLOCK_BOT_TOKEN not configured');
55 const attachment = {
56 title: payload.title || '',
57 description: payload.description || '',
58 color: payload.color || '#0084FF',
59 actions: payload.actions || [],
60 };
61 const params = new URLSearchParams({
62 token: botToken,
63 channel: payload.channel || defaultChannel || '',
64 text: payload.text || '',
65 attachments: JSON.stringify([attachment]),
66 });
67 const res = await fetch(`https://api.flock.com/v2/chat.sendMessage?${params}`);
68 const data = await res.json();
69 return new Response(JSON.stringify(data), {
70 headers: { ...corsHeaders, 'Content-Type': 'application/json' },
71 });
72 }
73 case 'list_channels': {
74 if (!botToken) throw new Error('FLOCK_BOT_TOKEN not configured');
75 const res = await fetch(`https://api.flock.com/v2/channels.list?token=${botToken}`);
76 const data = await res.json();
77 return new Response(JSON.stringify(data), {
78 headers: { ...corsHeaders, 'Content-Type': 'application/json' },
79 });
80 }
81 default:
82 return new Response(
83 JSON.stringify({ error: `Unknown action: ${action}` }),
84 { status: 400, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
85 );
86 }
87 } catch (err) {
88 return new Response(
89 JSON.stringify({ error: err.message }),
90 { status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
91 );
92 }
93});

Pro tip: Test your webhook URL directly from Cloud → Logs by sending a test POST request. If the webhook responds with 'ok', your Flock integration is working. Then proceed to test from your frontend components.

Expected result: The flock-proxy Edge Function is deployed. Sending a test message via the send_webhook or send_message action delivers a message to your specified Flock channel.

4

Build notification triggers in your Lovable app

With the Edge Function deployed, add Flock notification calls to the meaningful events in your application. The pattern is consistent: when a significant event occurs (form submission, user signup, payment, error), call the flock-proxy Edge Function with the appropriate channel and a formatted message. The frontend component does not need to know anything about Flock's API — it just calls the Edge Function. Ask Lovable to add notifications to your existing forms and event handlers. You can also build an admin notification settings panel where you configure which events send Flock notifications and to which channels, storing this configuration in Supabase so it can be changed without code deployments.

Lovable Prompt

Add Flock notifications to our existing contact form and signup flow. After a successful contact form submission, call the flock-proxy Edge Function with action 'send_attachment' to post a notification to our support channel. The attachment should have title 'New Contact Submission', description with the submitter's name and message preview, color '#0084FF', and an action button labeled 'View in Dashboard' linking to our admin page. After a new user signup, call the Edge Function with action 'send_message' to post a formatted text notification to our team channel with the new user's email and signup date. Add error handling so Flock notification failures do not interrupt the main form submission flow — use try/catch and continue even if the notification fails.

Paste this in Lovable chat

Pro tip: Always wrap Flock notification calls in try/catch blocks and do not await them in the critical path if notification failure should not block the user action. Use fire-and-forget pattern: call the function without awaiting for non-critical notifications.

Expected result: Submitting your contact form delivers a formatted Flock notification to the configured channel within a few seconds. The form submission still completes successfully even if the Flock notification fails.

Common use cases

App event notifications routed to team channels

Send automatic notifications to specific Flock channels when important events happen in your Lovable app: a new user signs up, a contact form is submitted, a payment is received, or an error threshold is exceeded. Each notification includes relevant context formatted as a Flock message attachment — for example, a new signup notification shows the user's name, email, plan tier, and a link to their profile in the app.

Lovable Prompt

Add Flock notification functionality to our app. Create an Edge Function that accepts a POST request with fields: channel (the Flock channel ID), title, message, and optional fields like link_text and link_url. The function should call the Flock API to send a formatted message to the specified channel using our FLOCK_BOT_TOKEN. Then add notification triggers in three places: 1) After a successful user signup, send a notification to the '#new-users' channel. 2) After a contact form is submitted, notify '#support'. 3) When an error occurs in the app, send details to '#alerts'. Use Flock's attachment format to make messages visually clear.

Copy this prompt to try it in Lovable

Daily summary digest sent to a team channel

Build a scheduled digest that aggregates daily activity metrics from your Supabase database and posts a summary to a Flock channel every morning. The digest shows key metrics like new users, active sessions, revenue, and any anomalies. This keeps the whole team informed about app health without anyone needing to log into a dashboard, and the Flock message format includes a link back to the full dashboard for details.

Lovable Prompt

Create a daily digest feature that runs on a schedule. Build an Edge Function called 'flock-daily-digest' that queries Supabase for yesterday's key metrics: new user count, total revenue, form submissions, and error count. Format these as a Flock message with a clear header 'Daily Summary for {date}' and metric rows with emoji indicators (green for good, yellow for attention, red for concern). Send the formatted message to the FLOCK_CHANNEL_ID stored in Cloud Secrets using the FLOCK_BOT_TOKEN. Add a button in the admin dashboard to manually trigger the digest send for testing.

Copy this prompt to try it in Lovable

Customer support ticket routing to Flock channels

Create a support ticket system where customer inquiries submitted through your Lovable app are automatically routed to the relevant Flock channel based on category. A billing question goes to #billing-support, a technical issue to #tech-support, and a general query to #customer-success. Each message includes the customer's message, contact information, and a priority level based on their plan tier.

Lovable Prompt

Build a customer support ticket form page with fields: name, email, category (billing/technical/general), priority (low/medium/high), and message. On submission, save the ticket to a Supabase support_tickets table, then call the flock-proxy Edge Function to send a notification to the appropriate Flock channel based on category. Format the message with the customer name, email, priority badge, message preview, and a direct link to the ticket in the admin dashboard. Add acknowledgment email sending via Supabase's built-in email. Show the customer a confirmation page with a ticket number after submission.

Copy this prompt to try it in Lovable

Troubleshooting

Webhook post returns 'ok' but no message appears in the Flock channel

Cause: The webhook URL is correct but the message format is not valid JSON, or the text field is empty or undefined. Flock webhooks silently accept requests with valid HTTP responses but discard messages with malformed content.

Solution: Verify that the message body sent to the webhook is valid JSON with a non-empty 'text' field. Log the exact body being sent in the Edge Function before the fetch call. Test the webhook directly by sending a minimal valid payload: {"text": "test message"}. Check that you are not accidentally sending an empty string or null as the message text.

typescript
1const body = JSON.stringify({ text: payload.message || 'Notification from Lovable App' });

Bot token API calls return 'user_not_found' or 'channel_not_found' error

Cause: The channel ID passed to the send_message action is incorrect or uses the wrong format. Flock channel IDs have specific prefixes: 'g:' for group channels and 'd:' for direct message conversations. Using a bare channel name or URL slug instead of the full ID causes this error.

Solution: Use the list_channels action to fetch valid channel IDs from the Flock API and verify the format of your FLOCK_DEFAULT_CHANNEL secret. Channel IDs from the Flock API will be in the format 'g:xxxxxxxxxxxxxxxx'. Make sure the bot has been added to the channel — bots cannot send messages to channels they are not members of.

Rich attachments display as plain text without the formatted card appearance

Cause: The attachments parameter is not being serialized correctly as a JSON string within the URL parameters, or the attachment object structure does not match what Flock expects. Flock's API requires attachments as a JSON-encoded string within form parameters, not as a nested JSON object.

Solution: Ensure the attachments value is serialized with JSON.stringify() before being added to the URL params, not just passed as an object. The entire attachments array must be a JSON string: params.set('attachments', JSON.stringify([attachmentObject])). Verify the attachment object has the correct fields: title, description, and color (as a hex string).

typescript
1params.set('attachments', JSON.stringify([{ title: payload.title, description: payload.description, color: payload.color }]));

Edge Function calls succeed but Flock messages are sometimes delayed by several minutes

Cause: Flock's message delivery can experience delays during high traffic periods or when the recipient device is offline and messages are queued. This is a Flock platform behavior rather than an integration issue.

Solution: Delays in Flock message delivery are a platform-level concern that cannot be resolved in the integration code. Verify the Edge Function is completing quickly by checking Cloud → Logs execution times. If the Edge Function itself takes only milliseconds and the message still takes minutes to appear, the delay is on Flock's side. Consider using Flock's notification priority settings for time-sensitive alerts.

Best practices

  • Store Flock bot tokens and webhook URLs in Cloud → Secrets, never in React components — tokens grant the ability to post messages to all channels the bot has access to.
  • Use the incoming webhook approach for simple single-channel notifications and reserve the bot token API for use cases that require sending to multiple channels or reading channel data.
  • Always make Flock notification calls non-blocking — wrap them in try/catch and do not let notification failures prevent the primary user action (form submission, payment, etc.) from completing.
  • Include a direct link back to the relevant record in your Lovable app in every Flock notification — this lets team members click through from the notification to take immediate action rather than having to navigate separately.
  • Use Flock's attachment color coding consistently: green (#00CC00) for success events, yellow (#FFB800) for warnings, and red (#FF0000) for errors, so team members can visually scan notification severity at a glance.
  • Store notification configuration (which events notify which channels) in Supabase rather than hardcoding channel IDs in the Edge Function — this allows changing notification routing without code deployments.
  • Test notifications in a dedicated test Flock channel before enabling them in production channels to avoid flooding your team with test messages during development.

Alternatives

Frequently asked questions

What is the difference between a Flock webhook URL and a bot token?

A Flock incoming webhook URL is pre-configured to post messages to a single specific channel — it is a simple URL you POST JSON to, requiring no authentication header. A bot token is a credential for a Flock bot that can send messages to any channel the bot has been added to, retrieve channel lists, and perform other API operations. Use a webhook URL for simple single-channel notifications; use a bot token when you need to send to multiple channels or access other Flock API features.

Can I use Flock as a replacement for Slack in Lovable?

Functionally yes, but the integration complexity differs. Slack has a native Lovable connector with automatic OAuth management and a gateway architecture that handles token refresh, rate limiting, and credential rotation automatically. Flock requires manual setup of the Edge Function proxy as described in this guide. For teams already using Flock, this integration provides equivalent notification capabilities. For teams choosing between the two, Slack's native connector offers a lower-effort integration path.

How do I find my Flock channel IDs for the bot API?

Channel IDs are in the format 'g:xxxxxxxxxxxxxxxx' for group channels. The easiest way to find them is to use the list_channels action in the Edge Function after setting up your bot token — this returns all channels with their IDs and names. You can also find channel IDs in the Flock web app URL when viewing a channel: the alphanumeric string after '/channel/' in the URL is part of the channel ID.

Is there a rate limit for Flock API calls?

Flock imposes rate limits on API calls, though the exact limits are not prominently published in their developer documentation. In practice, for typical notification use cases (a few messages per minute), rate limits are not a concern. For high-volume notification scenarios — sending hundreds of messages per minute — implement queuing and batching in your Edge Function, or use a message broker pattern where events are queued in Supabase and processed in controlled batches.

Can I receive messages from Flock in my Lovable app?

Yes, but this requires implementing a Flock slash command or bot integration that POSTs to your Edge Function URL when specific commands are triggered in Flock. Configure the slash command endpoint in the Flock developer portal to point to your Edge Function's URL. The Edge Function receives the command payload, processes it, and can store the result in Supabase. This enables two-way integration where Flock commands trigger actions in your Lovable app.

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.