Configuration
Configure SQS connection and event routing through environment variables.AWS Credentials
.env
Global Queue Settings
.env
- Separate Queues Per Event
- Single Queue for All Events
- Per-Instance Queues
Create individual queues for each event type:Creates queues like:
.env
evolution_messages_upsert.fifoevolution_qrcode_updated.fifoevolution_connection_update.fifo
Available Events
Configure which events are sent to SQS:- Instance Events
- Message Events
- Contact Events
- Chat & Group Events
- Other Events
.env
Per-Instance Configuration
WhenSQS_GLOBAL_ENABLED=false, configure SQS for specific instances:
Queue Setup
Evolution API automatically creates SQS FIFO queues when enabled:1
Queue Creation
Queues are created with
.fifo suffix for ordered message delivery:2
FIFO Configuration
- FIFO: Ensures message ordering
- Content-based deduplication: Enabled for global queues
- Message deduplication ID: Set for per-instance queues
3
Message Grouping
Messages are grouped by:
- Global:
{server_name}-{event}-{instance} - Per-instance:
evolution
FIFO queues ensure messages are processed in the order they’re sent, which is critical for maintaining conversation context.
Large Payload Handling
SQS has a 256 KB message size limit. Evolution API automatically handles larger payloads:.env
How It Works
1
Size Check
Evolution API checks if the message exceeds
SQS_MAX_PAYLOAD_SIZE.2
S3 Upload
If too large, the payload is uploaded to S3 as a JSON file:
3
Reference Message
A small message is sent to SQS with the S3 URL:
4
Download in Consumer
Your consumer downloads the full payload from S3 when
dataType: "s3".Message Format
Messages sent to SQS have the following structure:Consuming Events
Examples of consuming events from SQS:AWS Lambda Integration
Process SQS events with AWS Lambda:Lambda Function
Configure your Lambda function with the SQS queue as an event source trigger.
Best Practices
1
Use Long Polling
Set
WaitTimeSeconds: 20 to reduce empty responses and costs:2
Set Appropriate Visibility Timeout
Ensure timeout is longer than your processing time:
3
Delete Messages After Processing
Always delete messages after successful processing to avoid reprocessing.
4
Handle Failures with Dead Letter Queue
Configure a DLQ in AWS console for messages that fail repeatedly.
5
Monitor Queue Depth
Set CloudWatch alarms for queue depth to detect processing issues.
Troubleshooting
Queue creation failed
Queue creation failed
- Verify AWS credentials have
sqs:CreateQueuepermission - Check AWS account limits for number of queues
- Ensure queue name is valid (alphanumeric and hyphens only)
- Review CloudWatch logs for detailed error messages
Messages not appearing in queue
Messages not appearing in queue
- Check that specific events are enabled in configuration
- Verify
SQS_ENABLED=true - Check Evolution API logs for SQS errors
- Verify instance is connected to WhatsApp
- Check AWS IAM permissions for
sqs:SendMessage
Large message errors
Large message errors
- Enable S3 integration:
S3_ENABLED=true - Verify S3 credentials and bucket permissions
- Check S3 bucket exists in the same region
- Review Evolution API logs for S3 upload errors
Messages processed multiple times
Messages processed multiple times
This is normal if processing fails or visibility timeout expires. Implement idempotency using message IDs.