-
Notifications
You must be signed in to change notification settings - Fork 105
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
fix(api): execute fallback message when no Global Fallback #552
base: main
Are you sure you want to change the base?
fix(api): execute fallback message when no Global Fallback #552
Conversation
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.
Hi @omarNaifer12
Thank you for contributing to Hexabot 🙏 We really appreciate the effort you’ve put into this 👏 .
As seen in the screenshots below after disabling the global fallback the block- level one is not displayed.
this.sendMessageToSubscriber(event, { | ||
id: 'global-fallback', | ||
name: 'Global Fallback', | ||
message: settings.chatbot_settings.fallback_message, | ||
options: {}, | ||
patterns: [], | ||
assign_labels: [], | ||
starts_conversation: false, | ||
position: { x: 0, y: 0 }, | ||
capture_vars: [], | ||
builtin: true, | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
attachedBlock: null, | ||
} as any as BlockFull); | ||
|
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.
Great job on this implementation! I think it would be even better if you could refactor the code to avoid duplication in the catch
block. By using a finally
statement to send the message to the subscriber instead
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.
Thanks! I'm not sure where to include the finally statement but I noticed that if we remove the sendMessageToSubscriber from the catch block it works because if there is an error, the catch block doesn't return anything to close the function.
I think there's a misunderstanding about the nature of the issue, let's pause here until we validate the issue. |
Hi @IkbelTalebHssan, thank you for the feedback! Could you please clarify the purpose of enabling the fallback option in the box and what its message should achieve? |
Here is my understanding of issue #115: |
Hi @omarNaifer12, For example, imagine you have configured a block that requires the user to input only numbers for a specific purpose, such as entering a phone number, age, or weight. If the user attempts to trigger this block by sending a message containing letters, special characters, or any invalid input, the block-level fallback message will be activated. This ensures that the user receives a tailored response explaining the issue, rather than triggering the global fallback (if one exists) or receiving no response at all (in cases where the global fallback is disabled). In essence, the block-level fallback message serves as a context-aware error handler, improving user experience by providing clear, relevant feedback when their input does not align with the block's requirements. |
Thank you @IkbelTalebHssan,I will handle this case as well. |
Motivation
I just added an extra condition to check if fallback_block is not nullable, to ensure it dont enter to the condition and trigger catch block if it's nullable.If you don't want to duplicate the logic of sendMessageToSubscriber, I can remove it from the catch block.
Fixes #115
Type of change:
Please delete options that are not relevant.
Checklist:
I have performed a self-review of my own code
New and existing unit tests pass locally with my changes