Skip to main content
AWS SQS (Simple Queue Service) integration enables you to stream WhatsApp events to SQS FIFO queues for serverless architectures, Lambda functions, and AWS-native applications.

Configuration

Configure SQS connection and event routing through environment variables.

AWS Credentials

.env
Never commit AWS credentials to version control. Use environment variables or AWS IAM roles when running on EC2/ECS.

Global Queue Settings

.env
Create individual queues for each event type:
.env
Creates queues like:
  • evolution_messages_upsert.fifo
  • evolution_qrcode_updated.fifo
  • evolution_connection_update.fifo

Available Events

Configure which events are sent to SQS:
.env

Per-Instance Configuration

When SQS_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".
If S3 is not enabled and a message exceeds the size limit, it will be dropped with an error logged.

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.
FIFO queues have a limit of 3,000 messages per second with batching. For higher throughput, consider using standard queues (but lose ordering guarantees).

Troubleshooting

  1. Verify AWS credentials have sqs:CreateQueue permission
  2. Check AWS account limits for number of queues
  3. Ensure queue name is valid (alphanumeric and hyphens only)
  4. Review CloudWatch logs for detailed error messages
  1. Check that specific events are enabled in configuration
  2. Verify SQS_ENABLED=true
  3. Check Evolution API logs for SQS errors
  4. Verify instance is connected to WhatsApp
  5. Check AWS IAM permissions for sqs:SendMessage
  1. Enable S3 integration: S3_ENABLED=true
  2. Verify S3 credentials and bucket permissions
  3. Check S3 bucket exists in the same region
  4. Review Evolution API logs for S3 upload errors
This is normal if processing fails or visibility timeout expires. Implement idempotency using message IDs.