AI Agent Component Spec
AI Agent Component Spec
Overview
CometChatUrlsFormatter detects URLs in text messages and renders them as clickable links. You can customize the styling and add click tracking.
Time estimate: 10 minutesDifficulty: Intermediate
Prerequisites
- React.js integration completed
- Custom Formatters guide reviewed

Steps
Step 1: Create the formatter class
ExtendCometChatTextFormatter with URL regex patterns:
Step 2: Add custom styling
Style the links to match your design:Step 3: Use the formatter
Pass it to message components:Step 4: Add click tracking
OverrideonUrlClick to add analytics:
Complete Example
Customization Options
Different link styles
Custom navigation
Common Issues
| Issue | Solution |
|---|---|
| Links not clickable | Check registerEventListeners is implemented |
| Styling not applied | Verify CSS class matches the one in formatUrls |
| Links opening in same tab | Add target="_blank" to anchor tags |