agentleFS
AWSKnown publisherawslabs/social-messaging-agent-runtime-toolkit/recipes/voice-reply/AGENTS.md

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…

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
  1. Very specific:

    Import text_to_voice from the copied tool module into src/tools/__init__.py.

    line 14
  2. Very specific:

    Run inside socialagent_notify_context() so the outbound audio is queued and drained by the webhook after the turn.

    line 19

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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

SourceDestinationPurpose
tool.pysrc/tools/voice_reply.pytext_to_voice(text, language, voice_id) → Polly TTS → S3 → WhatsApp media id
skill.mdsrc/skills/voice_reply.mdAgent guidance on when to reply with audio vs text

Wiring steps

  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 a queued send ignores both.
  5. Run inside socialagent_notify_context() so the outbound audio is queued and drained by the webhook after the turn.

Required env vars

VariableRequiredPurpose
MEDIA_BUCKETyesS3 bucket for the MP3 (falls back to CONVERSATION_LOGS_BUCKET)
AWS_REGIONnoRegion for Polly/S3 clients (default us-east-1)
MEDIA_PREFIXnoOptional key prefix: <prefix>/voice/<uuid>.mp3

Required IAM actions

Agent runtime only needs:

  • polly:SynthesizeSpeech
  • s3:PutObject (on MEDIA_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_id defaults per language (Mia for es-MX, Joanna for en-US); only override it with a voice that supports the chosen language, or Polly rejects the call.
  • Polly neural voices for es-MX may be unavailable in some regions; verify the chosen voice_id before relying on it.
  • In dev mode (socialagent dev), text_to_voice skips Polly/S3 and returns {"audio_id": "dev-media-id"}.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.