ai_reply_suggestion
Generates an AI-suggested reply for a social media conversation based on context. Customize tone and language with optional system prompts.
Instructions
Get an AI-generated reply suggestion for a social media conversation.
The AI reads the conversation context and suggests an appropriate reply. You can customize the AI behavior with a system prompt.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| conversation_id | Yes | Conversation ID to suggest a reply for | |
| account_id | Yes | Social account ID | |
| system_prompt | No | Optional custom instructions for the AI (e.g., "Reply politely in Turkish, offer 10% discount") | |
| org_id | No | Organization ID (uses YAPARAI_ORG_ID env var if not provided) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/yaparai/tools/social.py:254-280 (handler)The main handler function for the ai_reply_suggestion tool. Takes conversation_id, account_id, system_prompt, and optional org_id, resolves the org, creates a YaparAIClient, and calls social_ai_reply API.
async def ai_reply_suggestion( conversation_id: str, account_id: str, system_prompt: str = "", org_id: str | None = None, ) -> dict: """ Get an AI-generated reply suggestion for a social media conversation. The AI reads the conversation context and suggests an appropriate reply. You can customize the AI behavior with a system prompt. Args: conversation_id: Conversation ID to suggest a reply for account_id: Social account ID system_prompt: Optional custom instructions for the AI (e.g., "Reply politely in Turkish, offer 10% discount") org_id: Organization ID (uses YAPARAI_ORG_ID env var if not provided) Returns: Dict with suggested_reply text. """ oid = resolve_org_id(org_id) client = YaparAIClient() return await client.social_ai_reply(oid, conversation_id, account_id, { "system_prompt": system_prompt, }) - src/yaparai/client.py:260-267 (helper)The client method social_ai_reply that sends a POST request to /api/enterprise/orgs/{org_id}/social/inbox/{conv_id}/ai-reply with account_id param and system_prompt in the JSON body.
async def social_ai_reply(self, org_id: str, conv_id: str, account_id: str, payload: dict) -> dict: """Get AI reply suggestion.""" return await self._request( "POST", f"/api/enterprise/orgs/{org_id}/social/inbox/{conv_id}/ai-reply", params={"account_id": account_id}, json=payload, ) - src/yaparai/server.py:80-81 (registration)Import of ai_reply_suggestion from yaparai.tools.social on line 80.
ai_reply_suggestion, ) - src/yaparai/server.py:166-166 (registration)Registration of ai_reply_suggestion as an MCP tool via mcp.tool(ai_reply_suggestion) on line 166.
mcp.tool(ai_reply_suggestion) - src/yaparai/tools/_org.py:6-18 (helper)Helper function resolve_org_id used by the handler to resolve the org_id from the parameter or YAPARAI_ORG_ID environment variable.
def resolve_org_id(org_id: str | None = None) -> str: """Return the org_id from parameter or YAPARAI_ORG_ID env var. Raises ValueError if neither is set. """ oid = org_id or YAPARAI_ORG_ID if not oid: raise ValueError( "Organization ID is required. Either pass org_id parameter " "or set the YAPARAI_ORG_ID environment variable. " "Use list_organizations() to find your org ID." ) return oid