# Setup required before going live

Everything below uses a placeholder value (starting with `CHANGE_ME_`) or a development default.
Replace each one in the server's `.env` file. **Never commit `.env` to Git or paste these values into chat.**

This list grows with each phase. Items marked *(Phase N)* are not used yet.

## Phase 1 — needed now

| Setting | Placeholder / default | What to put there | Where to get it |
| --- | --- | --- | --- |
| `APP_KEY` | empty | Generated key | Run `php artisan key:generate` on the server once |
| `APP_ENV` | `local` | `production` | — |
| `APP_DEBUG` | `true` | `false` | Must be `false` in production, or errors leak secrets |
| `APP_URL` | `http://localhost:8000` | `https://app.biznisos.com` | Your domain |
| `DB_DATABASE` | `biznisos` | Your database name | Created on your MySQL server |
| `DB_USERNAME` | `CHANGE_ME_db_user` | MySQL user | Created on your MySQL server (see DEPLOYMENT.md) |
| `DB_PASSWORD` | `CHANGE_ME_db_password` | Strong password | Same |
| `MAIL_MAILER` | `log` | `smtp` (or `ses`) | Emails are only written to the log until you change this |
| `MAIL_HOST` | `CHANGE_ME_smtp_host` | e.g. `email-smtp.ap-south-1.amazonaws.com` | Amazon SES → SMTP settings, or your mail provider |
| `MAIL_USERNAME` | `CHANGE_ME_smtp_user` | SMTP username | Same |
| `MAIL_PASSWORD` | `CHANGE_ME_smtp_password` | SMTP password | Same |
| `MAIL_FROM_ADDRESS` | `no-reply@biznisos.com` | A sender on your domain | Verify the domain with your mail provider (SPF, DKIM, DMARC DNS records) |
| `BIZNISOS_SUPPORT_EMAIL` | `support@biznisos.com` | Your support inbox | — |
| `BIZNISOS_ALLOW_REGISTRATION` | `true` | `true` for public signups, `false` for invite-only | Your choice |
| `SESSION_DOMAIN` | `null` | Keep `null` | Must stay host-only so code on published pages can never read dashboard logins |
| `BIZNISOS_PAGES_URL` | same as `APP_URL` | `https://pages.biznisos.com` | Published funnel pages are served from here, separate from the dashboard. Add a DNS A record for `pages` |
| `BIZNISOS_PAGES_CNAME` | `pages.biznisos.com` | Same | Customers point their own domains here with a CNAME record |
| `BIZNISOS_SERVER_IP` | empty | Your server's public IP | Shown to customers as the A-record option for root domains |

Also before launch:

- **Remove the demo users.** Do not run `php artisan db:seed` on the production server. If you did, delete the `@biznisos.test` users.
- **Agency plan limits.** New signups get the `starter` plan with 3 businesses (`max_accounts`). Change the defaults in `database/migrations/2026_12_04_000100_create_tenancy_tables.php` before the first migration, or update agencies in the database. SaaS billing arrives in Phase 7.

## Sales module notes

- Team members need their **mobile number in My profile** for click-to-call (the call rings them first).
- Paid event tickets are recorded as "payment pending" until online payments are switched on (Finance). Until then, mark them paid by hand.
- Webinar reminders are stored now and sent once WhatsApp/email automations are live.

## Lead Automation and Inbox (chunk 5) — needed to send and receive messages

Everything is entered in **Lead Automation → Integrations** (owners/admins only). Keys are stored encrypted in the database, not in `.env`. Until a channel is connected, replies and workflow messages are logged but not sent.

| Service | What you need | Where to paste it |
| --- | --- | --- |
| **Meta app** (developers.facebook.com) | One app of type *Business*, with the **WhatsApp**, **Webhooks** and **Facebook Login for Business** products. Copy its **App secret** (App settings → Basic). | The "Meta app secret" field on WhatsApp, Meta Lead Ads and Instagram cards. Webhook signatures are checked with it; without it, webhooks are refused in production. |
| **WhatsApp Business (Cloud API)** | Verified Meta Business, a phone number added to the WhatsApp Business Account (WABA), the **Phone number ID**, the **WABA ID**, and a **permanent System User token** with `whatsapp_business_messaging` + `whatsapp_business_management`. | WhatsApp card. Then copy the card's **Webhook URL** and **Verify token** into Meta app → WhatsApp → Configuration and subscribe to `messages`. Click **Sync templates** to load approved templates. |
| **Meta Lead Ads** | Facebook **Page ID** and a **Page access token** with `leads_retrieval`, `pages_manage_metadata`, `pages_show_list`. Subscribe the page to the app (`/{page-id}/subscribed_apps` with `leadgen`). | Meta Lead Ads card; paste its Webhook URL + Verify token into Meta app → Webhooks → **Page**, field `leadgen`. **Fetch last 90 days** backfills older leads. |
| **Instagram DMs / comments** | Instagram professional account linked to the Page, its **Instagram business account ID**, Page token with `instagram_manage_messages`, `instagram_manage_comments`. | Instagram card; Webhooks → **Instagram**, fields `messages` and `comments`. |
| **IndiaMART** | Lead Manager → **CRM key** (Push/Pull API). | IndiaMART card. Either paste the Webhook URL into IndiaMART's Push API, or turn on "Pull every 10 minutes" (needs the scheduler running). |
| **Inbound email** | Mailgun / SES / Postmark inbound routing that POSTs `from`, `subject`, `text`. | Email card's Webhook URL. Outgoing email uses the `MAIL_*` settings in `.env`. |

