π¬ Quick Action Buttons for Case Agent - Discussion
Overviewβ
Add WhatsApp-style quick action buttons to the case agent chat interface for better user experience when:
- Sending banking alias - Add a copy button
- Sharing social media URLs - Add quick action buttons to open/share on each platform
Current Stateβ
How Messages Are Currently Sentβ
-
Case Agent (
toto-ai-hub/src/agents/CaseAgent.ts):- Sends plain text messages via
/api/caseendpoint - Returns:
{ success, message, metadata } - Messages are just strings like:
"El alias bancario es: betoto.pet""Puedes compartir en Instagram: https://instagram.com/guardian"
- Sends plain text messages via
-
Frontend (
toto-app/src/components/cases/CaseChatModal.tsx):- Receives messages as plain text
- Displays them in a chat bubble
- No interactive elements currently
Current Message Structureβ
interface ChatMessage {
id: string;
type: 'user' | 'system';
message: string; // Plain text
timestamp: Date;
metadata?: {
agentType?: string;
intent?: string;
};
}
Proposed Solutionβ
Option 1: Rich Message Format (Recommended)β
Extend the message structure to support interactive elements:
interface ChatMessage {
id: string;
type: 'user' | 'system';
message: string;
timestamp: Date;
metadata?: {
agentType?: string;
intent?: string;
// NEW: Quick actions
quickActions?: QuickAction[];
};
}
interface QuickAction {
type: 'copy' | 'open_url' | 'share';
label: string;
data: string; // The value to copy/URL to open
icon?: string; // Optional icon name
}
Example Messages:
- Alias with Copy Button:
{
"message": "El alias bancario del guardiΓ‘n es:",
"metadata": {
"quickActions": [
{
"type": "copy",
"label": "Copiar alias",
"data": "betoto.pet",
"icon": "copy"
}
]
}
}
- Social Media URLs with Quick Actions:
{
"message": "Puedes compartir este caso en:",
"metadata": {
"quickActions": [
{
"type": "open_url",
"label": "Instagram",
"data": "https://instagram.com/guardian",
"icon": "instagram"
},
{
"type": "open_url",
"label": "Twitter",
"data": "https://twitter.com/guardian",
"icon": "twitter"
},
{
"type": "open_url",
"label": "Facebook",
"data": "https://facebook.com/guardian",
"icon": "facebook"
}
]
}
}
Option 2: Structured Message Typesβ
Create specific message types for different content:
type MessageType =
| 'text'
| 'alias'
| 'social_media_share'
| 'link';
interface AliasMessage extends ChatMessage {
type: 'system';
messageType: 'alias';
alias: string;
}
interface SocialMediaMessage extends ChatMessage {
type: 'system';
messageType: 'social_media_share';
platforms: {
instagram?: string;
twitter?: string;
facebook?: string;
};
}
Implementation Considerationsβ
Backend Changes (toto-ai-hub)β
-
CaseAgent.ts - Detect when sending alias/social URLs:
- When alias is in response β add
quickActionswith copy button - When social media URLs are in response β add
quickActionsfor each platform
- When alias is in response β add
-
Response Format:
// In CaseAgent.processMessage()
const response = {
success: true,
message: "El alias es: betoto.pet",
metadata: {
quickActions: [
{ type: 'copy', label: 'Copiar', data: 'betoto.pet' }
]
}
};
Frontend Changes (toto-app)β
-
CaseChatModal.tsx:
- Render quick action buttons below system messages
- Handle button clicks:
- Copy: Use
Clipboard.setStringAsync()(Expo) ornavigator.clipboard.writeText()(Web) - Open URL: Use
Linking.openURL()(React Native) orwindow.open()(Web) - Share: Use native share dialog
- Copy: Use
-
Button Styling:
- WhatsApp-style: Rounded buttons, icon + text
- Position: Below message bubble
- Mobile-friendly: Touch targets β₯ 44px
-
Example Component:
{msg.metadata?.quickActions && (
<View style={styles.quickActions}>
{msg.metadata.quickActions.map((action, idx) => (
<TouchableOpacity
key={idx}
onPress={() => handleQuickAction(action)}
style={styles.quickActionButton}
>
<Icon name={action.icon} />
<Text>{action.label}</Text>
</TouchableOpacity>
))}
</View>
)}
Decisions Made β β
1. Detection Strategy β β
- Selected: Option A - Case Agent automatically detects alias/social URLs in response and adds quick actions
- Frontend will parse message text to detect patterns and add buttons automatically
2. Button Behavior β β
- Minimal design - Clean, simple buttons
- Transform on selection - When user clicks a button, it disappears and transforms into an actual user message
- Example: Click "Copiar alias" β Button disappears β User message appears: "betoto.pet"
3. Copy Feedbackβ
- Copy feedback = Visual confirmation that copy action succeeded
- Examples: Toast notification ("Alias copiado"), brief highlight, checkmark icon
- Decision: To be determined during implementation
4. Social Media Flow β β
- When user expresses sharing intent β Agent asks: "ΒΏEn quΓ© plataforma quieres compartir?"
- User responds with platform name β Agent sends URL for that specific platform
- If user says "all" or "todas" β Show quick action buttons with all platform icons (Instagram, X/Twitter, Facebook)
- Each button opens the specific platform URL
5. Implementation Order β β
- Phase 1: Alias copy button (start here)
- Phase 2: Social media quick actions (after alias is working)
Design Mockup Ideasβ
Alias Messageβ
βββββββββββββββββββββββββββββββ
β El alias bancario es: β
β betoto.pet β
βββββββββββββββββββββββββββββββ
[π Copiar alias]
Social Media Messageβ
βββββββββββββββββββββββββββββββ
β Comparte este caso en: β
βββββββββββββββββββββββββββββββ
[π· Instagram] [π¦ Twitter] [π€ Facebook]
Next Stepsβ
- Decide on approach (Option 1 vs Option 2)
- Define exact button styles (colors, icons, sizes)
- Implement backend changes (CaseAgent quick action detection)
- Implement frontend changes (Button rendering + handlers)
- Test on mobile and web
- Add analytics (track button clicks)
Benefitsβ
- β Better UX - Users can copy/open with one tap
- β Reduces friction - No need to manually select and copy text
- β Mobile-friendly - Large touch targets
- β Familiar pattern - WhatsApp-style is well-known
- β Actionable - Makes it clear what users can do
Potential Challengesβ
- β οΈ Backend needs to detect when to add quick actions
- β οΈ Frontend needs to handle both old (plain text) and new (with actions) messages
- β οΈ Cross-platform clipboard/URL handling differences
- β οΈ Message parsing if we go with Option C
Your Thoughts?β
What do you think about:
- Which option do you prefer? (Rich metadata vs Structured types)
- Should we detect automatically or be explicit?
- Any specific design preferences?
- Should we start with alias copy button first, then add social media?