Getting started

Extending

Rest APIs
GraphQL APIs

Contributing

Frontend Development
Backend Development

User Guide

Setup

Setup
In this article

Setup Messaging & Calendar sync

Twenty offers integrations with Gmail and Google Calendar.

For Gmail and Google Calendar

Create a project in Google Cloud

You will need to create a project in Google Cloud and get the credentials.

Then you can set the following environment variables:

  • MESSAGING_PROVIDER_GMAIL_ENABLED=true
  • CALENDAR_PROVIDER_GOOGLE_ENABLED=true
  • AUTH_GOOGLE_CLIENT_ID=<client-id>
  • AUTH_GOOGLE_CLIENT_SECRET=<client-secret>
  • AUTH_GOOGLE_CALLBACK_URL=https://<your-domain>/auth/google/redirect if you want to use Google SSO
  • AUTH_GOOGLE_APIS_CALLBACK_URL=https://<your-domain>/auth/google-apis/get-access-token

Enable APIs

On Google Cloud Console, go to APIs & Services and enable the following APIs:

Authorized redirect URIs

Under Credentials, in OAuth 2.0 Client IDs, you need to add the following redirect URIs to your project:

  • https://<your-domain>/auth/google/redirect if you want to use Google SSO
  • https://<your-domain>/auth/google-apis/get-access-token

If your app is in test mode

If your app is in test mode, you will need to add test users to your project.

Under OAuth consent screen, add your test users to the "Test users" section.

Start the cron jobs

Register the following recurring jobs:

# from your worker container
yarn command:prod cron:messaging:messages-import
yarn command:prod cron:messaging:message-list-fetch
yarn command:prod cron:calendar:calendar-event-list-fetch
yarn command:prod cron:messaging:ongoing-stale
yarn command:prod cron:calendar:ongoing-stale

Setup Environment Variables

Frontend

VariableExampleDescription
REACT_APP_SERVER_BASE_URLhttp://localhost:3000Url of backend server
GENERATE_SOURCEMAPfalseGenerate source maps for debugging
CHROMATIC_PROJECT_TOKENChromatic token used for CI

Backend

Config

VariableExampleDescription
PG_DATABASE_URLpostgres://user:pw@localhost:5432/default?connection_limit=1Database connection
PG_SSL_ALLOW_SELF_SIGNEDfalseAllow self signed certificates
REDIS_URLredis://localhost:6379Redis connection url
FRONT_DOMAINlocalhostDomain of the hosted frontend
DEFAULT_SUBDOMAINappThe default subdomain name when multiworkspace mode is enabled
SERVER_URLhttp://localhost:3000Url to the hosted server
FRONT_PROTOCOLhttpprotocol of the frontend server. Could be `http` or `https`
FRONT_PORT3001Port of the frontend server.
PORT3000Port of the backend server
CACHE_STORAGE_TYPEredisCache type (memory, redis...)
CACHE_STORAGE_TTL3600 * 24 * 7Cache TTL in seconds

Security

VariableExampleDescription
API_RATE_LIMITING_TTL100API rate limiting time window
API_RATE_LIMITING_LIMIT200API rate limiting max requests

Tokens

VariableExampleDescription
APP_SECRET<random>Secret used for encryption across the app
ACCESS_TOKEN_EXPIRES_IN30mAccess token expiration time
LOGIN_TOKEN_EXPIRES_IN15mLogin token expiration time
REFRESH_TOKEN_EXPIRES_IN90dRefresh token expiration time
REFRESH_TOKEN_COOL_DOWN1mRefresh token cooldown
FILE_TOKEN_EXPIRES_IN1dFile token expiration time

Auth

VariableExampleDescription
MESSAGING_PROVIDER_GMAIL_ENABLEDfalseEnable Gmail API connection
CALENDAR_PROVIDER_GOOGLE_ENABLEDfalseEnable Google Calendar API connection
AUTH_GOOGLE_APIS_CALLBACK_URLhttps://[YourDomain]/auth/google-apis/get-access-tokenGoogle APIs auth callback
AUTH_PASSWORD_ENABLEDfalseEnable Email/Password login
AUTH_GOOGLE_ENABLEDfalseEnable Google SSO login
AUTH_GOOGLE_CLIENT_ID123456789012-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.comGoogle client ID
AUTH_GOOGLE_CLIENT_SECRETGoogle client secret
AUTH_GOOGLE_CALLBACK_URLhttps://[YourDomain]/auth/google/redirectGoogle auth callback
AUTH_MICROSOFT_ENABLEDfalseEnable Microsoft SSO login
AUTH_SSO_ENABLEDfalseEnable SSO with SAML or OIDC
AUTH_MICROSOFT_CLIENT_IDMicrosoft client ID
AUTH_MICROSOFT_TENANT_IDMicrosoft tenant ID
AUTH_MICROSOFT_CLIENT_SECRETMicrosoft client secret
AUTH_MICROSOFT_CALLBACK_URLhttp://[YourDomain]/auth/microsoft/redirectMicrosoft auth callback
AUTH_MICROSOFT_APIS_CALLBACK_URLhttp://[YourDomain]/auth/microsoft-apis/get-access-tokenMicrosoft APIs auth callback
IS_MULTIWORKSPACE_ENABLEDfalseAllows the use of multiple workspaces. Requires a web server that can manage wildcards for subdomains.
PASSWORD_RESET_TOKEN_EXPIRES_IN5mPassword reset token expiration time

Email

