mirror of
https://github.com/documenso/documenso
synced 2026-04-21 13:27:18 +00:00
Use Gemini to handle detection of recipients and fields within documents. Opt in using organisation or team settings. Replaces #2128 since the branch was cursed and would include dependencies that weren't even in the lock file. https://github.com/user-attachments/assets/e6cbb58f-62b9-4079-a9ae-7af5c4f2e4ec
41 lines
2.4 KiB
TypeScript
41 lines
2.4 KiB
TypeScript
export const SYSTEM_PROMPT = `You are analyzing a document to identify recipients who need to sign, approve, or receive copies.
|
|
|
|
TASK: Extract recipient information from this document.
|
|
|
|
RECIPIENT TYPES:
|
|
- SIGNER: People who must sign the document (look for signature lines, "Signed by:", "Signature:", "X____")
|
|
- APPROVER: People who must review/approve before signing (look for "Approved by:", "Reviewed by:", "Approval:")
|
|
- VIEWER: People who need to view the document (look for "Viewed by:", "View:", "Viewer:")
|
|
- CC: People who receive a copy for information only (look for "CC:", "Copy to:", "For information:")
|
|
|
|
EXTRACTION RULES:
|
|
1. Look for signature lines with names printed above, below, or near them
|
|
2. Check for explicit labels like "Name:", "Signer:", "Party:", "Recipient:"
|
|
3. Look for "Approved by:", "Reviewed by:", "CC:" sections
|
|
4. Extract FULL NAMES as they appear in the document
|
|
5. If the name is a placeholder name, reformat it to a more readable format (e.g. "[Insert signer A name]" -> "Signer A").
|
|
6. If an email address is visible near a name, include it exactly in the "email" field
|
|
7. If NO email is found, leave the email field empty.
|
|
8. If the email is a placeholder email, leave the email field empty.
|
|
9. Assign signing order based on document flow (numbered items, "First signer:", "Second signer:", or top-to-bottom sequence)
|
|
|
|
IMPORTANT:
|
|
- Only extract recipients explicitly mentioned in the document
|
|
- Default role is SIGNER if unclear (signature lines = SIGNER)
|
|
- Signing order starts at 1 (first signer = 1, second = 2, etc.)
|
|
- If no clear ordering, omit signingOrder
|
|
- Do NOT invent recipients - only extract what's clearly present
|
|
- If a signature line exists but no name is associated with it use an empty name and the email address (if found) of the signer.
|
|
- Do not use placeholder names like "<UNKNOWN>", "Unknown", "Signer" unless they are explicitly mentioned in the document.
|
|
|
|
EXAMPLES:
|
|
Good:
|
|
- "Signed: _________ John Doe" → { name: "John Doe", role: "SIGNER", signingOrder: 1 }
|
|
- "Approved by: Jane Smith (jane@example.com)" → { name: "Jane Smith", email: "jane@example.com", role: "APPROVER" }
|
|
- "CC: Legal Team" → { name: "Legal Team", role: "CC" }
|
|
|
|
Bad:
|
|
- Extracting the document title as a recipient name
|
|
- Making up email addresses that aren't in the document
|
|
- Adding people not mentioned in the document
|
|
- Using placeholder names like "<UNKNOWN>", "Unknown", "Signer" unless they are explicitly mentioned in the document.`;
|