# Executing approved proposals Reached from step 4 of `SKILL.md`. Rule 7 of the approval protocol in `/home/sascha.koenig/ap/PM/.okf/processes/it-basecamp-regeln.md` says what is allowed; this file is the mechanics. The Zammad calls named in `code` are specified in `/home/sascha.koenig/ap/PM/.okf/systems/zammad.md` ("Aufrufe für `lead-inbox`"); use them exactly as written there. ## Order per thread 1. Create the ticket or to-do (or the internal note on an existing ticket). 2. Read it back: the ticket number or to-do URL exists. 3. Send the notice or reply, with the real number or link. 4. Move or archive every mail of the thread. Work through the list in number order. A failing step ends that thread only: skip its remaining steps, leave its mails in the inbox, go on with the next item. Report the command, the error, and what already exists (ticket number, to-do URL), so the next run finds it through `dublette_suchen` and sends only the notice instead of creating a second ticket. ## Find the mail again before every mail action Cache numbers are not stable: every `search_emails` renumbers. Before a reply, move, archive or categorize: 1. `search_emails` for the mail's calendar day (`folder='Inbox'`, `inference_classification='all'`). 2. Read the page holding the mail with `browse_email_cache`. 3. Compare received time, sender and subject with the approved proposal. All three match → use that cache number. Otherwise do nothing to this thread and report it. Run no other `search_emails` between finding the mail and acting on it. Several mails of one day can be found in one fetch and handled in a row. **Batch items without browsing.** For a batch item whose mails share a sender or a subject fragment, let the search do the selecting: `search_emails(folder='Inbox', inference_classification='all', search_type='sender'|'subject', query='
', start_date=…, end_date=…)`. The cache then holds only those mails, numbered 1..`count`. Compare `count` with the number in the approved proposal: equal → act on all numbers; different → do nothing and report the count found (a new mail has arrived, or one is gone). This replaces the three-way comparison for batch items only; replies and tickets always use it. Give `end_date` as an explicit time (`'T23:59'`); `'now'` sometimes fails with a Graph filter error. With `move_single`, go through the numbers in descending order. ## Zammad ticket 1. `kunde_suchen` with the sender's address (for a shared mailbox: the person from the signature). Exactly one hit is needed. No hit for an internal sender → `customer_id: "guess:
"`, shown as such in the proposal. Several hits → `Für dich:`. 2. `dublette_suchen` for that customer. An open ticket on the same matter → no new ticket; the proposal is `notiz_anlegen` with the mail's content on that ticket. 3. Attachments: `get_email_content(cache_number=, download_attachments=true, download_path='/')`. Take only attachments with `isInline: false`. Base64-encode each into the article. Empty the directory after the thread is done. 4. `ticket_anlegen`: title from the matter (plain, no prefix); group `IT`; no owner, the IT triage bot assigns owner and priority. Article body in HTML: one line "Per Mail an Sascha König am , von ", then the original mail text unchanged. 5. Read back with `GET tickets/?expand=true`: customer, group `IT`, article count; attachments via `GET ticket_articles/by_ticket/`. Zammad rewrites the title shortly after creation, so refer to the ticket by number. Zammad sends the customer no confirmation for API tickets. The redirect notice is the only message the sender gets. ## Basecamp to-do Load the `basecamp` skill; check flags with `basecamp todos create --agent --help`. ```bash basecamp todos create "" --in [--todoset ] --list \ --assignee --due YYYY-MM-DD --description - [--attach …] --json < ``` - Title plain. Description (Markdown, from a scratchpad file so umlauts survive): one context sentence, the core of the mail, "Per Mail von am ", then the AI marker. - Target: the project the mail clearly belongs to; 👥 IT (one of the six lists) for team work; otherwise 🔒 Meins. IDs from `systems/basecamp.md`; projects with several to-do sets need `--todoset`. - Owner and due date come from the approval. Without both, create nothing. The owner must be a member of the project (`basecamp people list --in `), otherwise the item is a `Für dich:` point. - Read back with `basecamp todos show --json`: assignee, due date, attachments. ## Redirect notice A reply to the original mail, in `sascha-internal-communication-style`. Decide the form while drafting in step 3 of `SKILL.md`: - **Full form** (first notice to this person in 30 days): where the matter moved (ticket number, or to-do with owner and due date), why it is better kept there, and the request to file such matters there directly in future (`https://tickets.az-gruppe.com`, or the Basecamp project). - **Short form:** where it moved, number or link. No reason, no request. - Which one: `search_emails(folder='Sent Items', search_type='body', query='tickets.az-gruppe.com', days=30)`, then the same with `query='3.basecamp.com'`. The person appears in `to` of a hit → short form. - A Basecamp link only for people with access to the project; otherwise name owner and due date in the text and leave the link out. - Recipients: the sender. Keep the original Cc when that round followed the matter. Model for tone, full form, Zammad: ```md Hallo , dein Anliegen zu habe ich in unser Helpdesk umgezogen, es läuft dort jetzt als Ticket #. Über das Ticket bekommst du auch die Rückmeldungen. Hintergrund: Anfragen an die IT bearbeiten wir im Helpdesk, damit nichts in einem einzelnen Postfach liegen bleibt und immer jemand aus dem Team übernehmen kann. Mein Vorschlag: Stell solche Anliegen künftig direkt dort ein, über https://tickets.az-gruppe.com. Dann sparst du dir den Umweg über mich. Viele Grüße Sascha *✨unterstützt durch KI✨* ``` ## Sending `send_email(action='reply', cache_number=, htmlbody='<…>')`. Set `to` / `cc` only when the proposal differs from the original recipients. - The text is the approved one, character for character; only the ticket number or link is filled in. - HTML: `

` per paragraph, nothing between the tags, `
` only inside the closing ("Viele Grüße
Sascha"). Last paragraph: `

✨unterstützt durch KI✨

`. - Success means `success: true` and `sent_count` ≥ 1. Anything else is a failed step. ## Moving mails | Action | Call | |---|---| | Into a folder | `manage_emails(action='move_single', cache_number=, destination_folder='Inbox/')` | | Archive | `manage_emails(action='archive_multiple', cache_numbers=[…])` | | Mark an approval | `manage_emails(action='categorize_single', cache_number=, categories=['Freigabe'])` | Batch items: find all mails of one day, act on them in one call, then the next day. Read back per day with one more fetch: the moved mails are no longer in `Inbox`.