Deployment & Guide

Everything you need to deploy your OmniFlow script and wire it to every platform.

Your Webhook URL
auto-generated
Use this URL anywhere a third party asks for a callback / webhook endpoint.
url
https://your-app.lovable.app/api/public/webhook/meta
লাইভ Meta Webhook সেটআপ (বাংলা)
Meta Developer Portal-এ "The callback URL or verify token couldn't be validated" এরর কেন আসে এবং কীভাবে ঠিক করবেন।

সমস্যা: 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।

লাইভ প্রোডাকশনে চালু করার ধাপ:
  1. Lovable Cloud → Secrets-এ এই গুলো যোগ করুন: META_WEBHOOK_VERIFY_TOKEN, META_PAGE_ACCESS_TOKEN, GOOGLE_SHEET_ID, GOOGLE_SHEET_TAB, GOOGLE_SERVICE_ACCOUNT_JSON
  2. অ্যাপটি Publish করুন (উপরের ডানদিকের Publish বাটন)। Publish না হলে external URL কাজ করবে না।
  3. Meta Developer Portal → Webhooks-এ Callback URL হিসেবে দিন: https://<your-app>.lovable.app/api/public/webhook/meta
  4. Verify Token ফিল্ডে dashboard-এ সেভ করা সেই একই token পেস্ট করুন (যেটি আপনি META_WEBHOOK_VERIFY_TOKEN secret-এও রেখেছেন)।
  5. "Verify and Save" চাপুন — এবার validation সফল হবে। এরপর Page subscription যোগ করে live message reply শুরু হবে।

বিকল্প: চাইলে এই handler-এর কোড Supabase Edge Function, Vercel, বা Railway-তেও deploy করতে পারেন — তবে Lovable Cloud-এ already built-in সাপোর্ট আছে, আলাদা hosting দরকার নেই।

1. Environment Variables
Add these to your hosting provider (Vercel → Project Settings → Environment Variables, or your .env file locally).
VariableDescriptionCopy
VERCEL_URLPublic URL of your deployed app (used to build webhook callbacks).
SUPABASE_URLLovable Cloud / Supabase project URL.
SUPABASE_SERVICE_ROLE_KEYServer-side key. Never expose to the browser.
SUPABASE_PUBLISHABLE_KEYPublic anon key safe to ship to the client.
GOOGLE_SHEET_IDID from your Google Sheet URL between /d/ and /edit.
GOOGLE_SERVICE_ACCOUNT_JSONFull service account JSON, stringified.
META_APP_IDMeta Developer App ID for Messenger & Instagram.
META_APP_SECRETMeta App Secret. Required to verify webhook signatures.
META_WEBHOOK_VERIFY_TOKENToken Meta echoes back when subscribing to webhooks.
META_PAGE_ACCESS_TOKENLong-lived Page Access Token for sending replies.
WHATSAPP_BUSINESS_IDWhatsApp Business Account ID from Meta Business Suite.
WHATSAPP_PHONE_NUMBER_IDPhone Number ID for sending WA messages.
WHATSAPP_ACCESS_TOKENPermanent token from System User in Meta Business.
TIKTOK_CLIENT_KEYTikTok Developer Client Key.
TIKTOK_CLIENT_SECRETTikTok Client Secret.
OPENAI_API_KEYOpenAI key powering GPT-4o fallback replies.
ANTHROPIC_API_KEYAnthropic key for Claude 3.5 Sonnet (optional alternative to OpenAI).
AI_TEMPERATURECreativity for AI fallback replies (0 = strict, 1 = creative).

Full .env template

copy all
.env
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
2. Webhook Setup Guide
Copy your Webhook URL above, then follow the steps for each platform you want to enable.

  1. Go to developers.facebook.com/apps and open your app.
  2. In the left sidebar choose Messenger (or Instagram) → Settings → Webhooks.
  3. Click Add Callback URL and paste:
    callback url
    https://your-app.lovable.app/api/public/webhook/meta
  4. For Verify Token, paste the value of META_WEBHOOK_VERIFY_TOKEN.
  5. Subscribe to fields: messages, messaging_postbacks.
  6. Click Verify and Save. You should see a green “Active” badge.

3. Google Sheet Formatting
Your sheet must have exactly two columns. The bot matches incoming messages against Column A and replies with Column B.
A — Question
B — Answer
2
What are your hours?
We're open Mon–Fri, 9am–6pm EST.
3
Do you ship internationally?
Yes, we ship worldwide in 5–10 business days.
4
How much is the Pro plan?
Pro is $49/mo or $490/yr (2 months free).
5
How do I request a refund?
Reply with your order number and we'll process it within 24h.

⚠ 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

tsv
Question	Answer
4. Facebook Comment Webhook Setup
new
Subscribe to the feed webhook on your Page so OmniFlow auto-replies to comments on every post and ad.
  1. Open your app at developers.facebook.com/apps and add the Webhooks product.
  2. Click Add Subscription and choose the Page object.
  3. Paste your Callback URL and Verify Token:
    callback url
    https://your-app.lovable.app/api/public/webhook/meta
    verify token
    META_WEBHOOK_VERIFY_TOKEN
  4. Subscribe to the feed field — this delivers comments, reactions, and post mentions.
  5. In your Page settings, install the app and grant pages_manage_engagement and pages_read_user_content.
  6. Test by commenting on any post — the comment appears in Automation Logs within 2 seconds.

Sample feed payload

json
{
  "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?"
      }
    }]
  }]
}
5. Database Schema
OmniFlow ships with three core tables. Credentials are encrypted at rest and never returned to the client.
usersWorkspace owners and team members. Auth handled by Lovable Cloud.
ColumnTypeNotes
iduuidPrimary key · references auth.users
emailtextUnique login email
full_nametextDisplay name
plantextfree · pro · agency
created_attimestamptzAccount created
automation_logsAppend-only log of every incoming message and automated reply.
ColumnTypeNotes
iduuidPrimary key
user_iduuidFK → users.id (RLS scoped)
platformtextmessenger · instagram · whatsapp · tiktok · fb_comments
typetextdirect_message · comment
incoming_texttextRaw message from the customer
response_texttextAutomated reply sent
sourcetextgoogle_sheet · openai_gpt4o · claude_sonnet
confidencenumeric(4,3)0.000–1.000 match score
created_attimestamptzEvent timestamp
channel_credentialsPer-user API keys & tokens. Values stored encrypted (pgsodium).
ColumnTypeNotes
iduuidPrimary key
user_iduuidFK → users.id
providertextmeta · whatsapp · tiktok · google · openai · anthropic
secret_nametextLogical name (e.g. PAGE_ACCESS_TOKEN)
secret_valuebyteaEncrypted — never selected client-side
enabledbooleanToggle channel on/off without deleting
updated_attimestamptzLast 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/*.

You're all set 🎉
Once your env vars, webhooks, and Google Sheet are in place, head back to Integrations and click Save & Activate Automation.