Apps
Notifications
Learn how to send notifications to OMI users from your applications, including direct text notifications and best practices for implementation.
Types of Notifications π¬
1. π± Direct Text Notifications
Direct text notifications allow you to send immediate messages to specific OMI users. This is useful for alerts, updates, or responses to user actions.
Example Use Cases
- Send task reminders and event notifications
- Notify users about service updates or changes
- Deliver real-time alerts and warnings
- Respond to user queries or actions
- Announce new features or important changes
Implementing Notifications π οΈ
Step 1: Set Up Authentication π
Before sending notifications, youβll need:
- Your OMI App ID (
app_id
) - Your OMI App Secret (API Key)
Store these securely as environment variables:
Step 2: Configure Your Endpoint π
Base URL and Endpoint
Required Headers
Query Parameters
Step 3: Implement the Code π»
Hereβs a complete Node.js implementation:
Step 4: Test Your Implementation π§ͺ
-
Set up your environment variables:
-
Test with a sample notification:
-
Verify the notification appears in the userβs OMI app
Best Practices π―
-
Rate Limiting
- Implement reasonable delays between notifications
- Avoid sending duplicate notifications
- Group related notifications when possible
-
Content Guidelines
- Keep messages concise and clear
- Include relevant context
- Use appropriate urgency levels
-
Error Handling
- Implement retry logic for failed attempts
- Log errors for debugging
- Monitor notification delivery status
-
Security
- Store API credentials securely
- Validate user IDs before sending
- Implement request timeouts
Troubleshooting π
Common Issues
-
Authentication Errors
- Verify your API credentials
- Check the Bearer token format
- Ensure environment variables are set
-
Delivery Issues
- Validate the user ID exists
- Check message encoding
- Verify network connectivity
-
Rate Limiting
- Monitor API response headers
- Implement exponential backoff
- Track notification frequency
Error Response Codes
Status Code | Meaning | Action |
---|---|---|
401 | Unauthorized | Check API credentials |
404 | User not found | Verify user ID |
429 | Too many requests | Implement rate limiting |
500 | Server error | Retry with backoff |
Example Implementations π‘
1. Task Reminder
2. Service Update
Need Help? π€
- Check our API Reference
- Join our Discord community
- Contact support