Support Email Workflow
activeListens for new support emails, searches brain/code for answers, drafts responses, sends to admin via Telegram for approval, then sends email on accept.
Detailed Steps
· 13Received new_support_email event from IMAP trigger. Extract from, subject, body, messageId.
Search workspace brain using keywords from subject and body to find relevant knowledge about the AI Telegram Copier.
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.
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.
Generate a unique emailId (UUID v4).
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.
Pending response is stored in Telegram Support Handler's in-memory store at this point (send-draft endpoint persists it).
--- On callback (support_email_callback event) ---
Received support_email_callback event. Extract action, emailId, callbackQueryId, chatId.
Call GET /pending-response/:emailId on Telegram Support Handler to retrieve { draft, originalEmail, status }.
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 }.
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 }.
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 }.