--- title: Setup icon: TbServer image: /images/user-guide/table-views/table.png --- import OptionTable from '@site/src/theme/OptionTable' # 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` - `MESSAGING_PROVIDER_MICROSOFT_ENABLED=false` - `CALENDAR_PROVIDER_MICROSOFT_ENABLED=false` - `AUTH_GOOGLE_CLIENT_ID=` - `AUTH_GOOGLE_CLIENT_SECRET=` - `AUTH_GOOGLE_CALLBACK_URL=https:///auth/google/redirect` if you want to use Google SSO - `AUTH_GOOGLE_APIS_CALLBACK_URL=https:///auth/google-apis/get-access-token` ### Enable APIs On Google Cloud Console, go to [APIs & Services](https://console.cloud.google.com/apis/library/) and enable the following APIs: - [Gmail API](https://console.cloud.google.com/apis/library/gmail.googleapis.com) - [Google Calendar API](https://console.cloud.google.com/apis/library/calendar-json.googleapis.com) - [People API](https://console.cloud.google.com/apis/library/people.googleapis.com) ### Authorized redirect URIs Under [Credentials](https://console.cloud.google.com/apis/credentials), in OAuth 2.0 Client IDs, you need to add the following redirect URIs to your project: - `https:///auth/google/redirect` if you want to use Google SSO - `https:///auth/google-apis/get-access-token` ### Configure scopes [See relevant source code](https://github.com/twentyhq/twenty/blob/main/packages/twenty-server/src/engine/core-modules/auth/utils/get-google-apis-oauth-scopes.ts#L4-L10) - 'https://www.googleapis.com/auth/calendar.events' - 'https://www.googleapis.com/auth/gmail.readonly' - 'https://www.googleapis.com/auth/profile.emails.read' ### 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](https://console.cloud.google.com/apis/credentials/consent), 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:calendar:calendar-events-import yarn command:prod cron:messaging:ongoing-stale yarn command:prod cron:calendar:ongoing-stale ``` ## For Outlook and Outlook Calendar (Microsoft 365) Users must have a [Microsoft 365 Licence](https://admin.microsoft.com/Adminportal/Home) to be able to use the Calendar and Messaging API. They will not be able to sync their account on Twenty without one. ### Create a project in Microsoft Azure You will need to create a project in [Microsoft Azure](https://portal.azure.com/#view/Microsoft_AAD_IAM/AppGalleryBladeV2) and get the credentials. Then you can set the following environment variables: - `MESSAGING_PROVIDER_MICROSOFT_ENABLED=true` - `CALENDAR_PROVIDER_MICROSOFT_ENABLED=true` - `AUTH_MICROSOFT_ENABLED=true` - `AUTH_MICROSOFT_CLIENT_ID=` - `AUTH_MICROSOFT_CLIENT_SECRET=` - `AUTH_MICROSOFT_CALLBACK_URL=https:///auth/microsoft/redirect` if you want to use Microsoft SSO - `AUTH_MICROSOFT_APIS_CALLBACK_URL=https:///auth/microsoft-apis/get-access-token` ### Enable APIs On Microsoft Azure Console enable the following APIs in "Permissions": - Microsoft Graph: Mail.Read - Microsoft Graph: Calendars.Read - Microsoft Graph: User.Read.All - Microsoft Graph: openid - Microsoft Graph: email - Microsoft Graph: profile - Microsoft Graph: offline_access ### Authorized redirect URIs You need to add the following redirect URIs to your project: - `https:///auth/microsoft/redirect` if you want to use Microsoft SSO - `https:///auth/microsoft-apis/get-access-token` ### Configure scopes [See relevant source code](https://github.com/twentyhq/twenty/blob/main/packages/twenty-server/src/engine/core-modules/auth/utils/get-microsoft-apis-oauth-scopes.ts#L2-L9) - 'openid' - 'email' - 'profile' - 'offline_access' - 'Mail.Read' - 'Calendars.Read ### If your app is in test mode If your app is in test mode, you will need to add test users to your project. Add your test users to the "Users and groups" 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:calendar:calendar-events-import yarn command:prod cron:messaging:ongoing-stale yarn command:prod cron:calendar:ongoing-stale ``` # Setup Environment Variables ## Frontend ## Backend ### Config ### Security ### Tokens ', 'Secret used for encryption across the app'], ['ACCESS_TOKEN_EXPIRES_IN', '30m', 'Access token expiration time'], ['LOGIN_TOKEN_EXPIRES_IN', '15m', 'Login token expiration time'], ['REFRESH_TOKEN_EXPIRES_IN', '90d', 'Refresh token expiration time'], ['REFRESH_TOKEN_COOL_DOWN', '1m', 'Refresh token cooldown'], ['FILE_TOKEN_EXPIRES_IN', '1d', 'File token expiration time'], ]}> ### Auth ### Email #### Email SMTP Server configuration examples You will need to provision an [App Password](https://support.google.com/accounts/answer/185833). - 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' Keep in mind that if you have 2FA enabled, you will need to provision an [App Password](https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9). - EMAIL_DRIVER=smtp - EMAIL_SMTP_HOST=smtp.office365.com - EMAIL_SMTP_PORT=587 - EMAIL_SMTP_USER=office365_email_address - EMAIL_SMTP_PASSWORD='office365_password' **smtp4dev** is a fake SMTP email server for development and testing. - Run the smtp4dev image: `docker run --rm -it -p 8090:80 -p 2525:25 rnwood/smtp4dev` - Access the smtp4dev ui here: [http://localhost:8090](http://localhost:8090) - Set the following env variables: - EMAIL_DRIVER=smtp - EMAIL_SMTP_HOST=localhost - EMAIL_SMTP_PORT=2525 ### Storage ### Custom Code Execution ### Logging ### Data enrichment and AI ### Serverless functions This feature is WIP and is not yet useful for most users. ### Support Chat ', 'Support chat key'], ['SUPPORT_FRONT_CHAT_ID', '', 'Support chat id'], ]}> ### Telemetry ### Debug / Development ### Workspace Cleaning ### Captcha