-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ (whatsapp) Add custom session expiration #842
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes primarily focus on introducing session expiry for WhatsApp sessions and improving the UI components. The session expiry feature is implemented across several files, including error handling for expired sessions. UI improvements include making certain props optional and enhancing layout and functionality of components. Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 6
Files selected for processing (11)
- apps/builder/src/components/inputs/NumberInput.tsx (4 hunks)
- apps/builder/src/components/inputs/SwitchWithLabel.tsx (2 hunks)
- apps/builder/src/features/blocks/bubbles/embed/components/EmbedUploadContent.tsx (2 hunks)
- apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx (3 hunks)
- apps/viewer/src/features/chat/api/sendMessage.ts (2 hunks)
- packages/bot-engine/continueBotFlow.ts (2 hunks)
- packages/bot-engine/queries/getSession.ts (1 hunks)
- packages/bot-engine/whatsapp/resumeWhatsAppFlow.ts (2 hunks)
- packages/bot-engine/whatsapp/startWhatsAppSession.ts (2 hunks)
- packages/schemas/features/chat/sessionState.ts (1 hunks)
- packages/schemas/features/whatsapp.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- apps/builder/src/components/inputs/SwitchWithLabel.tsx
- apps/builder/src/features/blocks/bubbles/embed/components/EmbedUploadContent.tsx
Additional comments (Suppressed): 15
packages/bot-engine/queries/getSession.ts (1)
- 7-7: The
updatedAt
field is now being selected from the database query. Ensure that this field exists in thechatSession
table and that it is updated appropriately whenever a session is modified.packages/bot-engine/continueBotFlow.ts (1)
- 34-35: The import of
TRPCError
from@trpc/server
is new. Ensure that the package version being used supports this error type and that it's correctly handled in all places wherecontinueBotFlow
is called.packages/schemas/features/chat/sessionState.ts (2)
76-79: The
expiryTimeout
field has been added to the schema. This field is optional and represents the session expiration timeout in milliseconds. Ensure that all parts of the codebase that interact with this schema are updated to handle this new field correctly.71-75: The
credentialsId
field has been removed from the schema. Make sure that this change does not break any existing functionality wherecredentialsId
was being used.apps/viewer/src/features/chat/api/sendMessage.ts (1)
- 45-47: This part of the code remains unchanged and continues to function as expected, throwing an error when there's no session and no start parameters are provided.
apps/builder/src/components/inputs/NumberInput.tsx (3)
33-33: A new
suffix
prop has been added to theNumberInput
component. This prop is used to display a suffix text next to the input field. Ensure that this change does not affect the layout and appearance of existing uses of theNumberInput
component.105-105: The spacing between elements in the
FormControl
component now depends on thedirection
prop. This change could potentially alter the appearance of existing uses of theNumberInput
component. Please verify that this change is intended and does not negatively impact the UI.124-124: The
suffix
prop is rendered as aText
component next to the input field. If thesuffix
prop is not provided, it defaults tonull
. This is a good use of conditional rendering to handle optional props.packages/bot-engine/whatsapp/resumeWhatsAppFlow.ts (2)
68-71: The session expiration check is correctly implemented. However, it's important to note that the
expiryTimeout
is expected to be in milliseconds since it's being compared with JavaScript'sDate.now()
. IfexpiryTimeout
is stored in a different unit (like seconds or minutes), this comparison will not work as expected. Please verify thatexpiryTimeout
is indeed stored in milliseconds.74-84: The logic for deciding whether to continue the bot flow or start a new WhatsApp session has been updated to account for session expiration. This is a good approach to handle expired sessions. However, please ensure that the
startWhatsAppSession
function can handle starting a new session when an old one has expired without any issues.packages/schemas/features/whatsapp.ts (1)
- 190-198: The addition of
sessionExpiryTimeout
to thewhatsAppSettingsSchema
is a good move. It allows for customization of session expiration times. However, it's important to ensure that all parts of the codebase that use this schema are updated to handle this new field. Also, consider adding a default value in case this field is not provided.packages/bot-engine/whatsapp/startWhatsAppSession.ts (2)
11-15: The import statement has been updated to include
defaultSessionExpiryTimeout
from the@typebot.io/schemas/features/whatsapp
package. This change is in line with the PR summary, which mentions the introduction of custom session expiration functionality for WhatsApp.77-96: The function
startWhatsAppSession()
has been updated to include a newexpiryTimeout
property in thenewSessionState
. The value ofexpiryTimeout
is calculated based onsessionExpiryTimeoutHours
, which is either fetched frompublicTypebot.settings.whatsApp?.sessionExpiryTimeout
or defaults todefaultSessionExpiryTimeout
.This change aligns with the PR summary's mention of adding an
expiryTimeout
property to manage session expiration. However, it's important to ensure that thepublicTypebot.settings.whatsApp?.sessionExpiryTimeout
anddefaultSessionExpiryTimeout
values are always defined and valid to prevent potential issues with session management.Also, note that the
credentialsId
property has been removed fromnewSessionState.whatsApp
, as mentioned in the PR summary. Ensure that this does not affect other parts of the codebase that might be relying on this property.apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx (2)
126-147: The function
updateIsStartConditionEnabled
is updating thestartCondition
property of the WhatsApp settings. However, whenisEnabled
is true, it setsstartCondition
to an object with empty comparisons and a logical operator set to AND. This might not be the expected behavior if there were previously defined conditions. Please verify that this is the intended behavior.228-259: The
SwitchWithRelatedSettings
component is used to toggle the start bot condition and configure related settings. When the switch is toggled on, the user can add, edit, and remove comparison items. This is a good use of the component to group related settings together. However, please ensure that the state of the switch accurately reflects whether there are any start conditions defined.
}) => { | ||
const session = sessionId ? await getSession(sessionId) : null | ||
|
||
const isSessionExpired = | ||
session && | ||
isDefined(session.state.expiryTimeout) && | ||
session.updatedAt.getTime() + session.state.expiryTimeout < Date.now() | ||
|
||
if (isSessionExpired && !session) | ||
throw new TRPCError({ | ||
code: 'NOT_FOUND', | ||
message: 'Session expired. You need to start a new session.', | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition isSessionExpired && !session
will never be true because isSessionExpired
is only evaluated if a session exists. This means that the error message for an expired session will never be thrown. You should separate these conditions to handle them individually.
- if (isSessionExpired && !session)
+ if (isSessionExpired)
apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx
Outdated
Show resolved
Hide resolved
<NumberInput | ||
max={48} | ||
min={0} | ||
width="100px" | ||
label="Session expire timeout:" | ||
defaultValue={ | ||
whatsAppSettings?.sessionExpiryTimeout | ||
} | ||
placeholder={defaultSessionExpiryTimeout.toString()} | ||
moreInfoTooltip="The time in hours after which the session will expire if the user does not interact with the bot. The conversation restarts if the user sends a message after that expiration time." | ||
onValueChange={updateSessionExpiryTimeout} | ||
withVariableButton={false} | ||
suffix="hours" | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NumberInput
component is used to allow the user to specify the session expiry timeout. The max
prop is set to 48, which means the maximum session expiry time can be 48 hours. If this is the intended maximum limit, consider adding a note in the tooltip or label to inform the user about this limit.
f50c06f
to
730178c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 12
Files selected for processing (11)
- apps/builder/src/components/inputs/NumberInput.tsx (4 hunks)
- apps/builder/src/components/inputs/SwitchWithLabel.tsx (2 hunks)
- apps/builder/src/features/blocks/bubbles/embed/components/EmbedUploadContent.tsx (2 hunks)
- apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx (3 hunks)
- apps/viewer/src/features/chat/api/sendMessage.ts (2 hunks)
- packages/bot-engine/continueBotFlow.ts (2 hunks)
- packages/bot-engine/queries/getSession.ts (1 hunks)
- packages/bot-engine/whatsapp/resumeWhatsAppFlow.ts (2 hunks)
- packages/bot-engine/whatsapp/startWhatsAppSession.ts (2 hunks)
- packages/schemas/features/chat/sessionState.ts (1 hunks)
- packages/schemas/features/whatsapp.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- apps/builder/src/components/inputs/SwitchWithLabel.tsx
- apps/builder/src/features/blocks/bubbles/embed/components/EmbedUploadContent.tsx
Additional comments (Suppressed): 10
packages/bot-engine/queries/getSession.ts (1)
- 7-7: The
updatedAt
field is now being selected from the database query. Ensure that this field exists in thechatSession
table and is updated appropriately whenever a session is modified.packages/bot-engine/continueBotFlow.ts (1)
- 34-35: The import of
TRPCError
from@trpc/server
is new. Ensure that the package version being used supports this error type and that it's correctly handled in all places wherecontinueBotFlow
is called.packages/schemas/features/chat/sessionState.ts (1)
- 76-79: The new
expiryTimeout
field has been added to the schema. This field is optional and represents the session expiration delay in milliseconds. Ensure that all parts of the codebase that interact with this schema are updated to handle this new field appropriately.packages/bot-engine/whatsapp/resumeWhatsAppFlow.ts (1)
- 73-84: The logic for deciding whether to continue the bot flow or start a new session has been updated to account for session expiration. Ensure that this change doesn't introduce any unexpected behavior in other parts of the system that rely on the
resumeWhatsAppFlow
function.apps/builder/src/components/inputs/NumberInput.tsx (3)
33-33: The new
suffix
prop has been added to theNumberInput
component. This prop is used to display a suffix text next to the input field. Ensure that this change does not affect the layout or functionality of existing instances of theNumberInput
component.46-46: The
suffix
prop is destructured from the component props and passed down to the component rendering logic.124-124: The
suffix
prop is used here to conditionally render aText
component next to the input field. Ifsuffix
is defined, it is displayed as plain text; otherwise, nothing is rendered. This is a good use of conditional rendering based on prop values.packages/schemas/features/whatsapp.ts (1)
- 190-199: The addition of
sessionExpiryTimeout
to thewhatsAppSettingsSchema
is a good way to allow customization of session expiration. However, it's important to ensure that all parts of the codebase that use this schema are updated to handle this new field. Also, consider adding a default value within the schema itself using.default(defaultSessionExpiryTimeout)
for better encapsulation and maintainability.packages/bot-engine/whatsapp/startWhatsAppSession.ts (1)
- 11-17: The import statement has been updated to include
defaultSessionExpiryTimeout
from the@typebot.io/schemas/features/whatsapp
package. This change is in line with the PR's goal of introducing a custom session expiration feature for WhatsApp.apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx (1)
- 213-226: The
NumberInput
component is used to input the session expiry timeout. It's important to ensure that the input value is a whole number since it represents hours. If fractional hours are not supported, consider adding validation to enforce integer input.
expiryTimeout: z | ||
.number() | ||
.optional() | ||
.describe('Expiry timeout in milliseconds'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a minimum value constraint to the expiryTimeout
field to prevent negative or zero values, which could lead to unexpected behavior.
- expiryTimeout: z.number().optional().describe('Expiry timeout in milliseconds'),
+ expiryTimeout: z.number().min(1).optional().describe('Expiry timeout in milliseconds'),
const isSessionExpired = | ||
session && | ||
isDefined(session.state.expiryTimeout) && | ||
session?.updatedAt.getTime() + session.state.expiryTimeout < Date.now() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The session expiration check is not correctly implemented. The expiryTimeout
is supposed to represent hours, but it's being compared directly with milliseconds from Date.now()
. You need to convert the expiryTimeout
to milliseconds before performing the comparison.
- session?.updatedAt.getTime() + session.state.expiryTimeout < Date.now()
+ session?.updatedAt.getTime() + session.state.expiryTimeout * 60 * 60 * 1000 < Date.now()
}) => { | ||
const session = sessionId ? await getSession(sessionId) : null | ||
|
||
const isSessionExpired = | ||
session && | ||
isDefined(session.state.expiryTimeout) && | ||
session.updatedAt.getTime() + session.state.expiryTimeout < Date.now() | ||
|
||
if (isSessionExpired) | ||
throw new TRPCError({ | ||
code: 'NOT_FOUND', | ||
message: 'Session expired. You need to start a new session.', | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for checking session expiration seems correct, but it's important to ensure that the expiryTimeout
is stored in milliseconds since it's being compared with Date.now()
, which returns the current time in milliseconds. If expiryTimeout
is stored in hours as per the PR summary, you need to convert it to milliseconds before comparing.
- session.updatedAt.getTime() + session.state.expiryTimeout < Date.now()
+ session.updatedAt.getTime() + session.state.expiryTimeout * 60 * 60 * 1000 < Date.now()
}) | ||
|
||
export const defaultSessionExpiryTimeout = 12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The defaultSessionExpiryTimeout
constant is defined but not used in the schema definition. Consider using it as a default value in the schema itself.
sessionExpiryTimeout: z
.number()
.max(48)
.min(0)
.optional()
.describe('Expiration delay in hours after latest interaction'),
+ .default(defaultSessionExpiryTimeout),
userId: undefined, | ||
}) | ||
|
||
const sessionExpiryTimeoutHours = | ||
publicTypebot.settings.whatsApp?.sessionExpiryTimeout ?? | ||
defaultSessionExpiryTimeout | ||
|
||
return { | ||
...session, | ||
newSessionState: { | ||
...session.newSessionState, | ||
whatsApp: { | ||
contact, | ||
credentialsId: credentials.id, | ||
}, | ||
expiryTimeout: sessionExpiryTimeoutHours | ||
? sessionExpiryTimeoutHours * 60 * 60 * 1000 | ||
: undefined, | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new hunk introduces a sessionExpiryTimeoutHours
variable that retrieves the sessionExpiryTimeout
setting from the public Typebot settings or defaults to defaultSessionExpiryTimeout
. This value is then used to set the expiryTimeout
field in the newSessionState
object, which is calculated in milliseconds.
This change aligns with the PR's goal of implementing a custom session expiration feature. However, it's important to ensure that the sessionExpiryTimeout
setting is correctly defined and updated in the UI and backend, as this could impact the user experience if sessions expire too quickly or not at all.
Also, consider handling the case where sessionExpiryTimeoutHours
is zero or negative. Currently, if sessionExpiryTimeoutHours
is zero, expiryTimeout
will be undefined due to the conditional check, which may not be the intended behavior.
const sessionExpiryTimeoutHours =
publicTypebot.settings.whatsApp?.sessionExpiryTimeout ??
defaultSessionExpiryTimeout
return {
...session,
newSessionState: {
...session.newSessionState,
whatsApp: {
contact,
},
expiryTimeout: sessionExpiryTimeoutHours >= 0
? sessionExpiryTimeoutHours * 60 * 60 * 1000
: undefined,
},
}
}
apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx
Show resolved
Hide resolved
apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx
Outdated
Show resolved
Hide resolved
apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx
Show resolved
Hide resolved
Rate Limit ExceededYou have exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 29 minutes and 59 seconds before requesting another review. To re-trigger a review, convert this PR to a draft and then mark it as ready for review again. Alternatively, you can push a new commit to this PR. |
* 🚸 (typebotLink) Make sure variables from child bots are merged if necessary * ⚡ (customDomain) Add configuration modal for domain verification Closes baptisteArno#742 * 🐛 Fix bubble icon file upload * 🚸 (results) Use header id as table accessor to allow duplicate names * 🐛 (payment) Fix postalCode camel case issue Closes baptisteArno#822 * 🐛 (results) Fix result modal content display * ⚡ (whatsapp) Improve WhatsApp preview management Closes baptisteArno#800 * 🛂 (fileUpload) Improve file upload size limit enforcement Closes baptisteArno#799, closes baptisteArno#797 * 📝 Change googleSheets date system var name * ♻️ Export bot-engine code into its own package * ♻️ Remove storage limit related code * 🚑 Fix file upload expiration issue * 🚑 (upload) Fix upload in embed * 📝 Add custom domain troobleshoot section * 👷 (vercel) Increase max execution duration for webhooks * ⚡ (whatsapp) Improve whatsApp management and media collection Closes baptisteArno#796 * 💚 Rename back viewer * 👷 Only build docker images on tag push * ✨ (whatsapp) Add custom session expiration (baptisteArno#842) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - New Feature: Introduced session expiry timeout for WhatsApp integration, allowing users to set the duration after which a session expires. - New Feature: Added an option to enable/disable the start bot condition in WhatsApp integration settings. - Refactor: Enhanced error handling by throwing specific errors when necessary conditions are not met. - Refactor: Improved UI components like `NumberInput` and `SwitchWithLabel` for better usability. - Bug Fix: Fixed issues related to session resumption and message sending in expired sessions. Now, if a session is expired, a new one will be started instead of attempting to resume the old one. - Chore: Updated various schemas to reflect changes in session management and WhatsApp settings. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 🚑 (billing) Fix disabled upgrade buttons * ♿ (embed) Add aria-label to bubble button * ⚡ (wordpress) Add query params exclusion support * 🐛 (bot) Fix reactivity issue when filtering single choices Closes baptisteArno#803 * ⚡ Auto continue bot on whatsApp if starting block is input (baptisteArno#849) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit **New Features:** - Added WhatsApp integration feature to the Pro plan. **Refactor:** - Introduced the ability to exclude specific plans from being displayed in the Change Plan Modal. - Renamed the function `isProPlan` to `hasProPerks`, enhancing code readability and maintainability. - Updated the `EmbedButton` component to handle a new `lockTagPlan` property and use the `modal` function instead of the `Modal` component. **Chore:** - Removed the `whatsAppPhoneNumberId` field from the `Typebot` model across various files, simplifying the data structure of the model. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 🚑 (fileUpload) Fix file upload in linked typebots * ⚡ (setVariable) Add "Environment name" value in Set variable block (baptisteArno#850) Closes baptisteArno#848 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - New Feature: Added "Environment name" as a new value type in the SetVariable function, allowing users to distinguish between 'web' and 'whatsapp' environments. - Refactor: Simplified session state handling in `resumeWhatsAppFlow.ts` for improved code clarity. - Refactor: Updated `startWhatsAppSession.ts` to include an initial session state with WhatsApp contact and expiry timeout, enhancing session management. - Bug Fix: Improved null handling in `executeSetVariable.ts` for 'Contact name' and 'Phone number', preventing potential issues with falsy values. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 🛂 Improve editor authorization feedback (baptisteArno#856) Closes baptisteArno#844, closes baptisteArno#839 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - New Feature: Added a `logOut` function to the user context for improved logout handling. - Refactor: Updated the redirect path in the `SignInForm` component for better user redirection after authentication. - New Feature: Enhanced the "Add" button and "Connect new" menu item in `CredentialsDropdown` with role-based access control. - Refactor: Replaced the `signOut` function with the `logOut` function from the `useUser` hook in `DashboardHeader`. - Bug Fix: Prevented execution of certain code blocks in `TypebotProvider` when `typebotData` is read-only. - Refactor: Optimized the `handleObserver` function in `ResultsTable` with a `useCallback` hook. - Bug Fix: Improved router readiness check in `WorkspaceProvider` to prevent premature execution of certain operations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 🚸 Better random IDs generation in setVariable * 🐛 (pixel) Fix multiple Meta pixels tracking Closes baptisteArno#846 * 📝 (whatsapp) Add a "Create WhatsApp app" guide * 🚸 (whatsapp) Improve upgrade plan for whatsapp notice * 🐛 (preview) Fix always displayed start props toast * 🐛 (whatsapp) Fix preview failing to start and wait timeo… * 🚸 (pictureChoice) Improve single picture choice with same titles Closes baptisteArno#859 * 🚸 (pictureChoice) Allow dynamic picture choice with… (baptisteArno#865) … string variables <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - Refactor: Updated `GoogleSheetsNodeContent` component to use the `options` prop instead of `action`, and integrated the `useTypebot` hook for better functionality. - Style: Improved UI text and layout in `GoogleSheetsSettings.tsx`, enhancing user experience when selecting rows. - Refactor: Simplified rendering logic in `BlockNodeContent.tsx` by directly calling `GoogleSheetsNodeContent` component, improving code readability. - Bug Fix: Enhanced `injectVariableValuesInPictureChoiceBlock` function to handle different types of values for titles, descriptions, and picture sources, fixing issues with variable value injection. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 🐛 (whatsapp) Fix auto start input where it didn't display next bu… (baptisteArno#869) …bbles <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit **Release Notes** - New Feature: Enhanced WhatsApp integration with improved phone number formatting and session ID generation. - Refactor: Updated the `startWhatsAppPreview` and `receiveMessagePreview` functions for better consistency and readability. - Bug Fix: Added a check for `phoneNumberId` in the `receiveMessage` function to prevent errors when it's undefined. - Documentation: Expanded the WhatsApp integration guide and FAQs in the docs, providing more detailed instructions and addressing common queries. - Chore: Introduced a new `metadata` field in the `whatsAppWebhookRequestBodySchema` to store the `phone_number_id`. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 🐛 (typebotLink) Fix nested typebot link pop * 📝 (typebotLink) Add instructions about shared variables and merge answers * 🛂 (whatsapp) Remove feature flag Closes baptisteArno#401 * 🚑 (js) Fix dependency issue preventing user to install @typebot.io/js Closes baptisteArno#871 * 🚸 (whatsapp) Improve how the whatsapp preview behaves (baptisteArno#873) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - New Feature: Updated WhatsApp logo with a new design and color scheme. - New Feature: Added a help button in the UI linking to documentation, enhancing user guidance. - New Feature: Introduced an alert message indicating that the WhatsApp integration is in beta testing. - New Feature: Implemented a button to open WhatsApp Web directly from the application, improving user convenience. - Refactor: Adjusted the retrieval of `contactPhoneNumber` in `receiveMessagePreview` function for better data structure compatibility. - Refactor: Optimized the initialization and management of the WhatsApp session in `startWhatsAppPreview`. - Refactor: Improved the `parseButtonsReply` function by refining condition checks. - Refactor: Enhanced the readability of serialized rich text in `convertRichTextToWhatsAppText` by introducing newline characters. - Bug Fix: Ensured preservation of `contact` information when resuming the WhatsApp flow in `resumeWhatsAppFlow`. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 📝 Update About page content Closes baptisteArno#757 * 🐛 (builder) Fix system color mode not syncing properly * 🔖 Release v2.18.0 * 🚸 (sendEmail) Rename username SMTP creds label to avoid confusion * 🐳 Bump Postgres version in official docker compose file * 📝 (whatsapp) Re-organize whatsapp overview doc * 📝 (vercel) Add a note on function maxDuration for Hobby plans * 📝 (docker) Update postgres image name * 🚑 (whatsapp) Fix start whatsapp session when user has multiple whatsapp enabled * 🛂 (whatsapp) Disable whatsapp by default on duplication * 🛂 (whatsapp) Set default whatsapp expiry to 4 hours * 🚸 (videoBubble) Reparse variable video URL to correctly detect provider * 🐛 (whatsapp) Fix force create session when flow is completed at first round * 🧑💻 Improve invalid environment variable insight on build fail * 🐳 Remove wait-for-it script to avoid edge cases issues * 🚑 (results) Fix broken infinite scroll * ♻️ (api) Auto start bot if starting with input Closes baptisteArno#877, closes baptisteArno#884 * ✨ Automatically parse markdown from variables in text bubbles Closes baptisteArno#539 * 📝 (whatsapp) Remove private beta mention * 🚑 Fix text styling parsing on variables * 🐛 New sendMessage version for the new parser Make sure old client still communicate with old parser * 🔖 (wordpress) Deploy v3.4.0 * ⬆️ (openai) Replace openai-edge with openai and upgrade next * 🐛 Enable stream again by migrating endpoint to route handler https://vercel.com/docs/functions/edge-functions/streaming#streaming-data-with-edge-functions * 🚸 (openai) Improve streamed message lists CSS * 🔥 Remove streamer Pages API endpoint * 🐛 Add no cache instructions to streamer Attempt to fix buffering issue when Cloudflare proxy is enabled * 💄 Better parsing of lists and code in streaming bubbles * ♻️ Remove sentry client monitoring in viewer * 🚸 (condition) Don't show value in node content if operator is "set" or "empty" * 📝 (embed) Add note about non-embeddable websites * ⬆️ Upgrade sentry and improve its reliability * 🐛 (editor) Fix default branding settings on cre… * 🛂 Sanitize custom CSS and head code to avoid modification of lite badge * 📝 (s3) Add s3 configuration detailed instructions * 🚑 Fix custom CSS sanitization * 🚸 (openai) Improve streaming bubble sequence and visual * 💚 Fix docker build when Sentry not enabled * 🔖 Release v2.18.1 * 🚑 Fix empty bubble issue when plate element does not have a type attribute * 🐛 (openai) Fix 2 openai streaming back to back * 📝 (openai) Add "Multiple OpenAI blocks" video section * ⚡ (video) Allow changing video height when resolved to an iframe * 🐛 Fix link parsing when using variables Closes baptisteArno#764 * 🐛 (textBubble) Fix overflow with long links Closes baptisteArno#764 * 🐛 (videoBubble) Fix youtube parsing for IDs containing a "-" * 🐳 Force Next.js apps local hostname Closes baptisteArno#911 * 🔖 Release v2.18.2 * 🐛 (webhook) Fix webhook response data key number parsing * 📝 Add bounties info in README * ⚡ (billing) Automatic usage-based billing (baptisteArno#924) BREAKING CHANGE: Stripe environment variables simplified. Check out the new configs to adapt your existing system. Closes baptisteArno#906 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit **New Features:** - Introduced a usage-based billing system, providing more flexibility and options for users. - Integrated with Stripe for a smoother and more secure payment process. - Enhanced the user interface with improvements to the billing, workspace, and pricing pages for a more intuitive experience. **Improvements:** - Simplified the billing logic, removing additional chats and yearly billing for a more streamlined user experience. - Updated email notifications to keep users informed about their usage and limits. - Improved pricing and currency formatting for better clarity and understanding. **Testing:** - Updated tests and specifications to ensure the reliability of new features and improvements. **Note:** These changes aim to provide a more flexible and user-friendly billing system, with clearer pricing and improved notifications. Users should find the new system more intuitive and easier to navigate. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 🚑 (billing) Fix chats pricing tiers incremental flat amou… * 👷 Improve getUsage accuracy in check cron job * 🐛 (results) Lower the max limit in getResults endpoint to avoid payload size error Closes baptisteArno#908 * 💚 Fix send email in CI "React is not defined" * 🐛 Freeze body overflow when opening a Popup embed (baptisteArno#937) fix baptisteArno#763 /claim baptisteArno#763 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - **Enhancement**: Improved the visibility management of the bot in the popup. This update ensures a smoother and more intuitive user experience when interacting with the bot. - **Bug Fix**: Resolved an issue where certain styles could interfere with the bot's visibility in the popup. The update prioritizes the necessary style settings, ensuring the bot's visibility is maintained as expected, regardless of other conflicting styles. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 🐛 Fixed pinch zooming mouse issue (with ctrl key) (baptisteArno#940) **Fixed the drastic zoom increase decrease on ctrl + mouse scroll.** The issue was occuring due to the "scale" property in the pinch gesture. The scale was getting bigger values, leading to more zooming. What I did was, made sure that maximum scale difference between current and last value cannot be more than the scaling factor used in zoomin/zoomout buttons. That is. 0.2 Also, the pinch zoom would work as expected. /claim baptisteArno#567 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - Improvement: Enhanced zoom precision in the Graph component. This update allows for more accurate scaling when adjusting the view in the graph builder. The change ensures that the zoom level adjusts more precisely, providing a smoother and more controlled user experience when interacting with graphs. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * Fix audio content overflow in windows. (baptisteArno#944) /claim baptisteArno#667 The volume slider in audio element in windows chrome overflows. Possible fixes: 1. Change the width of audio blocks. (Not suggested, as the width of all blocks should be consistent) 2. Adjust the audio sub elements, so it doesn't overflow.(IMPLEMENTED) It's not so straightforward to apply customization to audio tag element. The best possible way I could find, to make the app look good, is by hiding the timeline track in the audio. It was showing up very small anyway(due to block width), so there shouldn't be an issue. Please look at the before & after videos below. https://github.com/baptisteArno/typebot.io/assets/29385192/f61c5b58-834d-470f-b684-bd82181e07f4 https://github.com/baptisteArno/typebot.io/assets/29385192/88f932eb-dc7e-4346-bf64-6405a015013e <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - Style: Improved the visual layout of the audio player on Windows. The update includes a cleaner interface by hiding the track timeline and adjusting the media controls panel. This change enhances the user experience by providing a more streamlined and intuitive audio player design. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * ♻️ Update import contact to brevo script * 👷 Add convenient script for migrating Stripe prices * 🩹 Surround logs saving in a try catch block It seems that in some particular set up the logs saving is failing. * 🚸 (buttons) Trim items content when parsing reply for better consistency Closes baptisteArno#948 * 🔖 Release v2.18.3 * ✏️ Fix popup blocked toast typo * 🧑💻 (whatsapp) Improve whatsapp start log * 🐛 (numberInput) Fix input clearing out on dot or comma press * 🚑 Fix can invite new members in workspace bool Closes baptisteArno#964 * 🔖 Release v2.18.4 * 🐛 Fix graph flickering on high res displays (baptisteArno#959) This PR fixes the flickering and improves the performance so panning around the graph is much smoother than before. https://github.com/baptisteArno/typebot.io/assets/62795688/56b91e20-1eb0-44b5-9a4a-c07525c2ba48 /claim baptisteArno#575 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - Refactor: Improved the Graph component's scaling calculation for enhanced readability and maintenance. - Style: Updated the Graph component's style properties to ensure better compatibility and visual performance on webkit browsers. These changes aim to enhance the user experience by ensuring the Graph component displays consistently across different web browsers. The refactoring of the scaling calculation also makes the code easier to understand and maintain, potentially leading to quicker updates and bug fixes in the future. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Baptiste Arnaud <[email protected]> * ✏️ Fix manual deployment doc start script typo Closes baptisteArno#969 * 💚 Fix checkAndReportChatsUsage script sending multiple emails at once * 🧑💻 Fix type resolution for @typebot.io/react and nextjs Closes baptisteArno#968 * 🧑💻 Migrate to Tolgee (baptisteArno#976) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - Refactor: Transitioned to a new translation library (`@tolgee/react`) across the application, enhancing the localization capabilities and consistency. - New Feature: Introduced a JSON configuration file for application settings, improving customization and flexibility. - Refactor: Updated SVG attribute naming convention in the `WhatsAppLogo` component to align with React standards. - Chore: Adjusted the `.gitignore` file and added a new line at the end. - Documentation: Added instructions for setting up environment variables for the Tolgee i18n contribution dev tool, improving the self-hosting configuration guide. - Style: Updated the `CollaborationMenuButton` to hide the `PopoverContent` component by scaling it down to zero. - Refactor: Simplified error handling logic for fetching and updating typebots in `TypebotProvider.tsx`, improving code readability and maintenance. - Refactor: Removed the dependency on the `parseGroupTitle` function, simplifying the code in several components. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 🐛 Fix group duplicate new title bug * 📝 Add webhook configuration tuto video * 🐛 (number) Fix number input validation with variables * 📝 Add text link section in text bubble doc * ✏️ Fix CORSRules content typo for S3 config * 🐛 Fix formatted message in input block when input is retried * ⚡ Add cache-control header on newly uploaded files * ✏️ (billing) Fix plan name typo * 🚑 Move cache control header into the post policy * 🔖 Release v2.19.0 * 📝 Add UTM params forwarding video tutorial * 📦 Add strict package versioning to avoid incompatibility in workspace * ⬆️ Upgrade Sentry to mitigate security issue https://github.com/getsentry/sentry-javascript/security?mkt_tok=Nzc2LU1KTi01MDEAAAGPNi0ooiOxT0sphdzXd6xHU63d5z5Sc75FNR8cH-6EK-zlvUsUuUqP1YsmnxivxEyXnGZS2cN8XkpuNNGi3NIfoDnwoHci-31tbyJQB8y0Cg * ⚡ (chatwoot) Unmount Typebot embed bubble when opening chatwoot Closes baptisteArno#1007 * 🚑 Fix weird env parsing on Firefox making it crash * 🛂 Update Cache-Control header in generatePresignedPostPolicy * fix: whole page overflowing on the x axis and displaying a horizontal scrollbar (baptisteArno#1011) this PR fixes issue baptisteArno#1008 by making the position of `HandDrawnArrow`'s parent relative, which confines the absolute position of its children to be within the bounds of the parent, causing layout not shift due to `right -30px` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Updated the layout behavior of the `RealTimeResults` component on the landing page for better user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * ♻️ Introduce typebot v6 with events (baptisteArno#1013) Closes baptisteArno#885 * 🚑 Fix parsing issue with new events field on ongoing session states * 🐛 (import) Fix import typebot files that does not have name field * 🚸 (typebotLink) Make "current" option work like typebot links instead of jump * 🐛 Fix typebot publishing endpoint events parsing * 🐛 Fix default initial items in TableList * 🚑 (editor) Fix move block with outgoing edge * 🚑 (zapier) Fix execute webhook endpoint too strict on block type check * 🐛 (typebotLink) Fix link to first group with start event * 🚑 (webhook) Fix webhook execution with default method * 🐛 (editor) Fix edge delete with undefined groupIndex * 🐛 Sort variables to parse to fix text bubble parsing issue * 🐛 Fix theme background and font default selection * 💄 Fix multi choice checkbox UI on small screens * 📝 Add breaking changes and OpenAI block improvements docs * ⚡ Add more video supports (baptisteArno#1023) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new layout option for the TextInput component. - Added support for GUMLET and TIKTOK video content types in VideoBubbleContent. - Enhanced VideoUploadContent to handle new properties like aspectRatio and maxWidth. - Updated VideoBubble to include aspect-ratio and max-width styles based on content properties. - **Refactor** - Changed the extension used for internationalization (i18n) in the VS Code environment. - Modified how environment variables are accessed in tolgee.tsx. - Updated parseVideoUrl function to include a new property videoSizeSuggestion. - **Chores** - Updated the tolgeeEnv object in env.ts and added a new optional parameter to the getRuntimeVariable function. - Expanded video handling capabilities by introducing new video content types and associated regular expressions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Closes baptisteArno#978 baptisteArno#936 baptisteArno#926 * 🛂 Reduce sendMessage serverless function max memory * 🐛 (webhook) Fix legacy webhook {{state}} body parsing * 🧑💻 (chat) Introduce startChat and continueChat endpoints Closes baptisteArno#1030 * ⏪ Revert new authentication method for preview bot * 📝 Add OpenAI Dialogue option in breaking change doc * ⚡ Add maxWidth and maxHeight bubble them props Closes baptisteArno#458 * 📝 Change community URLs, introduce Discord server Closes baptisteArno#866 * 🐛 (textBubble) Fix variable parsing when starting or finishing by spaces * ⏪ (wordpress) Revert to specific non breaking version for self-hosters * 🐛 (billing) Set invoicing behavior to "always invoice" to fix double payment issue * 🐛 (js) Fix default theme values css variables Closes baptisteArno#1031 * 🐛 (fileUpload) Fix results file display if name contains comma Closes baptisteArno#955 * ⬆️ (date) Upgrade date parser package * 📝 Update Discord invite link * 🚸 Auto scroll once picture choice images are fully loaded * ♿ Show scrollbar on searchable items * 🐛 Fix typebot parsing for legacy columnsWidth setting * 🐛 (wordpress) Fix version mismatch for self-hosters for Standard embed as well Closes baptisteArno#1038 * 🐛 (typebotLink) Fix variables merging with new values * 🐛 (editor) Fix AB test items not connectable * 🔊 Add response debug log for failing requests without errors * 💚 Fix docker build missing ts target in schemas * 🔖 Release v2.19.1 * ✏️ Fix typebot v7 breaking changes doc typo * 🌐 Add es and ro support * ✨ (openai) Add create speech OpenAI action Closes baptisteArno#1025 * 🐛 (chatwoot) Fix email prefill when Chatwoot contact already exist * 🛂 (billing) Add isPastDue field in workspace (baptisteArno#1046) Closes baptisteArno#1039 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Workspaces now include additional status indicator: `isPastDue`. - New pages for handling workspaces that are past due. Meaning, an invoice is unpaid. - **Bug Fixes** - Fixed issues with workspace status checks and redirections for suspended workspaces. - **Refactor** - Refactored workspace-related API functions to accommodate new status fields. - Improved permission checks for reading and writing typebots based on workspace status. - **Chores** - Database schema updated to include `isPastDue` field for workspaces. - Implemented new webhook event handling for subscription and invoice updates. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 🚑 (editor) Fix typebot update permission * ✨ Allow user to share a flow publicly and make it duplicatable Closes baptisteArno#360 * 🐛 (pictureChoice) Fix choice parsing too unrestrictive * 🔥 Remove VIEWER_URL_INTERNAL variable BREAKING CHANGE: NEXT_PUBLIC_VIEWER_INTERNAL does not exist anymore as typebot.io now directly points to the viewer project * 🚑 (billing) Fix stripe webhook "invoice.paid" typo * 🐛 Fix processTelemetry endpoint not reachable * ⚡ (billing) Improve past_due workspace checking webhook * 📝 Add new start and continue endpoints in the API runtime instructions * 🚸 (redirect) Make sure the redirection is always done on top frame * 🔧 Increase builder request max size to 4MB * 💚 Update broken action-autotag package * 🚑 (pictureChoice) Fix pic choice multi select parsing * 📝 Improve WP prefilled var explanation * 🐛 Fix default webhook body with multi inputs groups * 🛂 Allow app admin to read a typebot * 🐛 (share) Fix duplicate folderId issue * 🚸 (fileUpload) Properly encode commas from uploaded file urls Closes baptisteArno#955 * ⚡ (wordpress) Add lib_version prop in shortcode Closes baptisteArno#1035 * 📝 Add flow share docs * 🔖 Release v2.20.0 * ⚗️ (docs) Replace Algolia search with Community Search * Updated vercel deployment guide. (baptisteArno#1075) Adding explanation text about builder and viewer. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Enhanced the self-hosting guide with additional explanatory notes on deploying both the Builder and Viewer components for Typebot, clarifying their distinct roles in service flow creation and user interaction. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 🐛 (editor) Fix old typebot flash when changing the typebot * 🐛 Fix multiple item dragged issue * 🐛 Fix right click in bubble text editor selects the group Closes baptisteArno#920 * ✏️ Fix invalid ending comma in API instructions Closes baptisteArno#1022 * 🧑💻 Automatically guess env URLs for Vercel preview deploy… (baptisteArno#1076) …ments <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new URL processing logic to enhance compatibility with Vercel preview environments. - Improved handling of environment-specific URLs for authentication and viewer services. - **Enhancements** - Streamlined environment variable management for more reliable deployment configurations. - **Documentation** - Updated documentation to reflect new environment variable processing functions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * 📝 Add node prerequisite in Contributing guide * 🛂 (billing) Past due status only for unpaid invoices with additional usage * 🚸 (docs) Open community search docs results in same tab * ♻️ Remove references to old s3 URLs * 🔧 Update vercel.json to reflect new api path * 🛂 Hide workspace members list from guest * update typebot * update typebot * 🔧 Update main viewer domain to typebot.co * Delete apps/landing-page/public/favicon.png * Add files via upload * Delete apps/builder/public/favicon.png * Add files via upload * Delete apps/viewer/public/favicon.png * Add files via upload * Add files via upload * Delete apps/builder/public/favicon.png * Add files via upload * Add files via upload * translate * app.chatwoot.com * options.baseUrl * ⚡ Add dynamic timeout to bot engine api * 🐛 (sheets) Init OAuth client inside a function to avoid potential conflict * 🐛 Fix change language not working in the editor * ✨ Introducing Radar, fraud detection * Update publishTypebot.ts * 📝 (docs): fix typo in Unsplash description (baptisteArno#1094) Documentation This PR updates the documentation to fix an incorrect description for the Unsplash configuration. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Corrected a hyperlink and associated text in the self-hosting configuration guide, changing "Giphy" to "Unsplash" for image search references. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Victor Santos <[email protected]> * 📈 Only send suspicious bot alert if risk level is below 100 * 🛂 Auto ban IP on suspected bot publishing (baptisteArno#1095) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced sign-in error handling with specific messages for different error types. - Implemented IP-based restrictions for authentication and publishing actions. - **Bug Fixes** - Updated the retrieval of user session information to improve reliability. - **Documentation** - Updated usage instructions for `getServerSession` to reflect the new authentication options. - **Refactor** - Replaced direct usage of `authOptions` with a new function `getAuthOptions` to dynamically generate authentication options. - Improved IP address extraction logic to handle various header formats. - **Chores** - Added a new `BannedIp` model to the database schema for managing IP-based restrictions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * feat: toolzz logo on sigin and header --------- Signed-off-by: Victor Santos <[email protected]> Co-authored-by: Baptiste Arnaud <[email protected]> Co-authored-by: Rishi Raj Jain <[email protected]> Co-authored-by: Prateek Kalra <[email protected]> Co-authored-by: neo773 <[email protected]> Co-authored-by: onFire(Abhi) <[email protected]> Co-authored-by: Thiago Mendonça <[email protected]> Co-authored-by: lucasbuges <[email protected]> Co-authored-by: Baptiste Arnaud <[email protected]> Co-authored-by: Victor Santos <[email protected]>
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - New Feature: Introduced session expiry timeout for WhatsApp integration, allowing users to set the duration after which a session expires. - New Feature: Added an option to enable/disable the start bot condition in WhatsApp integration settings. - Refactor: Enhanced error handling by throwing specific errors when necessary conditions are not met. - Refactor: Improved UI components like `NumberInput` and `SwitchWithLabel` for better usability. - Bug Fix: Fixed issues related to session resumption and message sending in expired sessions. Now, if a session is expired, a new one will be started instead of attempting to resume the old one. - Chore: Updated various schemas to reflect changes in session management and WhatsApp settings. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
NumberInput
andSwitchWithLabel
for better usability.