Skip to content

membranehq/self-integrating-agent-example

Repository files navigation

🤖 Self-Integrating AI Agent Example

A complete, runnable example of an AI agent that builds its own integrations at runtime

No prebuilt connectors. No manual wiring. Just intent → action.

📖 Read the Self-Integration Manifesto


Hero Image


Quick Navigation:
🚀 Quick Start · 🧠 How It Works · 🛠 Tools · 🖥 UI Components


Star this repo and make your agents compatible with anything your customers need


What is a Self-Integrating Agent?

A self-integrating AI agent can:

  • Connect to external applications (CRM, task managers, communication tools, etc.)
  • Discover and use available actions (create tasks, send messages, fetch data)
  • Automatically build missing integrations via Membrane Agent delegation

This example provides a working implementation using:

🚀 Quick Start

⏱️ Time to first integration: ~2 minutes

1. Install Dependencies

npm install

2. Configure Environment

Copy .env.example to .env.local and fill in your credentials:

cp .env.example .env.local

Required variables:

  • MEMBRANE_WORKSPACE_KEY - Get from Membrane
  • MEMBRANE_WORKSPACE_SECRET - Get from Membrane
  • OPENROUTER_API_KEY - Get from OpenRouter. You can also use other LLM providers (Anthropic, OpenAI, Azure) - see the "Configuring LLM Providers" section in opencode-workspace-template/opencode-template.json.

3. Run the Application

npm run dev

This starts:

  • OpenCode server at http://localhost:1337
  • Next.js app at http://localhost:3000

4. Try It Out

Open http://localhost:3000 and try:

  • "Create a task in Linear"
  • "Get my recent deals from HubSpot"
  • "Send a message in Slack"

🧠 Self-integration Skill

The integration capability consists of three parts: a system prompt, custom tools, and UI components.

When implementing this skill for your agent, you need to:

  • Add the system prompt to your agent's system prompt.
  • Add tools to your agent's list of available tools.
  • Implement the custom UI components in your agent UI.

System Prompt

The agent's behavior is defined in opencode-workspace-template/AGENTS.md. It explains to agent how to use tools mentioned below and instructs it to:

  • Use Membrane for interacting with external apps: create connections and use tools (actions) to perform user requests.
  • Find existing integrations and build new ones if existing ones are not sufficient.
  • Interact with Membrane Agent to build integrations on the fly.

🛠 Tools

Integration skill uses the following tools:

Connecting External Apps

Tool Description
list-connections List all existing connections for the current customer
search-connectibles Search for things that connections can be created from (integrations, connectors, external apps)
request-test-connection Request OAuth connection from user (interactive)

Using Tools (Actions)

Tool Description
search-actions Search for actions by intent (e.g., "create task", "send message")
run-action Execute an action by ID

Dynamically Building Integrations

Tool Description
create-agent-session Start a Membrane Agent session to build connectors/actions
get-agent-session Check Membrane Agent session status (supports long polling)
send-agent-message Send follow-up message to Membrane Agent session
abort-agent-session Stop a running Membrane Agent session

💡 All tools are implemented in opencode-workspace-template/.opencode/tool/ and can be easily ported to any other tool framework.


🖥 UI Components

To work with Membrane, this agent implements a few custom UI components:

Component Description File
Request a Connection Connection UI triggered by request-test-connection tool call when agent needs user to create a connection connection-request.tsx
Membrane Agent Session Summary Status widget showing session state (busy/idle/error) right in the agent chat UI membrane-agent-session.tsx
Membrane Agent Session Details Sidebar showing full Membrane Agent session logs (when user clicks "Show details" button) membrane-agent-sidebar.tsx

If you're building agents that need to operate in the real world —
this is the missing integration layer.

Star this repo if you want agents that don't stop at "I can't do that yet".

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors