social-messaging-agent-runtime-toolkit / voice-reply
AGENTS.md4 starsChanged 8 days agoApache-2.0View on GitHub
AI-optimized wiring guide. Goal: reply with a Polly-synthesized WhatsApp voice note. 1. Import text_to_voice from the copied tool module into src/tools/__init__.py. 2. Define a Strands tool (e.g. voice_reply) with @tool(context=True). 3. await text_to_voice(text, language=...) (it is async). If the result has "error", raise ValueError(result["error"]). 4. Send the audio with the payload wrapper (required — notify.send_message reads message["payload"]): await notify.send_message(phone, {"type": "audio", "payload": {"audio": {"id": result["audio_id"]}}}) using tool_context.invocation_state.get("phone", ""). Pass no log_to_memory or memory_text: the send is queued (step 5), and…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository14 other files it gives its agents.
- AGENTS.mdAGENTS.md
- blueprints/appointment-scheduler/AGENTS.mdAGENTS.md
- blueprints/minimal/AGENTS.mdAGENTS.md
- blueprints/personal-assistant/AGENTS.mdAGENTS.md
- recipes/generate-image/AGENTS.mdAGENTS.md
- recipes/rich-messages/AGENTS.mdAGENTS.md
- socialagent-admin-console/AGENTS.mdAGENTS.md
- blueprints/appointment-scheduler/CLAUDE.mdCLAUDE.md
- blueprints/minimal/CLAUDE.mdCLAUDE.md
- blueprints/personal-assistant/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- image_generationSkill
- rich_messagesSkill
- voice_replySkill
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Import text_to_voice from the copied tool module into src/tools/__init__.py.
- Very specific: line 19
Run inside socialagent_notify_context() so the outbound audio is queued and drained by the webhook after the turn.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — voice-reply recipe
AI-optimized wiring guide. Goal: reply with a Polly-synthesized WhatsApp voice note.
Files copied by socialagent recipe add voice-reply
| Source | Destination | Purpose |
tool.py | src/tools/voice_reply.py | text_to_voice(text, language, voice_id) → Polly TTS → S3 → WhatsApp media id |
skill.md | src/skills/voice_reply.md | Agent guidance on when to reply with audio vs text |
Wiring steps
- Import
text_to_voicefrom the copied tool module intosrc/tools/__init__.py. - Define a Strands tool (e.g.
voice_reply) with@tool(context=True). await text_to_voice(text, language=...)(it is async). If the result has"error",raise ValueError(result["error"]).- Send the audio with the
payloadwrapper (required —notify.send_messagereadsmessage["payload"]):await notify.send_message(phone, {"type": "audio", "payload": {"audio": {"id": result["audio_id"]}}})usingtool_context.invocation_state.get("phone", ""). Pass nolog_to_memoryormemory_text: the send is queued (step 5), and a queued send ignores both. - Run inside
socialagent_notify_context()so the outbound audio is queued and drained by the webhook after the turn.
Required env vars
| Variable | Required | Purpose |
MEDIA_BUCKET | yes | S3 bucket for the MP3 (falls back to CONVERSATION_LOGS_BUCKET) |
AWS_REGION | no | Region for Polly/S3 clients (default us-east-1) |
MEDIA_PREFIX | no | Optional key prefix: <prefix>/voice/<uuid>.mp3 |
Required IAM actions
Agent runtime only needs:
polly:SynthesizeSpeechs3:PutObject(onMEDIA_BUCKET)
The S3 → WhatsApp upload runs in the notification Lambda via notify.upload_media, so the agent runtime needs no socialmessaging permission (only src/socialagent/providers/eum_social.py, inside the notification Lambda, calls socialmessaging).
Notes
- Output must be MP3 — WhatsApp rejects OGG.
voice_iddefaults per language (Mia for es-MX, Joanna for en-US); only override it with a voice that supports the chosenlanguage, or Polly rejects the call.- Polly neural voices for
es-MXmay be unavailable in some regions; verify the chosenvoice_idbefore relying on it. - In dev mode (
socialagent dev),text_to_voiceskips Polly/S3 and returns{"audio_id": "dev-media-id"}.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

