Overview
TheuseTamboSuggestions hook generates contextual prompt suggestions based on the conversation and available components. These suggestions help users discover what they can do next and keep conversations flowing naturally.
How It Works
- When the AI sends a message, Tambo analyzes the conversation context
- Suggestions are generated based on available components, tools, and conversation history
- Users click a suggestion to populate the input field or auto-submit
- The AI responds with the suggested action
import { useTamboSuggestions, useTambo } from '@tambo-ai/react';
function Chat() {
const { messages } = useTambo();
const { suggestions, accept, isLoading } = useTamboSuggestions();
if (isLoading) {
return <div>Loading suggestions...</div>;
}
return (
<div>
{messages.map((msg) => (
<Message key={msg.id} message={msg} />
))}
{suggestions.length > 0 && (
<div className="suggestions">
{suggestions.map((suggestion) => (
<button
key={suggestion.id}
onClick={() => accept({ suggestion })}
>
{suggestion.title}
</button>
))}
</div>
)}
</div>
);
}
const { suggestions, accept } = useTamboSuggestions();
suggestions.map((suggestion) => (
<button
key={suggestion.id}
onClick={() => accept({ suggestion, shouldSubmit: true })}
>
{suggestion.title}
</button>
));
Configuration Options
maxSuggestions
Maximum number of suggestions to generate (1-10):autoGenerate
Whether to automatically generate suggestions after assistant messages:false, call generate() manually:
queryOptions
Customize React Query behavior:Return Values
Data
Actions
UI State
Suggestion Object
Each suggestion has this structure:Advanced Examples
Styled Suggestion Chips
Manual Generation with Loading State
Suggestion Cards with Preview
Conditional Display
Only show suggestions when appropriate:Best Practices
Show suggestions after AI responses
Show suggestions after AI responses
Suggestions are most useful after the AI has responded, giving users natural next steps.
Hide during streaming
Hide during streaming
Don’t show suggestions while the AI is still responding:
Use clear, action-oriented titles
Use clear, action-oriented titles
Suggestion titles should clearly indicate what will happen:
- Good: “Show sales by region”, “Add a task”, “Export to CSV”
- Bad: “Click here”, “Next”, “More”
Provide visual feedback
Provide visual feedback
Show when a suggestion is being processed:
Consider mobile layouts
Consider mobile layouts
Use horizontal scrolling or wrapping for mobile:
Troubleshooting
No suggestions appearing
No suggestions appearing
- Ensure you’re using Tambo v1 API (not v0)
- Check that messages exist and latest is from assistant
- Verify
autoGenerateistrue(default) - Check browser console for errors
- Ensure you have components registered
Suggestions not relevant
Suggestions not relevant
- Register more components to give the AI more options
- Add context helpers to provide app state
- Increase
maxSuggestionsto get more variety
Suggestions taking too long
Suggestions taking too long
- Reduce
maxSuggestions(fewer = faster) - Check your network connection
- Verify API endpoint is accessible
Next Steps
Voice Input
Add voice input to your chat
Thread Input Hook
Handle user input and submission
Component State
Manage state in AI components
Context Helpers
Improve suggestions with context