Skip to content

Integration Examples

Integrate OpenComplai with popular platforms and services.

Zapier Integration

Automate Document Processing

Trigger: New email attachment
Step 1: Extract attachment
Step 2: Call OpenComplai API
  POST /api/v1/documents
  - title: from email subject
  - content: attachment content
Step 3: Store result
  - Save extracted data to Google Sheets
  - Send Slack notification

Zap Setup: 1. Trigger: "Gmail - New Attachment" 2. Action: "Webhooks - POST" - URL: https://api.opencomplai.com/v1/documents - Headers: Authorization: Bearer YOUR_API_KEY - Data: {"title": "{{subject}}", "content": "{{attachment}}"} 3. Action: "Google Sheets - Add Row" - Spreadsheet: Your tracking sheet - Values: {{document_id}}, {{title}}, Completed


Slack Integration

Get Document Summary in Slack

from slack_sdk import WebClient
from opencomplai import Client
import json

slack_client = WebClient(token="xoxb-your-token")
ocomplai_client = Client(api_key="sk_test_xyz...")

def handle_slack_command(ack, command, client):
    """Handle /summarize slash command."""
    ack()

    # Extract document URL from command
    doc_url = command['text']

    # For demo, use hardcoded doc ID
    doc_id = "doc_abc123"

    # Get document from OpenComplai
    doc = ocomplai_client.documents.get(doc_id)

    # Send summary to Slack
    slack_client.chat_postMessage(
        channel=command['channel_id'],
        blocks=[
            {
                "type": "header",
                "text": {"type": "plain_text", "text": f"📄 {doc.title}"}
            },
            {
                "type": "section",
                "text": {
                    "type": "mrkdwn",
                    "text": f"*Content:*\n{doc.content[:500]}..."
                }
            },
            {
                "type": "actions",
                "elements": [
                    {
                        "type": "button",
                        "text": {"type": "plain_text", "text": "View Full Document"},
                        "url": f"https://app.opencomplai.com/documents/{doc_id}"
                    }
                ]
            }
        ]
    )

Make (Zapier Alternative)

Connect OpenComplai to Cloud Storage

Trigger: New file in Google Drive
Step 1: Download file
  - Use Make's Google Drive module
Step 2: Create in OpenComplai
  - URL: https://api.opencomplai.com/v1/documents
  - Method: POST
  - Headers:
    - Content-Type: application/json
    - Authorization: Bearer [TOKEN]
  - Body:
    {
      "title": "{{filename}}",
      "content": "{{file_content}}"
    }
Step 3: Store metadata
  - Save to Airtable
  - Record: document ID, title, date processed

n8n Workflow

Complex Document Processing Pipeline

{
  "nodes": [
    {
      "name": "Trigger: File Upload",
      "type": "trigger",
      "operation": "wait_for_webhook"
    },
    {
      "name": "OpenComplai: Create Document",
      "type": "opencomplai",
      "operation": "documents.create",
      "parameters": {
        "title": "={{ $node['Trigger: File Upload'].json.filename }}",
        "content": "={{ $node['Trigger: File Upload'].json.content }}"
      }
    },
    {
      "name": "Wait for Processing",
      "type": "sleep",
      "parameters": {
        "duration": 5000  // 5 seconds
      }
    },
    {
      "name": "OpenComplai: Get Results",
      "type": "opencomplai",
      "operation": "documents.get",
      "parameters": {
        "id": "={{ $node['OpenComplai: Create Document'].json.id }}"
      }
    },
    {
      "name": "Airtable: Create Record",
      "type": "airtable",
      "operation": "create",
      "parameters": {
        "baseId": "appXYZ",
        "table": "Documents",
        "fields": {
          "Document ID": "={{ $node['OpenComplai: Get Results'].json.id }}",
          "Title": "={{ $node['OpenComplai: Get Results'].json.title }}",
          "Status": "={{ $node['OpenComplai: Get Results'].json.processing_status }}"
        }
      }
    },
    {
      "name": "Slack: Notify",
      "type": "slack",
      "operation": "postMessage",
      "parameters": {
        "channel": "#documents",
        "text": "Document processed: {{ $node['OpenComplai: Get Results'].json.title }}"
      }
    }
  ]
}

GitHub Actions Integration

