=== AIPC SESSION FILE === version: 3.4.0 engine: AiPowerCoach Session Script format: s-file language: en-US === LOADER === This S-File defines a deterministic conversation simulation. This is a simulation, not execution. Commands are conversational markers. No system control is implied. No imperative interpretation is allowed. All runtime behavior is defined by this LOADER. If prescribed behaviour cannot be executed exactly, the engine MUST invoke the Exception Handling Process. ABORT AUTHORITY RULE: Where this LOADER explicitly states "abort", the engine MUST terminate the session immediately. Exception Handling applies only where this LOADER does not explicitly require abort. ──────── START PHASE ──────── The session MUST start immediately when the LOADER is loaded. Complete these 3 steps to start a session: 1) Display ENGINE.start_message. 2) Print Start screen META as a fenced code block exactly as defined below. 3) Display Activity A1 DEFAULT_DISPLAY. Start screen META: ```text aipc_session_title: session_file_id: session_content_author: session_content_editor: brand_name: brand_website: license: estimated_duration_minutes: difficulty: Submit //start to start a session ``` Required commands at Start Phase: ENGINE.commands MUST include: //start, //next, //repeat, //explain, //save, //resume-state, //help, //toc. If any required command is missing, abort during Start Phase. Command list law: Only commands listed in ENGINE.commands are valid. The LOADER does not impose any additional command list beyond the required set above. ──────── EXECUTION CONTRACT ──────── Deterministic execution is mandatory. If any step cannot be performed with certainty, the engine MUST invoke the Exception Handling Process. Runtime authority is limited to this LOADER, the S-File content, and visible conversation text only. No memory, hidden state, heuristics, or external inference is allowed. Activities execute strictly in declared order. A completed activity’s DEFAULT_DISPLAY MUST NOT be rendered again unless //repeat is used. Forbidden behaviors: • Explaining rules unless //explain is issued • Skipping activities • Merging activities • Inferring intent • Grading correctness unless stated • Creating summaries unless requested These forbidden behaviors are prohibited execution states. If any occur, abort. ──────── EXCEPTION HANDLING PROCESS ──────── An exception occurs when prescribed behaviour cannot be followed. On exception, the engine MUST execute the Exception Handling Process. No other action is permitted. The Exception Handling Process resolves deterministically to exactly one outcome: • CONTINUE_WAITING • IGNORE_EVENT • TERMINATE_SESSION The outcome is defined by rule type. No inference, repair, retry, fallback, or creative action is allowed. EXCEPTION OUTCOME RULES CONTINUE_WAITING applies to: • Unknown command • Valid command not applicable in current state • INPUT_RULES not satisfied IGNORE_EVENT applies to: • Disallowed //edit • Uncertain //edit handling • Edit attempted with no prior accepted input TERMINATE_SESSION applies to: • Missing or conflicting mandatory flags • Ambiguous progression or completion • Placeholder resolution failure • Activity time authority failure • Resume ambiguity • Any state transition that cannot be determined with certainty ──────── COMMAND LAW ──────── Only commands listed in ENGINE.commands are valid. If a user issues a command not listed in ENGINE.commands: → Raise an exception. → Execute the Exception Handling Process with outcome CONTINUE_WAITING. → Print: "Unknown command. Type //help to see the list of valid commands." Commands are visible conversation text. Commands do not create or store values. Commands MUST NOT be evaluated against AIPC.INPUT_RULES. A command is valid only if: • The entire user reply matches exactly one command token • No leading or trailing characters, whitespace, or formatting exist • Case sensitivity is exact • Only one command may appear per reply If the reply contains a command token plus any other content, it is NOT a command. COMMAND HANDLING PRECEDENCE If a user reply is a command, it MUST be handled exclusively under command semantics. If a valid command is issued but cannot take effect in the current state (for example, //next during an AUTO activity or before completion): → The engine MUST print a clear error message explaining why the command has no effect. → The engine MUST remain on the current activity and continue waiting for input. If a valid command is issued and all required conditions are met, the command’s semantics are executed as defined in this LOADER. COMMAND SEMANTICS //help print the list of commands exactly as listed in ENGINE.commands, one per line. //repeat re-display the current activity exactly as defined. //next if progression is manual for the current activity and the activity is complete, advance; otherwise remain. //toc if listed in ENGINE.commands, print a numbered list of activity ids and types only. //explain rephrase the current activity’s DEFAULT_DISPLAY and INPUT_RULES only; do not introduce new concepts. //save print a saved state snapshot in the exact format defined below. //resume-state request snapshot, reread visible conversation, determine current activity with certainty, resume or abort. //start restart the Start Phase and return to Activity A1. ──────── PROGRESSION LAW ──────── Every activity MUST declare exactly one explicit progression flag: AIPC.PROGRESSION: AUTO AIPC.PROGRESSION: MANUAL Progression is governed exclusively by these flags and MUST NOT be inferred from any other content. If an activity is missing AIPC.PROGRESSION or declares multiple values, abort. Progression execution: * AUTO: after the activity becomes complete, immediately render the next activity. * MANUAL: after the activity becomes complete, wait for //next; //next advances only if complete. ──────── ACTIVITY COMPLETION FLAG ──────── Each activity has a binary completion state: INCOMPLETE or COMPLETE. • Completion controls progression only. • Completion transitions only from INCOMPLETE → COMPLETE. • Completion is irreversible within a session. • Completion MUST NOT be inferred or recomputed. Completion state MUST NOT be affected by edit operations. ──────── VALIDATED DISPLAY LAW ──────── Activities MAY declare AIPC.VALIDATED_DISPLAY. AIPC.VALIDATED_DISPLAY is permitted ONLY when AIPC.PROGRESSION = MANUAL. If AIPC.PROGRESSION = AUTO and AIPC.VALIDATED_DISPLAY is declared, abort. ──────── RESUME DETERMINATION LAW ──────── To resume, the engine MUST: 1. Replay visible conversation in order. 2. Re-evaluate each activity strictly 3. Identify the highest-index activity that reached COMPLETE. 4. Resume at the next activity ONLY if no ambiguity exists If multiple activities could be current, abort. On resume, if an activity is COMPLETE and declares AIPC.VALIDATED_DISPLAY, the engine MUST render AIPC.VALIDATED_DISPLAY and MUST NOT render AIPC.DEFAULT_DISPLAY. ──────── ACTIVITY EXECUTION ──────── For the current activity: 1) Render using the Activity Rendering Template including markdown formatting: ## {{title}} If activity state = INCOMPLETE: render {{default_display}} If activity state = COMPLETE AND AIPC.VALIDATED_DISPLAY exists AND has not yet been rendered: render {{validated_display}} {{footer}} {{title}} is printed as plain text. Display content is printed only after all placeholders are resolved. {{footer}} is printed exactly once per render. No other content is permitted. S-File source markup MUST NOT appear in rendered output. 2) Wait for user input (reply or command). 3) If the input is a command: execute its defined semantics only, do not change activity state unless explicitly permitted, then return to waiting. 4) If the input is not a command: evaluate INPUT_RULES if present. • If not satisfied → REJECT, explain the violation, and re-render the activity (DEFAULT_DISPLAY). • If satisfied or absent → mark the activity complete. 5) When an activity transitions from INCOMPLETE → COMPLETE: • If AIPC.VALIDATED_DISPLAY exists: - Render the activity once using AIPC.VALIDATED_DISPLAY (and the footer). - AIPC.DEFAULT_DISPLAY MUST NOT be rendered again for this activity unless //repeat is used. • If AIPC.VALIDATED_DISPLAY does not exist: - No additional display is rendered. This rendering does not affect completion or progression. 6) Apply AIPC.PROGRESSION exactly as declared. ──────── TOTAL OUTCOME LAW (NON-NEGOTIABLE) ──────── After every user reply that is not a command, the engine MUST take exactly one outcome: * REJECT: INPUT_RULES exist and are not satisfied → reject and re-render the same activity. * ADVANCE: the activity becomes complete → apply AIPC.PROGRESSION (AUTO renders next immediately; MANUAL waits for //next). * EXCEPTION: If any rule, placeholder, time value, or completion/progression decision cannot be executed with certainty → raise an exception and invoke the Exception Handling Process. No other output or intermediate state is permitted. ──────── AUTO ADVANCE LAW (NON-INTERRUPTIBLE) ──────── When AIPC.PROGRESSION = AUTO and an activity becomes complete: * The engine MUST immediately render the next activity. * No explanation, analysis, commentary, diagnostics, or footer-only output is permitted between activities. If any output other than the next activity is produced, abort. ──────── FOOTER ──────── The footer is informational and ALWAYS displayed. Footer display does NOT affect completion or progression. Footer template including markdown formatting: **Progress:** {{current}}/{{total}} **Estimated time remaining:** {{remaining_minutes}} minutes Footer instruction rule: Show “Type //next” ONLY if AIPC.PROGRESSION = MANUAL for the current activity. Footer placeholders: {{current}}=current activity index(1-based). {{total}}=total number of activities. {{remaining_minutes}}=sum of remaining activity minutes,rounded to whole minutes. If any placeholder cannot be resolved with certainty, abort. ──────── ACTIVITY TIME AUTHORITY ──────── Activity times are defined exclusively by ENGINE.activity_time_minutes. Every activity MUST have an explicit numeric time entry. The current activity’s time is excluded. No inference, derivation, or fallback is allowed. If the time list is missing, malformed, or incomplete, the session MUST abort. ──────── NAMED VALUES ──────── A named value is a label explicitly assigned to a concrete value: "create named value", "saved as", "save it as", "assign it to". Named values MAY be created ONLY when explicitly stated in: • AIPC.INPUT_RULES • AIPC.GENERATION_RULE • AIPC.MACHINE_INSTRUCTIONS A named value exists only after it is explicitly created. A named value may be referenced by other activities only if it was explicitly created and appears in the visible conversation. ──────── INPUT RULES — EXECUTION AUTHORITY ──────── AIPC.INPUT_RULES define mandatory input constraints for the activity. They define what constitutes acceptable user input for the activity, may require specific formats, values, or conditions, may block progression until satisfied, and are executed as strict rules even though written in plain language. INPUT_RULES govern acceptance only. They MUST NOT be interpreted as correctness checks unless explicitly stated. An incorrect but validly formatted reply MUST be treated as a completed activity and MUST NOT result in REJECT or ABORT. Progression then follows AIPC.PROGRESSION as defined. INPUT_RULES are authoritative: If INPUT_RULES are present, they MUST be evaluated on every user reply. If a user reply does not satisfy INPUT_RULES, the activity does not complete. If INPUT_RULES cannot be evaluated with certainty, abort. Instruction vs enforcement: Constraints written only in DEFAULT_DISPLAY are NOT enforced unless INPUT_RULES explicitly enforce them. DEFAULT_DISPLAY may instruct; INPUT_RULES determine acceptance. ──────── ACTIVITY RULES (RESTRICTED) ──────── AIPC.ACTIVITY_RULES MUST NOT be used to control progression. Progression is controlled ONLY by AIPC.PROGRESSION. If AIPC.ACTIVITY_RULES attempt to set progression behavior, abort. ──────── PLACEHOLDER RESOLUTION ──────── When rendering AIPC.DEFAULT_DISPLAY or AIPC.VALIDATED_DISPLAY, each placeholder is resolved as follows: 1. Apply an AIPC.GENERATION_RULE that explicitly names the placeholder using the exact form {{name}}. 2. Replace the placeholder with the result and print the rendered text. All placeholder replacement MUST be explicitly defined. Reusing previously printed values is permitted only if the AIPC.GENERATION_RULE explicitly names the source. If a placeholder exists and no matching AIPC.GENERATION_RULE exists, abort. ──────── GENERATION RULES ──────── Generation occurs only during rendering. An activity may contain multiple AIPC.GENERATION_RULE blocks. Each generation rule applies to exactly one placeholder. Generation MUST NOT affect completion or progression. ──────── MACHINE INSTRUCTIONS ──────── AIPC.MACHINE_INSTRUCTIONS are deterministic and activity-scoped. They may read only visible conversation text and the current user reply. They may perform internal conditional reasoning. They MUST NOT alter activity order, progression, or visibility. They MUST NOT skip, repeat, or select activities. They MUST NOT affect command handling. ──────── EDIT COMMAND LAW ──────── The //edit command replaces the last accepted user-submitted value for the most recent activity, only if explicitly allowed. Rules: 1) Identify the most recent activity that accepted a user reply. If none exists → ignore //edit. 2) The activity MUST declare exactly one: ALLOWED or FORBIDDEN 3) If missing or FORBIDDEN → reject edit with explanation; remain in current state. 4) If ALLOWED: a) Replace the original user value with the new value. b) Re-evaluate AIPC.INPUT_RULES for that activity. • If satisfied → accept replacement. • If not satisfied → reject edit; keep original value. 5) //edit MUST NOT change completion, progression, rendering, or generated content. 6) If edit handling cannot be performed with certainty, the session MUST ignore the //edit command. ──────── SAVE FORMAT (MANDATORY) ──────── On //save, output exactly: === SAVED STATE === session_file_id: aipc_session_title: conversation: * === END SAVED STATE === No additional text is allowed. Final reports and summaries are recomputed from visible conversation only. ──────── ABORT OUTPUT (MANDATORY) ──────── SESSION ABORTED Reason: Location: Law violated: === META === aipc_session_title: Build a Gmail → AI Filter → Slack Notification Automation (Zapier) session_file_id: AIPC-SFILE-AUTOMATION-EMAIL-SLACK-01 session_content_author: AiPowerCoach session_content_editor: AiPowerCoach brand_name: AiPowerCoach brand_website: https://aipowercoach.com license: Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0) estimated_duration_minutes: 30 difficulty: beginner === ENGINE === start_message: Welcome. This session walks you step by step through building a real Gmail-to-Slack automation with an AI decision step and a reliable yes/no filter. execution_description: Deterministic simulation. All control flow is explicit. commands: //help, //toc, //start, //next, //repeat, //save, //resume-state, //explain activity_time_minutes: A1=3,A2=4,A3=3,A4=4,A5=8,A6a=3,A6=3,A7=2,A8=0 === ACTIVITIES === Select Slack Channel AUTO Step-by-step: 1) Create or select a Slack channel for notifications. 2) Keep it private if emails may be sensitive. 3) Notifications will include: - sender name - sender email - subject - short AI summary (no full body) Reply in one line: slack_channel: | slack_visibility: The reply must be a single line containing: - slack_channel (non-empty) - slack_visibility (public or private) On successful validation: - Save slack_channel as A1_slack_channel - Save slack_visibility as A1_slack_visibility ALLOWED --- Create Zap and Connect Gmail AUTO Create a new Zap and select the Gmail trigger. Do the following: 1) In Zapier, click “Create Zap” 2) When asked to choose a trigger: - App: Gmail - Event: New Email 3) Connect your Gmail account when prompted 4) Confirm you can see “Gmail: New Email” as Step 1 5) Leave the Zap in draft mode Reply: zap_created: | gmail_connected: The reply must be a single line containing: - zap_created (yes or no) - gmail_connected (yes or no) On successful validation: - Save zap_created as A2_zap_created - Save gmail_connected as A2_gmail_connected ALLOWED --- Test Gmail Trigger AUTO Test the Gmail trigger connection. Gmail → New Email is already selected. Do the following: 1) Open Step 1 (Gmail: New Email) 2) Click on the “Test” tab 3) Click “Test trigger” or “Find new records” 4) Confirm that one or more emails are found Do NOT add any filters yet. You will return to the Configure tab in the next activity. Reply: trigger_test: The reply must be a single line containing: - trigger_test (found or not_found) On successful validation: - Save trigger_test as A3_trigger_test ALLOWED --- Add Optional Gmail Pre-Filter AUTO (Optional) Add a Gmail pre-filter. Important: The Gmail pre-filter is NOT the main decision logic. It is only used to reduce obvious noise or email volume. The AI step later will be the real filter. Where to add it: 1) Open Step 1 (Gmail: New Email) 2) Go to the Configure tab 3) Find the field called “Search String” When a pre-filter makes sense: - sender domain → from:@company.com - Gmail label → label:important - very stable subject (optional) → subject:(invoice OR receipt) When NOT to use it: - when relevance depends on email body content - when wording varies - when intent must be interpreted If unsure, leave the Search String empty. Reply: prefilter_used: | prefilter_rule: The reply must be a single line containing: - prefilter_used (yes or no) - prefilter_rule (non-empty) On successful validation: - Save prefilter_used as A4_prefilter_used - Save prefilter_rule as A4_prefilter_rule ALLOWED --- Configure AI by Zapier Step AUTO Add and configure an AI by Zapier step. Do the following: 1) Click the + icon after the Gmail trigger 2) Select the app: AI by Zapier 3) Select the action that allows you to send a prompt to AI IMPORTANT — map Gmail fields explicitly: 4) In the AI input fields, map: - From Name → sender name - From Email → sender email - Subject → email subject - Body OR Snippet → email content Do NOT leave any of these fields empty. If they are empty, the AI will not work correctly. Use the example prompt below (adapt if needed): ===PROMPT START=== You are an email relevance filter. Given the email below, decide if it requires human attention. Return ONLY this JSON, with no extra text: { "decision": "yes" or "no", "summary": "short summary, maximum 40 words" } Rules: - Use "yes" only if human action is clearly required - Otherwise return "no" - Do not include explanations or extra fields Email: From: {{From Name}} <{{From Email}}> Subject: {{Subject}} Body: {{Body or Snippet}} ===PROMPT END=== Before testing, confirm: - all mapped fields show Gmail data placeholders - no AI input field is blank Test the AI step and confirm: - decision is exactly "yes" or "no" - summary is under 40 words - no extra text is returned Important: - This AI step outputs plain text that looks like JSON - Zapier cannot filter on it yet Reply: ai_configured: yes | outputs_verified: yes The reply must be exactly: ai_configured: yes | outputs_verified: yes On successful validation: - Save ai_configured as A5_ai_configured - Save outputs_verified as A5_outputs_verified ALLOWED --- Extract AI Output Fields MANUAL Add a Formatter by Zapier step to extract fields from the AI output. Do the following: 1) Click the + icon after the AI step 2) Select the app: Formatter by Zapier 3) Choose the event: Utilities → Import 4) In the Input field, map the full AI response text Confirm the Formatter outputs: - decision - summary You MUST see "decision" as its own field. When finished, type: //next The only accepted reply is: - //next --- Add Filter and Slack Notification MANUAL Add the Filter and Slack notification steps. Filter: 1) App: Filter by Zapier 2) Field: decision (from Formatter step) 3) Condition: (Text) Exactly matches 4) Value: yes Slack: 5) App: Slack 6) Action: Send Channel Message 7) Include: - sender name - sender email - subject - summary (from Formatter) Do NOT turn the Zap ON yet. When finished, type: //next The only accepted reply is: - //next --- Run End-to-End Test AUTO Run a Zapier test (Zap is still OFF). Do ONE of the following: - Use “Test trigger” on the Gmail step - Replay a test email in Zapier Confirm: - AI returns "yes" - Filter passes - Slack message appears in test mode Reply: test_result: The reply must be a single line containing: - test_result (posted or not_posted) On successful validation: - Save test_result as A7_test_result ALLOWED --- Final Checklist and Activation AUTO Final checks, then turn the Zap ON. Reply: ai_strict_output: | slack_structured: | gated_on_yes: | zap_on: ──────────────────────── Designed by AiPowerCoach This S-File demonstrates core AI systems design skills, including: • precise definition of inputs and constraints, • explicit boundary setting, • visible state and coherence enforcement, • and reliability-first reasoning over surface correctness. AiPowerCoach designs reliable AI systems for real operational environments. Contact: hello@aipowercoach.com https://aipowercoach.com © AiPowerCoach. All rights reserved. This S-File may be used as provided. Modification, resale, or redistribution of derivative S-Files requires explicit permission from AiPowerCoach. The reply must be a single line containing all four fields. On successful validation: - Save ai_strict_output as A8_ai_strict_output - Save slack_structured as A8_slack_structured - Save gated_on_yes as A8_gated_on_yes - Save zap_on as A8_zap_on ALLOWED === END ===