Openpieces logoopenpieces
Back to workflows

Support Email Workflow

active

Listens for new support emails, searches brain/code for answers, drafts responses, sends to admin via Telegram for approval, then sends email on accept.

Sydney3 pieces0 tasksPublished 5/24/2026 · 7d ago

Detailed Steps

· 13
1

Received new_support_email event from IMAP trigger. Extract from, subject, body, messageId.

2

Search workspace brain using keywords from subject and body to find relevant knowledge about the AI Telegram Copier.

3

If brain results are insufficient, call GET /repo/search on Git Code Controller with query composed from subject + body keywords scoped to org:munashesydney. Read relevant files via GET /repo/file to gather context from the codebase.

4

Compose a helpful draft response addressing the user's support issue. Be specific — reference actual code/config/features from the brain or code search. Keep responses short and conversational. NO markdown (no **bold**, no *italic*, no backticks). NO divider lines like -- or ---. Use human-like natural language — avoid AI-sounding phrases like 'I hope this helps', "Please don't hesitate", 'Rest assured'. Write like a real person would.

5

Generate a unique emailId (UUID v4).

6

Call POST /send-draft on Telegram Support Handler with { emailFrom, emailSubject, draftResponse, emailId, workflowId: '8e5da368-cd2f-48c4-9661-7fadef04d146', includeButtons: true }. Do NOT pass chatId — the service reads ADMIN_CHAT_ID (8050367545) from its own env vars.

7

Pending response is stored in Telegram Support Handler's in-memory store at this point (send-draft endpoint persists it).

8

--- On callback (support_email_callback event) ---

9

Received support_email_callback event. Extract action, emailId, callbackQueryId, chatId.

10

Call GET /pending-response/:emailId on Telegram Support Handler to retrieve { draft, originalEmail, status }.

11

If action is accept: Call POST /send on Email Sender with { to: originalEmail.from.email, subject: 'Re: ' + originalEmail.subject, body: draft, inReplyTo: originalEmail.messageId }. Follow the same tone rules: short, no markdown, no dividers, human-like. Then send confirmation to admin via POST /send-draft on Telegram Support Handler with { emailFrom: originalEmail.from.email, emailSubject: '✅ Email sent', draftResponse: '✅ Email sent successfully!', emailId, workflowId: '8e5da368-cd2f-48c4-9661-7fadef04d146', includeButtons: false }.

12

If action is reject: Send admin a Telegram message via POST /send-draft on Telegram Support Handler with { emailFrom: '', emailSubject: '❌ Rejected', draftResponse: '❌ Response rejected — no email sent.', emailId, workflowId: '8e5da368-cd2f-48c4-9661-7fadef04d146', includeButtons: false }.

13

If action is edit: Send admin a Telegram message via POST /send-draft on Telegram Support Handler with { emailFrom: '', emailSubject: '✏️ Edit mode', draftResponse: '✏️ Edit mode active. Reply to this message with your revised response.', emailId, workflowId: '8e5da368-cd2f-48c4-9661-7fadef04d146', includeButtons: false }.