Back to Openhands

External Integrations

enterprise/doc/architecture/external-integrations.md

1.7.03.5 KB
Original Source

External Integrations

OpenHands integrates with external services (GitHub, Slack, Jira, etc.) through webhook-based event handling:

mermaid
sequenceDiagram
    autonumber
    participant Ext as External Service
(GitHub/Slack/Jira)
    participant App as App Server
    participant IntRouter as Integration Router
    participant Manager as Integration Manager
    participant Conv as Conversation Service
    participant Sandbox as Sandbox

    Note over Ext,Sandbox: Webhook Event Flow (e.g., GitHub Issue Created)

    Ext->>App: POST /api/integration/{service}/events
    App->>IntRouter: Route to service handler
    Note over IntRouter: Verify signature (HMAC)

    IntRouter->>Manager: Parse event payload
    Note over Manager: Extract context (repo, issue, user)
    Note over Manager: Map external user → OpenHands user

    Manager->>Conv: Create conversation (with issue context)
    Conv->>Sandbox: Provision sandbox
    Sandbox-->>Conv: Ready

    Manager->>Sandbox: Start agent with task

    Note over Ext,Sandbox: Agent Works on Task...

    Sandbox-->>Manager: Task complete
    Manager->>Ext: POST result
(PR, comment, etc.)

    Note over Ext,Sandbox: Callback Flow (Agent → External Service)

    Sandbox->>App: Webhook callback
/api/v1/webhooks
    App->>Manager: Process callback
    Manager->>Ext: Update external service

Supported Integrations

IntegrationTrigger EventsAgent Actions
GitHubIssue created, PR opened, @mentionCreate PR, comment, push commits
GitLabIssue created, MR openedCreate MR, comment, push commits
Slack@mention in channelReply in thread, create tasks
JiraIssue created/updatedUpdate ticket, add comments
LinearIssue createdUpdate status, add comments

Integration Components

ComponentPurposeLocation
Integration RoutesWebhook endpoints per serviceenterprise/server/routes/integration/
Integration ManagersBusiness logic per serviceenterprise/integrations/{service}/
Token ManagerStore/retrieve OAuth tokensenterprise/server/auth/token_manager.py
Callback ProcessorHandle agent → service updatesenterprise/integrations/{service}/*_callback_processor.py

Integration Authentication

External Service (e.g., GitHub)
        │
        ▼
┌─────────────────────────────────┐
│ GitHub App Installation         │
│ - Webhook secret for signature  │
│ - App private key for API calls │
└─────────────────────────────────┘
        │
        ▼
┌─────────────────────────────────┐
│ User Account Linking            │
│ - Keycloak user ID              │
│ - GitHub user ID                │
│ - Stored OAuth tokens           │
└─────────────────────────────────┘
        │
        ▼
┌─────────────────────────────────┐
│ Agent Execution                 │
│ - Uses linked tokens for API    │
│ - Can push, create PRs, comment │
└─────────────────────────────────┘