AI chatbots format their responses based on the platform, use case, and desired user experience. Here’s how they typically structure and format their replies:
1. Basic Text Formatting
Most chatbots start with plain text but may add simple formatting for clarity:
- Line breaks:
\n (new line) or spaces for readability.
- Bold/italic: Some platforms support Markdown-like syntax (e.g.,
*italic*, **bold**).
- Lists: Bulleted (
-, *) or numbered lists.
- Code blocks: Backticks (`) or triple backticks for code snippets.
Example:
Here are your options:
1. Check your balance 💰
2. Transfer funds 📤
3. Exit ❌
2. Rich Formatting (Markdown, HTML, or Platform-Specific Syntax)
Depending on the platform (web apps, messaging services, etc.), chatbots may use:
3. Structured Data (for APIs or Apps)
Chatbots integrated with apps or APIs often return structured data (like JSON) instead of raw text. This allows the frontend to render the response dynamically.
Example (JSON):
{
"message": "Your flight is confirmed!",
"details": {
"flight_number": "AA123",
"departure": "2024-03-15T10:00:00",
"status": "Confirmed ✅"
},
"buttons": [
{ "text": "View Itinerary", "url": "https://example.com/itinerary" }
]
}
4. Platform-Specific Formatting
Chatbots on messaging platforms (WhatsApp, Facebook Messenger, Telegram) follow platform-specific rules:
- Buttons: Quick-reply buttons (e.g., "Yes" / "No").
- Cards: Visual elements with images, titles, and buttons.
- Templates: Pre-approved message formats for notifications (e.g., order updates).
Example (WhatsApp Template Message):
Hi {{name}}, your order is ready! 📦
Status: {{status}}
Estimated delivery: {{date}}
5. Dynamic Content Generation
Chatbots often insert variables (e.g., user names, dates) or personalize responses using logic:
response = f"Welcome back, {user_name}! Your last login was on {last_login_date}."
6. Voice Assistant Responses
For voice interfaces (Alexa, Google Assistant), formatting focuses on:
- SSML (Speech Synthesis Markup Language) to control tone, pauses, or emphasis.
- Short, conversational sentences without visual formatting.
Example (SSML):
<speak>
Your account balance is <prosody pitch="+10%">$100</prosody>.
<break time="500ms"/> Would you like to proceed?
</speak>
How Formatting is Applied
- Generation Phase: The AI model (e.g., GPT, Claude) generates a response with formatting hints (e.g., "add a checkmark emoji here").
- Post-Processing: The backend applies platform-specific syntax (e.g., converting
:checkmark: to ✅ or HTML).
- Rendering: The user’s device/app displays the formatted response.
Best Practices
- Consistency: Match the platform’s style (e.g., avoid HTML in SMS).
- Accessibility: Use alt text for images or emojis (e.g.,
✅ (success)).
- Fallbacks: Ensure plain text works if formatting fails.
- Security: Sanitize HTML to prevent XSS attacks.
Example Responses
- Plain Text:
Hello! How can I assist you today?
- Markdown:
## Menu Options:
- *Pizza* 🍕
- *Burger* 🍔
- *Salad* 🥗
- Voice (SSML):
<speak>Please say your account number <emphasis>clearly</emphasis>.</speak>
By combining these methods, chatbots deliver responses tailored to their environment while enhancing user engagement! 🚀