Skip to content

🐞[Bug]: bug(ai): improve error handling and user feedback in AI health chat #1355

@minhajparveenh2008

Description

@minhajparveenh2008

Related Area

Frontend

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The AI Health Chat feature does not handle API failures consistently. When the AI service fails due to network issues, rate limits, or server errors, the chat may stay stuck in a loading state or show unclear error messages. In some cases, errors are only logged in the console without proper user feedback.

Expected Behaviour

The AI Health Chat should handle all API failures gracefully. When an error occurs, the loading state should stop immediately and the user should see a clear, user-friendly message such as “Please check your internet connection” or “AI service is currently unavailable.” The user should always receive proper feedback instead of a blank screen or silent failure.

###Proposed solution

Standardize and improve error handling in the AI Health Chat frontend by implementing consistent API error handling and user-friendly feedback messages.

Suggested improvements:
Create a unified error handler for AI chat API responses
Map backend error codes to user-friendly messages
Ensure loading state is always reset on API failure
Replace console-only errors with visible UI feedback
Optionally add retry button for failed requests

Error mapping example:
429 → “Too many requests. Please try again later.”
503 → “AI service is currently unavailable.”
Network failure → “Please check your internet connection.”

Implementation approach:
Update AI chat service/API layer
Refactor Chatbot screen error handling logic
Ensure consistent Snackbar/Alert usage across AI chat flows

Steps to Reproduce:
Open the UltimateHealth mobile app
Go to AI Health Chat screen
Type any message (e.g., “Hello”)
Turn off internet OR simulate slow network
Send the message
Observe the behavior when the API fails

Add ScreenShots

No response

What browsers are you seeing the problem on?

No response

Record

  • I have read the Contributing Guidelines
  • I'm a GSSOC'24 contributor
  • I'm a GSSOC'26 contributor
  • I'm a IEEE IGDTUW contributor
  • I want to work on this issue

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions