Skip to content
UsecaseBoard
← All use cases
hashnodeAssistant Development

Separate an assistant's action request from its WhatsApp reply

At a glance

Satvik Srivastava's Andro walkthrough separates Gemini's conversational text from structured actions before routing either output. This workflow is listed under Assistant Development, Structured Actions, Message Routing.

Agents / tools
Python, Gemini API, WhatsApp, Andro

SourceBuilding a tool for these workflows? See weekly rates.

What they did

1) Have a Python assistant with a Gemini client, a WhatsApp sender, and handlers for the actions it supports. Import re and json for response parsing. 2) Document each supported action and its JSON shape in the system instructions. Have Gemini put an action object inside <action> and </action> after its conversational reply. 3) Search the response with re.compile(r'<action>\s*(\{.*?})\s*</action>', re.DOTALL). If there is no match, return the original text and no action. Otherwise, strip the text before the match and decode match.group(1) with json.loads. 4) Send only the cleaned text to WhatsApp and pass the decoded dictionary to the appropriate action handler.

Worth knowing

This is one component of Andro, not a complete reminder service. The author's WhatsApp integration uses unofficial browser automation, and Gemini calls leave the local machine.

Save ideas in this browser. Upvotes count across the board.

Prompt excerpt

No prompt excerpt was provided by the source.

Sponsored

CodeBuddy

Tencent Cloud AI coding assistant for IDE and CLI.

Try CodeBuddy ↗
Explore all →