Skip to content

Add fallback response for unknown or unclear user queries#65

Open
Dev10-sys wants to merge 1 commit intodbpedia:masterfrom
Dev10-sys:fallback-unknown-queries
Open

Add fallback response for unknown or unclear user queries#65
Dev10-sys wants to merge 1 commit intodbpedia:masterfrom
Dev10-sys:fallback-unknown-queries

Conversation

@Dev10-sys
Copy link

@Dev10-sys Dev10-sys commented Jan 22, 2026

What this PR does

Adds a simple fallback mechanism in the RiveScript bot to handle unknown or unclear user queries more gracefully.

When the bot returns empty, very short, or non-informative responses, it now suggests example DBpedia-related questions instead of replying with confusing or irrelevant text.

Why

Currently, unclear queries may result in generic or misleading replies.
This change improves user experience by:

  • Avoiding meaningless responses
  • Guiding users toward supported DBpedia-style questions

Scope

  • No change to existing RiveScript rules
  • Minimal logic added in RiveScriptBot
  • No external dependencies introduced

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced chatbot error handling for unclear and invalid queries. The chatbot now provides helpful fallback responses instead of errors or empty responses, ensuring users always receive meaningful feedback. This improves reliability by gracefully handling edge cases that previously resulted in error messages, creating a more consistent user experience.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

The RiveScriptBot now caches reply results in a temporary variable and applies fallback logic when replies are null, empty, too short, match specific phrases, or contain error indicators. The final reply is processed through the same utility method regardless of source.

Changes

Cohort / File(s) Summary
RiveScript Bot Reply Fallback
src/main/java/chatbot/rivescript/RiveScriptBot.java
Modified reply handling to introduce fallback messaging. Replaced direct return statement with variable caching and conditional logic that assigns a predefined multi-line fallback message when reply is null, empty, too short, matches certain phrases, or contains "ERR". Maintains existing method signature while altering control flow for error scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a fallback response mechanism for unknown or unclear user queries. It matches the implemented behavior of providing a fallback message when replies are null, empty, too short, or contain error indicators.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant