diff --git a/apps/builder/src/features/workspace/api/procedures/createWorkspaceProcedure.ts b/apps/builder/src/features/workspace/api/procedures/createWorkspaceProcedure.ts
index 5782f4b10..6174ac877 100644
--- a/apps/builder/src/features/workspace/api/procedures/createWorkspaceProcedure.ts
+++ b/apps/builder/src/features/workspace/api/procedures/createWorkspaceProcedure.ts
@@ -1,9 +1,9 @@
import prisma from '@/lib/prisma'
import { authenticatedProcedure } from '@/utils/server/trpc'
import { TRPCError } from '@trpc/server'
-import { Plan } from 'db'
import { Workspace, workspaceSchema } from 'models'
import { z } from 'zod'
+import { parseWorkspaceDefaultPlan } from '../../utils'
export const createWorkspaceProcedure = authenticatedProcedure
.meta({
@@ -39,8 +39,7 @@ export const createWorkspaceProcedure = authenticatedProcedure
message: 'Workspace with same name already exists',
})
- const plan =
- process.env.ADMIN_EMAIL === user.email ? Plan.LIFETIME : Plan.FREE
+ const plan = parseWorkspaceDefaultPlan(user.email ?? '')
const newWorkspace = (await prisma.workspace.create({
data: {
diff --git a/apps/builder/src/features/workspace/index.ts b/apps/builder/src/features/workspace/index.ts
index 37982cc0f..45e7c4a3e 100644
--- a/apps/builder/src/features/workspace/index.ts
+++ b/apps/builder/src/features/workspace/index.ts
@@ -1,2 +1,3 @@
export { WorkspaceProvider, useWorkspace } from './WorkspaceProvider'
export * from './components'
+export { parseWorkspaceDefaultPlan } from './utils'
diff --git a/apps/builder/src/features/workspace/utils/index.ts b/apps/builder/src/features/workspace/utils/index.ts
index 36709961f..cf6554307 100644
--- a/apps/builder/src/features/workspace/utils/index.ts
+++ b/apps/builder/src/features/workspace/utils/index.ts
@@ -1,2 +1,3 @@
export * from './parseNewName'
+export * from './parseWorkspaceDefaultPlan'
export * from './setWorkspaceIdInLocalStorage'
diff --git a/apps/builder/src/features/workspace/utils/parseWorkspaceDefaultPlan.ts b/apps/builder/src/features/workspace/utils/parseWorkspaceDefaultPlan.ts
new file mode 100644
index 000000000..16764ad33
--- /dev/null
+++ b/apps/builder/src/features/workspace/utils/parseWorkspaceDefaultPlan.ts
@@ -0,0 +1,9 @@
+import { Plan } from 'db'
+
+export const parseWorkspaceDefaultPlan = (userEmail: string) => {
+ if (process.env.ADMIN_EMAIL === userEmail) return Plan.LIFETIME
+ const defaultPlan = process.env.DEFAULT_WORKSPACE_PLAN as Plan | undefined
+ if (defaultPlan && Object.values(Plan).includes(defaultPlan))
+ return defaultPlan
+ return Plan.FREE
+}
diff --git a/apps/builder/src/pages/api/auth/adapter.ts b/apps/builder/src/pages/api/auth/adapter.ts
index 6221f68d5..6a1c4fd0a 100644
--- a/apps/builder/src/pages/api/auth/adapter.ts
+++ b/apps/builder/src/pages/api/auth/adapter.ts
@@ -3,7 +3,6 @@ import {
PrismaClient,
Prisma,
Invitation,
- Plan,
WorkspaceRole,
WorkspaceInvitation,
Session,
@@ -12,6 +11,7 @@ import type { Adapter, AdapterUser } from 'next-auth/adapters'
import cuid from 'cuid'
import { got } from 'got'
import { generateId } from 'utils'
+import { parseWorkspaceDefaultPlan } from '@/features/workspace'
type InvitationWithWorkspaceId = Invitation & {
typebot: {
@@ -53,11 +53,7 @@ export function CustomAdapter(p: PrismaClient): Adapter {
name: data.name
? `${data.name}'s workspace`
: `My workspace`,
- ...(process.env.ADMIN_EMAIL === data.email
- ? { plan: Plan.LIFETIME }
- : {
- plan: Plan.FREE,
- }),
+ plan: parseWorkspaceDefaultPlan(data.email),
},
},
},
diff --git a/apps/docs/docs/get-started/welcome.md b/apps/docs/docs/get-started/welcome.md
index 40c334d75..cb0f9bac2 100644
--- a/apps/docs/docs/get-started/welcome.md
+++ b/apps/docs/docs/get-started/welcome.md
@@ -5,7 +5,7 @@ slug: /
# Welcome
-[Typebot](https://www.typebot.io) Typebot is an open-source alternative to Landbot. It allows you to create conversational apps/forms (Lead qualification, Product launch, User onboarding, Customer support), embed them anywhere on your web/mobile apps, and collect results in real-time.
+[Typebot](https://www.typebot.io) is an open-source alternative to Landbot. It allows you to create conversational apps/forms (Lead qualification, Product launch, User onboarding, Customer support), embed them anywhere on your web/mobile apps, and collect results in real-time.
This is the Typebot documentation. It's a great place to find most answers. Please use the search box in the top right or the navigation menu (soon available) on the left-hand side to find the answers you're looking for.
diff --git a/apps/docs/docs/self-hosting/configuration/builder.mdx b/apps/docs/docs/self-hosting/configuration/builder.mdx
index 1305f9258..7890760a7 100644
--- a/apps/docs/docs/self-hosting/configuration/builder.mdx
+++ b/apps/docs/docs/self-hosting/configuration/builder.mdx
@@ -8,15 +8,16 @@ import { SponsorButton } from '../../../src/js/SponsorButton.jsx'
## General
-| Parameter | Default | Description |
-| ---------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| DATABASE_URL | postgresql://postgres:typebot@db:5432/typebot | The database URL |
-| ENCRYPTION_SECRET | SgVkYp2s5v8y/B?E(H+MbQeThWmZq4t6 | A 256-bit key used to encrypt sensitive data. It is strongly recommended to [generate](https://www.allkeysgenerator.com/Random/Security-Encryption-Key-Generator.aspx) a new one. The secret should be the same between builder and viewer. |
-| ADMIN_EMAIL | -- | The email that will get a "Pro" plan on user creation |
-| NEXTAUTH_URL | http://localhost:3000 | The builder base URL. Should be the publicly accessible URL (i.e. `https://typebot.domain.com`) |
-| NEXT_PUBLIC_VIEWER_URL | http://localhost:3001 | The viewer base URL. Should be the publicly accessible URL (i.e. `https://bot.domain.com`) |
-| NEXTAUTH_URL_INTERNAL | -- | The internal builder base URL. You have to set it only when `NEXTAUTH_URL` isn't publicly accessible |
-| DISABLE_SIGNUP | false | To disable new sign ups but still be able to sign in with existing users or admin email |
+| Parameter | Default | Description |
+| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| DATABASE_URL | | The database URL |
+| ENCRYPTION_SECRET | | A 256-bit key used to encrypt sensitive data. It is strongly recommended to [generate](https://www.allkeysgenerator.com/Random/Security-Encryption-Key-Generator.aspx) a new one. The secret should be the same between builder and viewer. |
+| ADMIN_EMAIL | | The email that will get a "Pro" plan on user creation |
+| NEXTAUTH_URL | | The builder base URL. Should be the publicly accessible URL (i.e. `https://typebot.domain.com`) |
+| NEXT_PUBLIC_VIEWER_URL | | The viewer base URL. Should be the publicly accessible URL (i.e. `https://bot.domain.com`) |
+| NEXTAUTH_URL_INTERNAL | | The internal builder base URL. You have to set it only when `NEXTAUTH_URL` isn't publicly accessible |
+| DEFAULT_WORKSPACE_PLAN | FREE | Default workspace plan on user creation or when a user creates a new workspace. Possible values are `FREE`, `STARTER`, `PRO`, `LIFETIME`. The default plan for admin user is `LIFETIME` |
+| DISABLE_SIGNUP | false | To disable new sign ups but still be able to sign in with existing users or admin email |
## Email (Auth, notifications)
@@ -24,11 +25,11 @@ Used for sending email notifications and authentication
| Parameter | Default | Description |
| --------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| SMTP_USERNAME | -- | SMTP username |
-| SMTP_PASSWORD | -- | SMTP password |
-| SMTP_HOST | -- | SMTP host. (i.e. `smtp.host.com`) |
+| SMTP_USERNAME | | SMTP username |
+| SMTP_PASSWORD | | SMTP password |
+| SMTP_HOST | | SMTP host. (i.e. `smtp.host.com`) |
| SMTP_PORT | 25 | SMTP port |
-| NEXT_PUBLIC_SMTP_FROM | - | From name and email (i.e. `'Typebot Notifications'