Auto-Process Documentation Files

name: Process Documentation

on:
  pull_request:
    paths:
      - 'docs/**/*.md'

jobs:
  process:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'

      - name: Install dependencies
        run: |
          pip install opencomplai

      - name: Process documentation
        env:
          OPENCOMPLAI_API_KEY: ${{ secrets.OPENCOMPLAI_API_KEY }}
        run: |
          python scripts/process_docs.py

      - name: Comment on PR
        uses: actions/github-script@v6
        with:
          script: |
            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: '✅ Documentation files processed by OpenComplai'
            })

Script: scripts/process_docs.py

import os
from opencomplai import Client
from pathlib import Path

client = Client(api_key=os.getenv("OPENCOMPLAI_API_KEY"))

# Find all markdown files changed in PR
docs_path = Path("docs")
for md_file in docs_path.rglob("*.md"):
    content = md_file.read_text()

    # Create document in OpenComplai
    doc = client.documents.create(
        title=md_file.stem,
        content=content,
        metadata={"source": "github_actions", "path": str(md_file)}
    )

    print(f"✅ Processed: {md_file}{doc.id}")

API Gateway Integration

Kong API Gateway Rate Limiting

# Kong plugin configuration
services:
  - name: opencomplai-api
    url: https://api.opencomplai.com
    routes:
      - paths:
          - /documents
    plugins:
      - name: rate-limiting
        config:
          minute: 1000
          policy: local
      - name: oauth2
        config:
          scopes:
            - document.read
            - document.create

Database Integration

PostgreSQL Change Data Capture

-- Create replication slot
SELECT * FROM pg_create_logical_replication_slot('opencomplai_cdc', 'test_decoding');

-- Subscribe to document changes
SELECT lsn, data FROM pg_logical_slot_get_changes('opencomplai_cdc', NULL, NULL);

-- Example output:
-- 0/16B45A8 | BEGIN
-- 0/16B45A8 | table public.documents: INSERT: id[uuid]='123' content[text]='...'
-- 0/16B45A8 | COMMIT

Email Integration

Forward Emails as Documents

import imaplib
from opencomplai import Client

client = Client(api_key="sk_test_xyz...")

def process_inbox():
    """Forward emails to OpenComplai."""

    mail = imaplib.IMAP4_SSL("imap.gmail.com")
    mail.login("your-email@gmail.com", "app-password")
    mail.select("INBOX")

    # Search for unread emails
    _, message_numbers = mail.search(None, "UNSEEN")

    for num in message_numbers[0].split():
        _, msg_data = mail.fetch(num, "(RFC822)")
        email_body = msg_data[0][1].decode()

        # Create document from email
        doc = client.documents.create(
            title=f"Email {num}",
            content=email_body,
            metadata={"source": "email"}
        )

        print(f"✅ Processed email → {doc.id}")

        # Mark as read
        mail.store(num, '+FLAGS', '\\Seen')

# Schedule with APScheduler
from apscheduler.schedulers.background import BackgroundScheduler

scheduler = BackgroundScheduler()
scheduler.add_job(process_inbox, 'interval', minutes=5)
scheduler.start()

Real-World Use Case: Document Management System

Complete Integration Example

from fastapi import FastAPI, File, UploadFile
from opencomplai import Client
import asyncio

app = FastAPI()
ocomplai = Client(api_key="sk_test_xyz...")

@app.post("/upload")
async def upload_document(file: UploadFile = File(...)):
    """Upload and process document."""

    content = await file.read()
    content_str = content.decode('utf-8')

    # Create in OpenComplai
    doc = ocomplai.documents.create(
        title=file.filename,
        content=content_str
    )

    # Return immediately with processing status
    return {
        "id": doc.id,
        "title": doc.title,
        "status": "processing",
        "check_status_url": f"/documents/{doc.id}"
    }

@app.get("/documents/{doc_id}")
async def get_document(doc_id: str):
    """Get document and processing results."""

    doc = ocomplai.documents.get(doc_id)

    return {
        "id": doc.id,
        "title": doc.title,
        "status": doc.processing_status,
        "content": doc.content[:200]  # Preview
    }

# Usage
# curl -X POST http://localhost:8000/upload \
#   -F "file=@document.txt"