Back to Document Management & Filing

Developer Handover Pack

Everything needed to build the automation from scratch: current state, full agent specs, data flow, and the build stack.

4 pagesPDF · Technical
FS-DOC-04Technical

Developer Handover Pack

Document Management and Filing

[YourCompany.com] · Operations Department · Prepared by FullSpec · [Today's Date]

This document gives the FullSpec build team everything needed to construct, connect, and validate the Document Management and Filing automation. It covers the current-state step map with bottlenecks identified, full agent specifications with IO contracts, the end-to-end data flow trace, and the recommended build stack. The process owner side is responsible for confirming Drive folder structure, supplying sample documents for classifier tuning, and granting API credentials before build begins. FullSpec handles all build, integration, testing, and handover work.

01Process snapshot

Step
Name
Description
1
Check Inbox for New Attachments
Operations Coordinator opens Gmail and scans for messages with file attachments requiring saving to the shared drive. Time cost: 10 min/document.
2
Download Attachment to Local Device
Attachment is downloaded to a local folder before being moved, often creating a duplicate that lingers on the hard drive. Time cost: 3 min/document.
3
Identify Document Type and Relevant Party
Staff member reads the document or email context to decide document type (contract, invoice, HR form, compliance record) and who it relates to. Time cost: 8 min/document. BOTTLENECK.
4
Determine Correct Folder Destination
Based on document type and party, the correct subfolder path in the shared drive is identified. Requires knowledge of current folder structure. Time cost: 5 min/document.
5
Rename File to Match Naming Convention
File is manually renamed to follow team convention (e.g. ClientName_ContractType_YYYY-MM-DD), often applied inconsistently when the coordinator is busy or absent. Time cost: 4 min/document. BOTTLENECK.
6
Upload File to Correct Folder
Renamed file is dragged or uploaded to the correct folder in Google Drive. Time cost: 3 min/document.
7
Log Document in Notion Database
A row is added to the Notion database recording the file name, type, date, and responsible person. Time cost: 6 min/document.
8
Notify Relevant Team Member
A Slack message is sent to the document owner (account manager or finance lead) confirming the file is filed. Time cost: 3 min/document.
9
Handle Exceptions and Misfilings
Periodically a file is found in the wrong location or a naming error is flagged by a colleague and corrected manually. Time cost: 8 min/occurrence. BOTTLENECK.
Time cost summary: Total manual time per document cycle is approximately 50 minutes. At ~120 documents/month (roughly 30/week), this produces 5 manual hours lost per week and approximately 22 hours per 30-day period. Steps 1 through 9 are all manual today. The automation replaces steps 1 through 8 entirely for confidently classified documents. Step 9 (exception handling) is reduced but not eliminated: the classification agent flags ambiguous documents to a human rather than filing them silently, cutting the correction burden to under 8% of volume.
Developer Handover PackPage 1 of 4
FS-DOC-04Technical

02Agent specifications

Document Classification Agent

Reads the content of an incoming file attachment and its associated email context (subject line, sender address, email body) to determine the document type, extract the relevant party name, and identify the document date. When a DocuSign trigger fires, the agent reads the envelope metadata and completed PDF in place of email context. It produces a structured metadata object that the Filing and Routing Agent consumes. If classification confidence falls below the configured threshold, the agent routes to a Slack exception alert rather than passing metadata downstream. Estimated build time: 8 hours. Complexity: Moderate.

Trigger
New email attachment detected in monitored Gmail inbox OR DocuSign envelope status changes to 'completed'.
Tools
Gmail, DocuSign
Replaces steps
Steps 1, 2, 3 (inbox monitoring, attachment download, document type and party identification)
Estimated build
8 hours / Moderate
// Input
gmail.message.id          : string   // unique message identifier
gmail.message.subject     : string   // email subject line
gmail.message.from        : string   // sender address
gmail.message.body_text   : string   // plain-text email body
gmail.attachment.filename : string   // original filename
gmail.attachment.mime_type: string   // e.g. application/pdf
gmail.attachment.content  : base64   // raw file content
docusign.envelope_id      : string   // present when trigger is DocuSign
docusign.envelope_status  : string   // expected value: 'completed'
docusign.completed_pdf    : base64   // signed document content

// Output (on confident classification)
metadata.document_type    : string   // e.g. 'Invoice', 'Contract', 'HR Form', 'Compliance'
metadata.party_name       : string   // e.g. 'Acme Supplies Ltd'
metadata.document_date    : string   // ISO 8601, e.g. '2025-06-15'
metadata.confidence_score : float    // 0.0 to 1.0; threshold >= 0.75 to proceed
metadata.source           : string   // 'gmail' or 'docusign'
metadata.raw_filename     : string   // original filename passed downstream
metadata.file_content     : base64   // attachment content passed downstream

// On low confidence (score < 0.75)
exception.flag            : boolean  // true
exception.reason          : string   // human-readable explanation for Slack alert
exception.raw_filename    : string
exception.file_content    : base64
  • Gmail API tier requirement: Gmail must be on Google Workspace (Business Starter or above) to support the Gmail watch/push notification endpoint. Free Gmail accounts do not support server-side push and will require polling instead, which adds latency.
  • DocuSign trigger: Use the DocuSign Connect webhook (available on Standard plan and above). Confirm admin-level API credentials and Connect configuration access before build starts. Without admin access the webhook cannot be registered.
  • AI classification model: Use an LLM call (prompt-engineered) with the file content and email context as input. The prompt must include a defined list of accepted document_type values agreed with the operations team before build. Do not allow open-ended type inference.
  • Confidence threshold: The default confidence threshold is 0.75. This value must be exposed as a configurable parameter in the workflow so the operations team can adjust it without a code change.
  • Dedupe behaviour: Cache the gmail.message.id and docusign.envelope_id of each processed document in the error/state log. On re-trigger (e.g. Gmail webhook fires twice for the same message), check the cache and skip processing if the ID has already been handled.
  • Fallback on extraction failure: If the file content cannot be parsed (e.g. corrupted PDF, zero-byte attachment), the agent must route immediately to the exception Slack alert and log the failure. It must never pass empty metadata downstream.
  • Sample document requirement: At least 30 labelled sample documents covering all expected document types must be provided before the prompt can be tuned. Confirm availability with the operations team during Discovery.
Filing and Routing Agent

Receives the structured metadata object from the Document Classification Agent, constructs the standardised file name using the agreed naming convention, uploads the renamed file to the correct subfolder in Google Drive, creates a log entry in the Notion document register, and sends a Slack confirmation message to the relevant document owner. This agent also handles the exception branch: when the Classification Agent flags a low-confidence result, this agent posts a Slack alert to the Operations Coordinator with the original file attached and the reason for flagging, without filing anything automatically. Estimated build time: 10 hours. Complexity: Moderate.

Trigger
Document Classification Agent returns a metadata object with confidence_score >= 0.75, OR an exception flag with confidence_score < 0.75.
Tools
Google Drive, Notion, Slack
Replaces steps
Steps 4, 5, 6, 7, 8 (folder routing, file renaming, Drive upload, Notion logging, Slack notification) and reduces step 9 (exception handling) to human review of flagged documents only.
Estimated build
10 hours / Moderate
// Input (standard path)
metadata.document_type    : string   // from Classification Agent
metadata.party_name       : string
metadata.document_date    : string   // ISO 8601
metadata.confidence_score : float
metadata.source           : string
metadata.raw_filename     : string
metadata.file_content     : base64

// Input (exception path)
exception.flag            : boolean  // true
exception.reason          : string
exception.raw_filename    : string
exception.file_content    : base64

// Output (standard path)
drive.file_name           : string   // e.g. 'AcmeSupplies_Invoice_2025-06-15.pdf'
drive.folder_path         : string   // e.g. '/Clients/Acme Supplies/Invoices/2025'
drive.file_id             : string   // Google Drive file ID of uploaded document
drive.file_url            : string   // shareable Drive link
notion.page_id            : string   // ID of created Notion log entry
notion.database_id        : string   // target Notion database
slack.channel_id          : string   // channel or DM where confirmation posted
slack.message_ts          : string   // Slack message timestamp

// Output (exception path)
slack.alert_channel       : string   // Operations Coordinator channel or DM
slack.alert_message       : string   // includes filename, exception.reason, and file attachment
slack.alert_ts            : string
  • Google Drive folder mapping: A folder mapping table must be built and confirmed before this agent goes live. The table maps each document_type value to a Drive folder ID. Using folder IDs (not path strings) avoids breakage if folders are renamed. Store the mapping as a configuration object in the workflow, not hardcoded in the step logic.
  • Naming convention format: The agreed standard is PartyName_DocumentType_YYYY-MM-DD (e.g. AcmeSupplies_Invoice_2025-06-15). Spaces in party names must be stripped or replaced with underscores. Special characters must be sanitised before the filename is constructed.
  • Notion schema: The Notion document register database must include the following fields before integration: File Name (title), Document Type (select), Party Name (text), Document Date (date), Drive Link (url), Filed At (date, auto-populated), Source (select: gmail/docusign), Confidence Score (number). Confirm this schema is in place with the operations team before the Filing Agent build begins.
  • Slack owner routing: A lookup table mapping document_type to the Slack user ID of the relevant owner must be agreed and configured. For example, invoices route to the Finance Coordinator; HR forms route to the HR lead. This table must be populated before go-live.
  • Google Drive OAuth scope: Requires https://www.googleapis.com/auth/drive.file at minimum. If the build needs to browse existing folder structure programmatically, https://www.googleapis.com/auth/drive.readonly is also required. Confirm scopes with the workspace admin.
  • Notion integration token: Use an internal Notion integration token scoped to the document register database only. Do not use a full-workspace token. The token must be stored in the shared credential store, not in the workflow step configuration directly.
  • Idempotency on Drive upload: Before uploading, query the target folder for an existing file with the same constructed name. If a match exists, append a suffix (_v2, _v3) rather than overwriting silently. Log the duplicate detection event in the error table.
Developer Handover PackPage 2 of 4
FS-DOC-04Technical

03End-to-end data flow

Full trigger-to-output data flow: Document Management and Filing automation
// ─────────────────────────────────────────────────────────────────
// TRIGGER: New document event detected
// ─────────────────────────────────────────────────────────────────

EVENT_SOURCE: 'gmail' | 'docusign'

IF EVENT_SOURCE == 'gmail':
  gmail.message.id          -> dedupe_cache.check(message.id)
  gmail.message.subject     -> classification_agent.input.subject
  gmail.message.from        -> classification_agent.input.from_email
  gmail.message.body_text   -> classification_agent.input.body_text
  gmail.attachment.filename -> classification_agent.input.raw_filename
  gmail.attachment.mime_type-> classification_agent.input.mime_type
  gmail.attachment.content  -> classification_agent.input.file_content

IF EVENT_SOURCE == 'docusign':
  docusign.envelope_id      -> dedupe_cache.check(envelope_id)
  docusign.envelope_status  -> assert('completed')
  docusign.completed_pdf    -> classification_agent.input.file_content
  docusign.envelope_id      -> classification_agent.input.raw_filename

// ─────────────────────────────────────────────────────────────────
// AGENT HANDOFF 1: Classification Agent processes the document
// ─────────────────────────────────────────────────────────────────

classification_agent.input.file_content  -> llm_prompt.document_body
classification_agent.input.body_text      -> llm_prompt.email_context
classification_agent.input.from_email     -> llm_prompt.sender_hint

llm_prompt.response -> parse:
  metadata.document_type    : string   // 'Invoice' | 'Contract' | 'HR Form' | 'Compliance' | ...
  metadata.party_name       : string
  metadata.document_date    : string   // ISO 8601
  metadata.confidence_score : float    // 0.0 – 1.0

// ──────────────────────────────────────────────��──────────────────
// DECISION: Confidence threshold check
// ─────────────────────────────────────────────────────────────────

IF metadata.confidence_score >= 0.75:
  -> STANDARD PATH: pass to Filing and Routing Agent
ELSE:
  exception.flag        = true
  exception.reason      = llm_prompt.low_confidence_explanation
  exception.raw_filename= classification_agent.input.raw_filename
  exception.file_content= classification_agent.input.file_content
  -> EXCEPTION PATH: pass to Filing and Routing Agent (exception branch)

// ─────────────────────────────────────────────────────────────────
// AGENT HANDOFF 2: Filing and Routing Agent — standard path
// ─────────────────────────────────────────────────────────────────

// Step A: Construct standardised file name
metadata.party_name      -> sanitise(strip_spaces, remove_special_chars)
metadata.document_type   -> sanitise()
metadata.document_date   -> format('YYYY-MM-DD')
drive.file_name          = '{party_name}_{document_type}_{document_date}.pdf'
// e.g. 'AcmeSupplies_Invoice_2025-06-15.pdf'

// Step B: Resolve target Drive folder
folder_map[metadata.document_type] -> drive.folder_id
// folder_map is a config object: { 'Invoice': '1BxK...', 'Contract': '2CyL...' }

// Step C: Dedupe check before upload
drive.list_files(folder_id, query: drive.file_name)
IF match_found: drive.file_name += '_v{n}'

// Step D: Upload file to Google Drive
metadata.file_content    -> drive.upload(
  name     : drive.file_name,
  parent   : drive.folder_id,
  mimeType : 'application/pdf'
)
drive.file_id            <- upload_response.id
drive.file_url           <- upload_response.webViewLink

// Step E: Create Notion log entry
notion.create_page(
  database_id    : notion.database_id,
  'File Name'    : drive.file_name,
  'Document Type': metadata.document_type,
  'Party Name'   : metadata.party_name,
  'Document Date': metadata.document_date,
  'Drive Link'   : drive.file_url,
  'Filed At'     : now(),
  'Source'       : metadata.source,
  'Confidence'   : metadata.confidence_score
)
notion.page_id           <- create_page_response.id

// Step F: Send Slack confirmation to document owner
owner_map[metadata.document_type] -> slack.channel_id
slack.post_message(
  channel : slack.channel_id,
  text    : 'Filed: {drive.file_name} | Folder: {drive.folder_path} | {drive.file_url}'
)
slack.message_ts         <- post_message_response.ts

// ─────────────────────────────────────────────────────────────────
// AGENT HANDOFF 2 (exception branch): Filing and Routing Agent
// ─────────────────────────────────────────────────────────────────

slack.post_message(
  channel     : ops_coordinator.slack_user_id,
  text        : 'Unclassified document requires manual review.',
  attachments : exception.file_content,
  fields      : { filename: exception.raw_filename, reason: exception.reason }
)
error_log.insert(
  event_type  : 'classification_exception',
  filename    : exception.raw_filename,
  reason      : exception.reason,
  timestamp   : now()
)

// ─────────────────────────────────────────────────────────────────
// END OF FLOW
// ─────────────────────────────────────────────────────────────────
Developer Handover PackPage 3 of 4
FS-DOC-04Technical

04Recommended build stack

Orchestration layer
A workflow automation platform with native HTTP/webhook support, credential store, and branching logic. Build one workflow per agent (two workflows total): 'Document Classification' and 'Filing and Routing'. Both workflows share a single credential store holding all API keys and OAuth tokens. Do not embed credentials in step configurations. The Classification workflow calls the Filing workflow via an internal webhook or direct workflow trigger on completion.
Webhook configuration
Gmail: configure a Gmail push notification (Google Cloud Pub/Sub topic + subscription) pointed at the Classification workflow webhook URL. The Pub/Sub subscription must be renewed every 7 days; implement an auto-renewal step on a scheduled trigger. DocuSign: register a DocuSign Connect listener (HTTPS POST) on the envelope 'Completed' event, pointed at the same Classification workflow webhook URL. Use a shared secret header for request validation on both endpoints.
Templating approach
File name construction uses a string interpolation template: '{party_name}_{document_type}_{document_date}.{ext}'. The template is stored as a workflow-level variable so it can be updated without editing individual steps. Notion log entries use a field-mapping object defined at the workflow level. Slack messages use a short plain-text template with the file name and Drive URL interpolated. No external templating engine is required.
Error logging
All exceptions (low-confidence classifications, Drive upload failures, Notion API errors, Slack delivery failures) are written to a Supabase table named 'automation_error_log' with columns: id (uuid), event_type (text), workflow_name (text), error_message (text), payload_snapshot (jsonb), created_at (timestamptz). A Supabase database webhook or scheduled query alerts the operations Slack channel if more than 3 errors occur within any 60-minute window. The FullSpec team configures this table and alert rule during the Testing and QA stage.
Testing approach
All agent builds are tested in a sandbox environment first: a dedicated Gmail test inbox, a DocuSign sandbox account, a mirrored Google Drive folder tree under a '/TEST/' root, a duplicate Notion database marked '[TEST]', and a Slack test channel '#automation-qa'. No production Drive folders or the live Notion register are touched until end-to-end QA passes with real documents. Sandbox credentials are stored separately from production credentials in the credential store and swapped at go-live.
Estimated total build time
Document Classification Agent: 8 hours. Filing and Routing Agent: 10 hours. End-to-end integration testing and QA: 4 hours. Total: 22 hours across approximately 3 to 4 business weeks, consistent with the confirmed build effort in the project snapshot.
Pre-build blockers: Three items must be resolved before any build work begins. First, the Google Drive folder hierarchy must be standardised and folder IDs confirmed. Second, DocuSign admin-level API credentials and Connect configuration access must be granted. Third, a minimum of 30 labelled sample documents covering all expected document types must be provided for classifier prompt tuning. Work cannot proceed on the Classification Agent without the sample set, and the Filing Agent cannot be configured without confirmed Drive folder IDs. Raise these with the operations team at the Discovery and Drive Audit stage.
Support: For any build queries or handover questions, contact the FullSpec team at support@gofullspec.com.
Developer Handover PackPage 4 of 4

More documents for this process

Every document generated for Document Management & Filing.

Launch Plan
Operations · Owner
View
ROI and Business Case
Finance · Owner
View
Process Runbook / SOP
Operations · Owner
View
Integration and API Spec
Technical · Developer
View
Test and QA Plan
Quality · Developer
View