Notes:
- WhatsApp only allows free-text replies within **24 hours** of the customer's last message; after that BiznisOS asks for an approved template.
- Broadcasts go only to contacts who have messaged you on WhatsApp (opted in) and are not on WhatsApp DND. Mark other opt-ins in your own process before importing.
- Workflow "Wait" steps and scheduled broadcasts need the **scheduler** (`* * * * * php artisan schedule:run`) and a **queue worker** (`php artisan queue:work`), see DEPLOYMENT.md.
- Automated tests use a fake WhatsApp client, so nothing is sent while testing.

## Calendar and Finance (chunk 6) — needed to take payments and add video links

All of these are entered in **Lead Automation → Integrations** (owners/admins only) and stored encrypted.

| Service | What you need | Where it goes |
| --- | --- | --- |
| **Razorpay** (recommended for India) | Dashboard → Account & Settings → API keys: **Key ID** and **Key secret** (start with test keys `rzp_test_…`). Dashboard → Webhooks: add the card's **Webhook URL**, choose a **webhook secret**, events `payment.captured` and `refund.processed`. | Razorpay card: Key ID, Key secret, Webhook secret. Switch to live keys after KYC is approved. |
| **Stripe** (international cards) | Developers → API keys: **Secret key** `sk_…`. Developers → Webhooks: add the card's Webhook URL with events `checkout.session.completed` and `charge.refunded`, then copy the **signing secret** `whsec_…`. | Stripe card. |
| **Google Calendar + Meet** | Google Cloud project with the Calendar API on, an OAuth client (web), and a **refresh token** for the calendar owner with scopes `https://www.googleapis.com/auth/calendar.events` and `https://www.googleapis.com/auth/calendar.freebusy` (e.g. from the OAuth Playground using your own client). Calendar ID, usually `primary`. | Google Calendar card. Two-way sync: every booking becomes an event (with Meet when the location is "Google Meet"), busy times block slots, and events moved or deleted in Google move or cancel the booking within 10 minutes. Team members can enter their own calendar ID under Profile; share that calendar's free/busy with the connected Google account. |
| **Zoom** | Zoom Marketplace → Server-to-Server OAuth app with scope `meeting:write:admin`: **Account ID**, **Client ID**, **Client secret**. | Zoom card. Bookings on calendars whose location is "Zoom" get a meeting link. |

Also set:
- **Business state and GSTIN** in Settings → Business profile, so invoices split GST correctly and show your GSTIN.
- The **scheduler** must run (`* * * * * php artisan schedule:run`) for booking reminders, subscription renewal links and Google Calendar sync.
- **Mail** settings in `.env` (`MAIL_*`) for booking confirmations, reminders and invoices.

Known limits:
- Subscription renewals are collected by **payment link**: before each renewal date the customer is emailed a link (and up to two reminders); paying it moves the subscription on and sends a GST invoice. Tune with `SUBSCRIPTION_NOTICE_DAYS`, `SUBSCRIPTION_REMINDER_DAYS`, `SUBSCRIPTION_MAX_REMINDERS` and `SUBSCRIPTION_CANCEL_AFTER_DAYS` (0 = never cancel automatically). Charging a saved card or UPI AutoPay mandate without the customer clicking needs Razorpay Subscriptions / Stripe Billing and is not connected yet.
- Prices on products and invoice lines are taken as **before GST**.
- Test mode: in automated tests, or if an integration's stored credentials include `driver = fake`, payments show a "Pay now (test)" button and no money moves.

## AI and wallet (chunk 8)

| Setting (`.env`) | What it is | Where to get it |
| --- | --- | --- |
| `OPENAI_API_KEY` | Platform OpenAI key used for the Fast and Smart models; businesses pay for it with credits. | platform.openai.com → API keys. Set a monthly spend limit there. |
| `ANTHROPIC_API_KEY` | Platform Anthropic key used for the Claude models. | console.anthropic.com → API keys. |
| `AI_OPENAI_FAST_MODEL`, `AI_OPENAI_SMART_MODEL`, `AI_ANTHROPIC_FAST_MODEL`, `AI_ANTHROPIC_MODEL` | Model ids. Change them when providers release new models; no code change needed. | Provider documentation. **Check these ids before going live.** |
| `PLATFORM_RAZORPAY_KEY_ID`, `PLATFORM_RAZORPAY_KEY_SECRET` | **Your own** Razorpay account (the BiznisOS owner), which receives money for credit top-ups. Not the businesses' accounts. | Razorpay Dashboard → API keys. |
| `PLATFORM_RAZORPAY_WEBHOOK_SECRET` | Lets a top-up be credited even if the buyer closes the browser. | Razorpay Dashboard → Webhooks: URL `https://app.biznisos.com/webhooks/platform/razorpay`, events `payment.captured` and `order.paid`. |
| `WALLET_WELCOME_CREDITS` | Free credits each new business gets. Default 50. | Your choice. |

