Overview
Standard webhook flow has a timeout (default 30 seconds). If your processing takes longer, use async replies: Standard Flow:When to Use Async Replies
Good Use Cases
Long Processing
AI operations taking >30 seconds
External APIs
Waiting for slow third-party services
Complex Workflows
Multi-step processes with user updates
Background Jobs
Queued tasks processed later
Examples
- AI Image Generation: “I’m generating your image. This will take about 2 minutes…”
- Data Analysis: “I’m analyzing your file. I’ll send the results shortly…”
- External Lookups: “I’m checking our inventory system. One moment…”
- Report Generation: “I’m creating your report. I’ll notify you when it’s ready…”
Implementation
Step 1: Immediate Acknowledgment
Return an immediate response withasync: true:
Step 2: Background Processing
Your backend processes the request asynchronously:Step 3: Send Final Response
When processing completes, send the final response via the Conversation Messages API:Conversation Messages API
Send Message
Endpoint:POST /v1/conversations/{conversation_id}/messages
Authentication: Bearer token (API key)
Request Body:
Code Examples
Send async reply
Send async reply
- cURL
- JavaScript
- PHP
- Python
Send multiple updates
Send multiple updates
- JavaScript
- Python
Advanced Patterns
Progress Updates
Send multiple updates as work progresses:Error Handling
Handle errors gracefully during async processing:Timeout and Retries
Implement retries for API calls:Job Queue Pattern
Use a job queue for reliable async processing:User Experience Best Practices
Clear Communication
Set clear expectations in the interim message: Good:- “I’m generating your report. This will take about 2-3 minutes…”
- “Processing your video (typically takes 5 minutes)…”
- “Analyzing your data. I’ll send results in about 30 seconds…”
- “Please wait…”
- “Processing…”
- “Working on it”
Reasonable Timeouts
Don’t make users wait too long. If processing takes >5 minutes, consider:
- Email notification instead
- Webhook callback to user
- Dashboard where users can check status
Progress Indicators
If processing is long, send progress updates:Security Considerations
API Key Security
Server-Side Only
Never expose API keys in client-side code
Environment Variables
Store keys in environment variables
Rotate Regularly
Rotate API keys periodically
Least Privilege
Use keys with minimum required permissions
Conversation ID Validation
Always validate the conversation ID before sending messages:Troubleshooting
Messages Not Appearing
Check:- Conversation ID is correct
- API key has proper permissions
- Response status is 200 OK
- User hasn’t blocked the bot
- Channel is still connected
Duplicate Messages
Causes:- Job processed multiple times
- Retry logic without idempotency
- Multiple workers processing same job
Rate Limiting
Problem: Too many API calls in short time Solution:- Implement exponential backoff
- Queue messages locally
- Batch updates when possible
- Respect rate limits
Complete API Reference
View the full API specification with all endpoints, parameters, and response schemas.
Next Steps
Webhook Payload
Understand the payload format
Conversation API
Explore conversation management
Webhook Setup
Configure your integration