VariableExampleDescription
EMAIL_FROM_ADDRESS[email protected]Global email From: header used to send emails
EMAIL_FROM_NAMEJohn from YourDomainGlobal name From: header used to send emails
EMAIL_SYSTEM_ADDRESS[email protected]Email address used as a destination to send internal system notification
EMAIL_DRIVERloggerEmail driver: 'logger' (to log emails in console) or 'smtp'
EMAIL_SMTP_HOSTEmail SMTP Host
EMAIL_SMTP_PORTEmail SMTP Port
EMAIL_SMTP_USEREmail SMTP User
EMAIL_SMTP_PASSWORDEmail SMTP Password

Email SMTP Server configuration examples

Gmail
Office365
Smtp4dev

You will need to provision an App Password.

  • EMAIL_DRIVER=smtp
  • EMAIL_SMTP_HOST=smtp.gmail.com
  • EMAIL_SMTP_PORT=465
  • EMAIL_SMTP_USER=gmail_email_address
  • EMAIL_SMTP_PASSWORD='gmail_app_password'

Storage

VariableExampleDescription
STORAGE_TYPElocalStorage driver: 'local' or 's3'
STORAGE_S3_REGIONStorage Region
STORAGE_S3_NAMEBucket Name
STORAGE_S3_ENDPOINTUse if a different Endpoint is needed (for example Google)
STORAGE_S3_ACCESS_KEY_IDOptional depending on the authentication method
STORAGE_S3_SECRET_ACCESS_KEYOptional depending on the authentication method
STORAGE_LOCAL_PATH.local-storageData path (local storage)

Custom Code Execution

VariableExampleDescription
SERVERLESS_TYPElocalServerless driver type: 'local' or 'lambda'
SERVERLESS_LAMBDA_REGIONLambda Region
SERVERLESS_LAMBDA_ROLELambda Role
SERVERLESS_LAMBDA_ACCESS_KEY_IDOptional depending on the authentication method
SERVERLESS_LAMBDA_SECRET_ACCESS_KEYOptional depending on the authentication method

Message Queue

VariableExampleDescription
MESSAGE_QUEUE_TYPEbull-mqQueue driver: 'bull-mq'

Logging

VariableExampleDescription
LOGGER_DRIVERconsoleCurrently, only supports 'console'
LOGGER_IS_BUFFER_ENABLEDtrueBuffer the logs before sending them to the logging driver
LOG_LEVELSerror,warnThe loglevels which are logged to the logging driver. Can include: 'log', 'warn', 'error'
EXCEPTION_HANDLER_DRIVERsentryThe exception handler driver can be: 'console' or 'sentry'
SENTRY_ENVIRONMENTmainThe sentry environment used if sentry logging driver is selected
SENTRY_RELEASElatestThe sentry release used if sentry logging driver is selected
SENTRY_DSNhttps://[email protected]/xxxThe sentry logging endpoint used if sentry logging driver is selected
SENTRY_FRONT_DSNhttps://[email protected]/xxxThe sentry logging endpoint used by the frontend if sentry logging driver is selected

Data enrichment and AI

VariableExampleDescription
OPENAI_API_KEYsk-proj-abcdabcd...OpenAI API key
LLM_CHAT_MODEL_DRIVERopenaiLLM provider
LLM_TRACING_DRIVERlangfuseWhere to output LangChain logs. 'langfuse' or 'console'.
LANGFUSE_SECRET_KEYsk-lf-abcdabcd-abcd...Langfuse secret key
LANGFUSE_PUBLIC_KEYpk-lf-abcdabcd-abcd...Langfuse public key

Serverless functions

This feature is WIP and is not yet useful for most users.

VariableExampleDescription
SERVERLESS_TYPElocalFunctions can either be executed through Lambda or directly by the main node process
SERVERLESS_LAMBDA_REGIONus-east-1If you use the Lambda driver, region of the Lambda function
SERVERLESS_LAMBDA_ROLEarn:aws:iam::121334:role/lambda-execution-roleIf you use the Lambda drive, name of the IAM role with the right permissions

Support Chat

VariableExampleDescription
SUPPORT_DRIVERfrontSupport driver ('front' or 'none')
SUPPORT_FRONT_HMAC_KEY<secret>Support chat key
SUPPORT_FRONT_CHAT_ID<id>Support chat id

Telemetry

VariableExampleDescription
TELEMETRY_ENABLEDtrueChange this if you want to disable telemetry
TELEMETRY_ANONYMIZATION_ENABLEDtrueTelemetry is anonymized by default, you probably don't want to change this

Debug / Development

VariableExampleDescription
DEBUG_MODEtrueActivate debug mode
SIGN_IN_PREFILLEDtruePrefill the Sign in form for usage in a demo or dev environment

Workspace Cleaning

VariableExampleDescription
WORKSPACE_INACTIVE_DAYS_BEFORE_NOTIFICATIONNumber of inactive days before sending workspace deleting warning email
WORKSPACE_INACTIVE_DAYS_BEFORE_DELETIONNumber of inactive days before deleting workspace

Captcha

VariableExampleDescription
CAPTCHA_DRIVERThe captcha driver can be 'google-recaptcha' or 'turnstile'
CAPTCHA_SITE_KEYThe captcha site key
CAPTCHA_SECRET_KEYThe captcha secret key

Noticed something to change?

As an open-source company, we welcome contributions through Github. Help us keep it up-to-date, accurate, and easy to understand by getting involved and sharing your ideas!

twenty github image
The #1 Open Source CRM
©2024 Twenty PBC