- Credit prices and packs are in `config/biznisos.php` (`wallet.packs`, `ai.models.*.credits`). Pack prices include GST; issue GST invoices for top-ups from your own books.
- With the keys left as `CHANGE_ME`, AI answers are labelled demo answers and top-ups add credits without charging ("test mode"). **Set real keys before launch.**
- Voice typing uses the browser's own speech recognition (Chrome, Edge, Safari); nothing to configure.

## Google sign-in, SMS, media storage (gap fixes)

| Setting | What it is | Where to get it |
| --- | --- | --- |
| `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET` | Sign in with Google. Leave as `CHANGE_ME` to hide the button. | Google Cloud Console → APIs & Services → Credentials → OAuth client (Web). Authorised redirect URI: `https://app.biznisos.com/auth/google/callback`. Set the OAuth consent screen to "In production". |
| `SMS_DRIVER` + `MSG91_*` or `TWILIO_*` | Optional login codes by SMS (in addition to email). | MSG91: DLT-registered sender ID and an OTP flow template containing `##body##`. Twilio: account SID, auth token, a sending number. |
| MSG91 / Twilio SMS in **Integrations** | Each business's own SMS for the "Send SMS" workflow step. | In India every message must match a DLT-approved template, so register templates before you use them. |
| `MEDIA_DISK=s3` + `AWS_*` | Store media vault files on Amazon S3 or DigitalOcean Spaces instead of this server. | Create a bucket with public-read objects (or a CDN). For Spaces set `AWS_ENDPOINT` and `AWS_URL`. Needs the `league/flysystem-aws-s3-v3` package, which composer.json now includes. |
| `BIZNISOS_DOCS_URL` | Link for the "Docs" button on Get Started. | Your help site. |

Also:
- When `MEDIA_DISK=public`, run `php artisan storage:link` once so uploaded files have public URLs. WhatsApp downloads media from those URLs, so they must be reachable over HTTPS.
- Email campaigns use the `MAIL_*` mailer. For volume, use Amazon SES or Mailgun with a verified domain, SPF and DKIM.
- The app can be installed from the browser on Android, iPhone and desktop. Nothing to configure, but the site must be served over HTTPS.

## Browser push notifications and platform admin

| Setting | What it is | Where to get it |
| --- | --- | --- |
| `VAPID_PUBLIC_KEY`, `VAPID_PRIVATE_KEY` | Lets people turn on "Alerts on this device" under the bell, so notifications reach their phone or desktop even when BiznisOS is closed. Leave empty to hide the switch. | Run `php artisan biznisos:vapid` once and paste the two lines into `.env`. Keep the private key secret and never change it afterwards, or everyone has to turn alerts on again. |
| `VAPID_SUBJECT` | Contact address push services can use if something goes wrong. | `mailto:` plus your support email. |

Also:
- Push needs HTTPS. On iPhone it works only after the person adds BiznisOS to the home screen (iOS 16.4 or later).
- **Platform feedback** (Profile menu → Platform feedback) is visible only to users with `is_super_admin = 1`. Set that flag on your own user in the database: `UPDATE users SET is_super_admin = 1 WHERE email = 'you@example.com';`

## Coming in later phases

| Service | Used for | Phase | What you will need |
| --- | --- | --- | --- |
| Razorpay | Payments, subscriptions, UPI | **Now** (see above) | Business account, KYC, API key + secret, webhook secret |
| Stripe | International payments | **Now** (see above) | Account, API keys, webhook secret |
| Meta WhatsApp Cloud API | WhatsApp inbox, broadcasts | **Now** (see the section above) | Meta Business verification, phone number, permanent token, approved message templates. **Start verification early; it can take weeks.** |
| Amazon SES or Mailgun | Bulk email campaigns | **Now** (Inbox → Broadcasts → Email campaign) | Account out of sandbox mode, verified domain |
| Exotel / Twilio / Knowlarity / MyOperator | IVR calling, click-to-call, call recordings | **Now** (Sales → IVR Calling → Providers) | Account with KYC, a virtual number (caller ID), API keys. Paste the webhook URL shown in BiznisOS into the provider's call-status settings. For Twilio, also a TwiML URL that dials the customer. Knowlarity and MyOperator use account-specific click-to-call URLs; confirm the field names with their support |
| MSG91 or Twilio | SMS / OTP by SMS | **Now** (see above) | Account, DLT registration (India) |
| Google Cloud | Google login, Calendar sync | **Now** (see above) | OAuth client ID + secret |
| Zoom | Meeting links on bookings | **Now** (see above) | Server-to-server OAuth app |
| OpenAI or Anthropic | AI writing, auto-replies | **Now** (see the AI section above) | API key with billing enabled |
| S3 / DigitalOcean Spaces | Media storage + CDN | **Now**, optional (see above) | Bucket, access key, secret |
