Deployment & Guide
Everything you need to deploy your OmniFlow script and wire it to every platform.
https://your-app.lovable.app/api/public/webhook/metaসমস্যা: Facebook যখন callback URL যাচাই করে, তখন একটি GET request পাঠায় — hub.mode, hub.verify_token, hub.challenge সহ। আমাদের সার্ভারকে অবশ্যই raw hub.challenge মানটি plain text হিসেবে ফেরত দিতে হবে (JSON বা HTML নয়)।
সমাধান: আমরা একটি public backend endpoint তৈরি করেছি — /api/public/webhook/meta। এই path-টি Lovable-এর auth wall bypass করে, তাই Facebook সরাসরি call করতে পারে। GET request এলে token মিলিয়ে দেখে এবং সফল হলে শুধু hub.challenge-এর raw স্ট্রিং (status 200, text/plain) ফেরত দেয়। token না মিললে 403 Forbidden।
- Lovable Cloud → Secrets-এ এই গুলো যোগ করুন:
META_WEBHOOK_VERIFY_TOKEN,META_PAGE_ACCESS_TOKEN,GOOGLE_SHEET_ID,GOOGLE_SHEET_TAB,GOOGLE_SERVICE_ACCOUNT_JSON। - অ্যাপটি Publish করুন (উপরের ডানদিকের Publish বাটন)। Publish না হলে external URL কাজ করবে না।
- Meta Developer Portal → Webhooks-এ Callback URL হিসেবে দিন:
https://<your-app>.lovable.app/api/public/webhook/meta - Verify Token ফিল্ডে dashboard-এ সেভ করা সেই একই token পেস্ট করুন (যেটি আপনি
META_WEBHOOK_VERIFY_TOKENsecret-এও রেখেছেন)। - "Verify and Save" চাপুন — এবার validation সফল হবে। এরপর Page subscription যোগ করে live message reply শুরু হবে।
বিকল্প: চাইলে এই handler-এর কোড Supabase Edge Function, Vercel, বা Railway-তেও deploy করতে পারেন — তবে Lovable Cloud-এ already built-in সাপোর্ট আছে, আলাদা hosting দরকার নেই।
.env file locally).| Variable | Description | Copy |
|---|---|---|
VERCEL_URL | Public URL of your deployed app (used to build webhook callbacks). | |
SUPABASE_URL | Lovable Cloud / Supabase project URL. | |
SUPABASE_SERVICE_ROLE_KEY | Server-side key. Never expose to the browser. | |
SUPABASE_PUBLISHABLE_KEY | Public anon key safe to ship to the client. | |
GOOGLE_SHEET_ID | ID from your Google Sheet URL between /d/ and /edit. | |
GOOGLE_SERVICE_ACCOUNT_JSON | Full service account JSON, stringified. | |
META_APP_ID | Meta Developer App ID for Messenger & Instagram. | |
META_APP_SECRET | Meta App Secret. Required to verify webhook signatures. | |
META_WEBHOOK_VERIFY_TOKEN | Token Meta echoes back when subscribing to webhooks. | |
META_PAGE_ACCESS_TOKEN | Long-lived Page Access Token for sending replies. | |
WHATSAPP_BUSINESS_ID | WhatsApp Business Account ID from Meta Business Suite. | |
WHATSAPP_PHONE_NUMBER_ID | Phone Number ID for sending WA messages. | |
WHATSAPP_ACCESS_TOKEN | Permanent token from System User in Meta Business. | |
TIKTOK_CLIENT_KEY | TikTok Developer Client Key. | |
TIKTOK_CLIENT_SECRET | TikTok Client Secret. | |
OPENAI_API_KEY | OpenAI key powering GPT-4o fallback replies. | |
ANTHROPIC_API_KEY | Anthropic key for Claude 3.5 Sonnet (optional alternative to OpenAI). | |
AI_TEMPERATURE | Creativity for AI fallback replies (0 = strict, 1 = creative). |
Full .env template
VERCEL_URL=your-app.vercel.app
SUPABASE_URL=https://xxxx.supabase.co
SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOi...service_role
SUPABASE_PUBLISHABLE_KEY=eyJhbGciOi...anon
GOOGLE_SHEET_ID=1A2B3C4D5E6F_your_sheet_id
GOOGLE_SERVICE_ACCOUNT_JSON={"type":"service_account",...}
META_APP_ID=1234567890
META_APP_SECRET=abcd1234efgh5678
META_WEBHOOK_VERIFY_TOKEN=a-long-random-string
META_PAGE_ACCESS_TOKEN=EAAG...
WHATSAPP_BUSINESS_ID=1029384756
WHATSAPP_PHONE_NUMBER_ID=5647382910
WHATSAPP_ACCESS_TOKEN=EAAG...
TIKTOK_CLIENT_KEY=awxyz1234567890
TIKTOK_CLIENT_SECRET=secret_xxxxxxx
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxx
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxx
AI_TEMPERATURE=0.4- Go to developers.facebook.com/apps and open your app.
- In the left sidebar choose Messenger (or Instagram) → Settings → Webhooks.
- Click Add Callback URL and paste:callback url
https://your-app.lovable.app/api/public/webhook/meta - For Verify Token, paste the value of
META_WEBHOOK_VERIFY_TOKEN. - Subscribe to fields:
messages,messaging_postbacks. - Click Verify and Save. You should see a green “Active” badge.
⚠ Important formatting rules
- Row 1 must be the header row:
Question/Answer. - Do not merge cells or add extra columns — only A and B are read.
- Share the sheet with your service account email as Viewer.
- Keep questions short and natural — the matcher is case-insensitive and fuzzy.
Header row template
Question Answerfeed webhook on your Page so OmniFlow auto-replies to comments on every post and ad.- Open your app at developers.facebook.com/apps and add the Webhooks product.
- Click Add Subscription and choose the
Pageobject. - Paste your Callback URL and Verify Token:callback url
https://your-app.lovable.app/api/public/webhook/metaverify tokenMETA_WEBHOOK_VERIFY_TOKEN - Subscribe to the
feedfield — this deliverscomments,reactions, and post mentions. - In your Page settings, install the app and grant
pages_manage_engagementandpages_read_user_content. - Test by commenting on any post — the comment appears in Automation Logs within 2 seconds.
Sample feed payload
{
"object": "page",
"entry": [{
"id": "PAGE_ID",
"changes": [{
"field": "feed",
"value": {
"item": "comment",
"verb": "add",
"post_id": "PAGE_ID_POST_ID",
"comment_id": "COMMENT_ID",
"from": { "id": "USER_ID", "name": "Aisha M." },
"message": "Do you have this in navy blue?"
}
}]
}]
}usersWorkspace owners and team members. Auth handled by Lovable Cloud.| Column | Type | Notes |
|---|---|---|
id | uuid | Primary key · references auth.users |
email | text | Unique login email |
full_name | text | Display name |
plan | text | free · pro · agency |
created_at | timestamptz | Account created |
automation_logsAppend-only log of every incoming message and automated reply.| Column | Type | Notes |
|---|---|---|
id | uuid | Primary key |
user_id | uuid | FK → users.id (RLS scoped) |
platform | text | messenger · instagram · whatsapp · tiktok · fb_comments |
type | text | direct_message · comment |
incoming_text | text | Raw message from the customer |
response_text | text | Automated reply sent |
source | text | google_sheet · openai_gpt4o · claude_sonnet |
confidence | numeric(4,3) | 0.000–1.000 match score |
created_at | timestamptz | Event timestamp |
channel_credentialsPer-user API keys & tokens. Values stored encrypted (pgsodium).| Column | Type | Notes |
|---|---|---|
id | uuid | Primary key |
user_id | uuid | FK → users.id |
provider | text | meta · whatsapp · tiktok · google · openai · anthropic |
secret_name | text | Logical name (e.g. PAGE_ACCESS_TOKEN) |
secret_value | bytea | Encrypted — never selected client-side |
enabled | boolean | Toggle channel on/off without deleting |
updated_at | timestamptz | Last rotation |
Row-Level Security
Every table enables RLS with policies scoped to auth.uid() = user_id. Service-role writes are restricted to verified webhook handlers under /api/public/*.