diff --git a/api/src/chat/services/bot.service.ts b/api/src/chat/services/bot.service.ts index 4694b706..13e6cd57 100644 --- a/api/src/chat/services/bot.service.ts +++ b/api/src/chat/services/bot.service.ts @@ -275,7 +275,6 @@ export class BotService { !matchedBlock && event.getMessageType() === IncomingMessageType.message && fallbackOptions.active && - convo.context?.attempt && convo.context.attempt < fallbackOptions.max_attempts ) { // Trigger block fallback diff --git a/frontend/src/components/visual-editor/constants.ts b/frontend/src/components/visual-editor/constants.ts index cdd4349b..748eea6d 100644 --- a/frontend/src/components/visual-editor/constants.ts +++ b/frontend/src/components/visual-editor/constants.ts @@ -20,7 +20,7 @@ export const SIMPLE_TEXT_BLOCK_TEMPLATE: Partial = { patterns: ["Hi"], options: { typing: 0, - fallback: { active: false, max_attempts: 1, message: [] }, + fallback: { active: false, max_attempts: 0, message: [] }, }, message: ["Hi back !"], starts_conversation: false, @@ -30,7 +30,7 @@ export const ATTACHMENT_BLOCK_TEMPLATE: Partial = { patterns: ["image"], options: { typing: 0, - fallback: { active: false, max_attempts: 1, message: [] }, + fallback: { active: false, max_attempts: 0, message: [] }, }, message: { attachment: { @@ -46,7 +46,7 @@ export const QUICK_REPLIES_BLOCK_TEMPLATE: Partial = { patterns: ["colors"], options: { typing: 0, - fallback: { active: false, max_attempts: 1, message: [] }, + fallback: { active: false, max_attempts: 0, message: [] }, }, message: { text: "What's your favorite color?", @@ -71,7 +71,7 @@ export const BUTTONS_BLOCK_TEMPLATE: Partial = { patterns: ["about"], options: { typing: 0, - fallback: { active: false, max_attempts: 1, message: [] }, + fallback: { active: false, max_attempts: 0, message: [] }, }, message: { text: "What would you like to know about us?", @@ -92,7 +92,7 @@ export const LIST_BLOCK_TEMPLATE: Partial = { patterns: ["coffee"], options: { typing: 0, - fallback: { active: false, max_attempts: 1, message: [] }, + fallback: { active: false, max_attempts: 0, message: [] }, content: { display: OutgoingMessageFormat.list, limit: 2, @@ -131,7 +131,7 @@ export const CUSTOM_BLOCK_TEMPLATE: Partial = { capture_vars: [], options: { typing: 0, - fallback: { active: false, max_attempts: 1, message: [] }, + fallback: { active: false, max_attempts: 0, message: [] }, }, starts_conversation: false, message: { diff --git a/frontend/src/components/visual-editor/form/inputs/options/LocalFallbackInput.tsx b/frontend/src/components/visual-editor/form/inputs/options/LocalFallbackInput.tsx index de00c0db..d2539d08 100644 --- a/frontend/src/components/visual-editor/form/inputs/options/LocalFallbackInput.tsx +++ b/frontend/src/components/visual-editor/form/inputs/options/LocalFallbackInput.tsx @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. @@ -70,6 +70,7 @@ const LocalFallbackInput: FC = ({ value, onChange }) => { value >= 0 || t("message.invalid_max_fallback_attempt_limit"), }, + valueAsNumber: true, })} helperText={ errors.options?.fallback?.max_attempts @@ -81,7 +82,7 @@ const LocalFallbackInput: FC = ({ value, onChange }) => { setFallback({ ...fallback, max_attempts: parseInt(e.target.value) || 0, - active: fallback.max_attempts > 0, + active: parseInt(e.target.value, 10) > 0, }); }} />