⚠️ These setup steps are performed manually in the AWS Console. Terraform does not currently configure SES receiving rules.
- Go to S3 → Create bucket
- Name it something like
needl-email-inbox - Leave most settings as default, but ensure Block all public access is enabled
- Go to IAM → Roles → Create role
- Choose SES as the trusted service
- Attach the AmazonS3FullAccess policy (or create a minimal policy scoped to your bucket)
- Name the role something like
SESToS3WriteRole - Save the Role ARN — you’ll need it in the SES rule setup
- Go to SES → Email Receiving → Rule Sets
- Create a new rule set
- Add a new rule with the following:
- Recipients: leave blank for all emails or specify (e.g.,
@yourdomain.com) - Actions:
- Choose S3
- Select the S3 bucket you created earlier (e.g.,
needl-email-inbox) - Use the IAM role you created that grants SES write permissions
- Recipients: leave blank for all emails or specify (e.g.,
- Make sure the rule set is activated so SES begins processing email
- Go to Route 53 → Hosted Zones → yourdomain.com
- Create an MX record:
10 inbound-smtp.us-east-1.amazonaws.com.
- Send an email to your domain (e.g.,
[email protected]) - Confirm the email appears in the S3 bucket
To enable Telegram to send messages to your webhook Lambda, you must register your Lambda URL with Telegram's setWebhook API.
curl -X POST "https://api.telegram.org/bot<YOUR_BOT_ID>/setWebhook" -d "url=<YOUR_FUNCTION_URL>"flowchart TD
Gmail[Gmail] -.forward.-> SES
SES[SES] --> S3Inbox[[S3<br/><i>Raw</i>]]
S3Inbox --> SQSInbox([SQS])
SQSInbox --> LambdaSanitizer[Lambda<br/><i>Sanitizer</i>]
LambdaSanitizer --> S3Sanitized[[S3<br/><i>Sanitized</i>]]
LambdaSanitizer -->|write user_emails| Dynamo[(DynamoDB)]
S3Sanitized --> SNSSanitized([SNS])
SNSSanitized --> SQSSanitized([SQS])
SQSSanitized --> LambdaClassifier[Lambda<br/><i>Email Classifier</i>]
LambdaClassifier -->|read users| Dynamo
LambdaClassifier --> Bedrock[Bedrock]
LambdaClassifier --> SQSClassified([SQS])
LambdaClassifier --> SQSGmailAllow([SQS])
SQSGmailAllow --> LambdaGmailAllow[Lambda<br/><i>Gmail Allow Forward</i>]
LambdaGmailAllow -.-> Gmail
SQSClassified --> LambdaChat[Lambda<br/><i>Chat Agent</i>]
LambdaNotifier -->|read users.telegram_id| Dynamo
LambdaNotifier -.-> Telegram[Telegram Bot]
Telegram -.->|ingest user messages| LambdaWebhook[Lambda<br/><i>Webhook</i>]
LambdaWebhook -->|write link record| Dynamo
LambdaWebhook --> SQSClassified
LambdaChat -->|get bot response| Bedrock
LambdaChat -->|write chat history| Dynamo
LambdaChat --> SQSChat([SQS])
SQSChat --> LambdaNotifier[Lambda<br/><i>Notifier</i>]