MODULE 17 · 5 HOUR BUILD
Channel inbox and response router
Build a normalized inbox that admits one job per namespaced event and prepares channel-specific response drafts. The seed uses local envelopes and sends no messages.
Build evidence Record your actual checks, results, and limitations.
Build it in stages
- Define normalized envelopes and capability records for Slack, Discord, and WhatsApp.
- Implement per-platform request verification behind separate adapters.
- Persist inbox admission and namespaced event uniqueness in one transaction.
- Render response drafts with native reply context and a text fallback.
- Add playback trace tests for a voice adapter and document distinct cancellation scopes.
Your acceptance criteria
Use these as your project review. Record commands, outputs, and failure cases in your repository.
- Duplicate delivery creates one job for a given platform and tenant.
- Identical native IDs in different platforms remain distinct.
- Transport receipts do not trigger agent reasoning.
- All outbound records are drafts until the authorized sender path executes them.
A working starting point
The seed runs as supplied. Extend it to satisfy the full brief. It is a teaching starting point, not a finished portfolio submission.
main.py
python
import json
from collections import deque
CAPABILITIES = {'slack': {'rich': True}, 'discord': {'rich': True},
'whatsapp': {'rich': False}}
class Inbox:
def __init__(self):
self.seen = set()
self.jobs = deque()
def admit(self, event):
if event['kind'] != 'message':
return 'ignored'
key = (event['platform'], event['tenant'], event['event_id'])
if key in self.seen:
return 'duplicate'
self.seen.add(key)
self.jobs.append(dict(event))
return 'admitted'
def drafts(self):
output = []
while self.jobs:
event = self.jobs.popleft()
rich = CAPABILITIES[event['platform']]['rich']
output.append({'platform': event['platform'], 'tenant': event['tenant'],
'conversation': event['conversation'], 'status': 'draft',
'format': 'components' if rich else 'text',
'text': 'Received: ' + event['text']})
return output
def main():
inbox = Inbox()
base = {'platform': 'slack', 'tenant': 'A', 'event_id': 'e1',
'conversation': 'c1', 'kind': 'message', 'text': 'status'}
for event in [base, base, dict(base, platform='whatsapp')]:
print(inbox.admit(event))
for draft in inbox.drafts():
print(json.dumps(draft, sort_keys=True))
if __name__ == '__main__':
main()
Push it further
Add a fault-injection matrix spanning inbox commit, acknowledgment, worker completion, and uncertain outbound delivery, with recovery evidence for every boundary.