Skip to content
BotServBotServ
Open WebUIPipelinesAutomationWebhooksTools

Open WebUI Automation

Automate with Open WebUI: pipelines, webhooks, tool integration, workflow connection, and practical examples.

S

schutzgeist

6 min read
Open WebUI Automation

Open WebUI for Automation

What This Article Covers

  • Using Open WebUI as an automation platform, not just a chat interface.
  • How pipelines, tools, and webhooks work.
  • Connecting Open WebUI with n8n and other systems.
  • Practical examples for document processing, research, and notifications.
  • Best practices for integration and security.

Introduction: Open WebUI for Automation Explained

Open WebUI is known as a chat interface for Ollama. But it can do much more: pipelines for custom logic, tools for external actions, webhooks for event processing, and RAG for documents. This transforms Open WebUI into an automation platform, not merely a chat client.

This article is for users who want to leverage Open WebUI for automation tasks. You’ll find foundational knowledge in Open WebUI and Ollama.

Why Use Open WebUI for Automation?

Imagine building an AI chat that doesn’t just answer questions but takes action: processing documents, calling APIs, generating reports. Open WebUI makes this possible through pipelines, which inject custom Python logic directly into the chat flow.

Open WebUI for Automation at a Glance

Open WebUI provides pipelines (Python code that runs on every message), tools (functions the model can invoke), and webhooks (HTTP endpoints for external events). Together, these let you automate workflows within the chat interface itself.

The core idea: chat as your automation interface.

Who Should Read This?

  • Open WebUI users looking to go beyond chat.
  • Self-hosters running AI automation locally.
  • Developers building pipelines and tools.
  • Teams deploying AI assistants for workflow automation.

Basic familiarity with Open WebUI and Python is helpful.

Key Concepts

  • Open WebUI - Chat interface for Ollama. Use when: deploying the platform.
  • Pipelines - Python code in Open WebUI. Use when: adding custom logic.
  • Tools - Functions the model can call. Use when: triggering external actions.
  • Webhooks - HTTP endpoints. Use when: receiving external events.
  • RAG - Retrieval-Augmented Generation. Use when: working with documents.
  • Ollama - Model server. Use when: running inference.
  • n8n - Workflow automation tool. Use when: orchestrating multi-step processes.

Pipelines: Custom Logic in Chat

Pipelines are Python functions that run on every message. They can filter, modify, or enrich messages and call external systems.

Simple Pipeline

# pipelines/filter.py
class Pipeline:
    def __init__(self):
        self.name = "Automatisierungs-Pipeline"

    async def on_message(self, message, user):
        """Wird bei jeder Nachricht aufgerufen"""
        # Nachricht analysieren
        if "bericht" in message.lower():
            # Bericht-Workflow auslösen
            await self.trigger_workflow("bericht", message)
        return message

    async def trigger_workflow(self, typ, data):
        """Externen Workflow auslösen"""
        import aiohttp
        async with aiohttp.ClientSession() as session:
            await session.post(
                "http://n8n:5678/webhook/bericht",
                json={"typ": typ, "data": data}
            )

Installing a Pipeline

# In Open WebUI:
# Admin Panel → Pipelines → Upload
# Datei: filter.py hochladen

# Oder via API:
curl -X POST http://open-webui:8080/pipelines/upload \
  -H "Authorization: Bearer ..." \
  -F "file=@filter.py"

Tools: Functions for the Model

Tools are Python functions that the model can invoke via function calling.

# tools/web_search.py
def web_search(query: str) -> str:
    """Sucht im Web nach Informationen."""
    import requests
    response = requests.get(
        "https://api.duckduckgo.com/",
        params={"q": query, "format": "json"}
    )
    return response.json().get("AbstractText", "Kein Ergebnis")

def get_weather(city: str) -> str:
    """Gibt das Wetter für eine Stadt zurück."""
    import requests
    response = requests.get(
        f"https://wttr.in/{city}?format=3"
    )
    return response.text

Activating a Tool in Open WebUI

  1. Admin Panel → Tools → New Tool
  2. Paste Python code
  3. Save
  4. Select the tool in chat

The model can now call web_search() and get_weather().

Webhooks: Receiving External Events

Open WebUI can receive webhooks and generate messages:

# Webhook-Endpoint in Open WebUI
# POST /api/v1/webhook

# Beispiel: n8n sendet Benachrichtigung
curl -X POST http://open-webui:8080/api/v1/webhook \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Neues Dokument wurde hochgeladen",
    "chat_id": "abc123"
  }'

Practical Example 1: Automatic Document Processing

# Pipeline: Dokument automatisch verarbeiten
class Pipeline:
    async def on_file_upload(self, file, user):
        """Bei Datei-Upload"""
        if file.name.endswith(".pdf"):
            # PDF verarbeiten
            text = extract_pdf(file)
            summary = await self.summarize(text)
            # Als Nachricht posten
            return f"Zusammenfassung von {file.name}:\n\n{summary}"
        return None

    async def summarize(self, text):
        import aiohttp
        async with aiohttp.ClientSession() as s:
            async with s.post(
                "http://ollama:11434/api/chat",
                json={
                    "model": "llama3.1",
                    "messages": [
                        {"role": "user", "content": f"Fasse zusammen:\n{text[:4000]}"}
                    ]
                }
            ) as r:
                data = await r.json()
                return data["message"]["content"]

Practical Example 2: Chat to n8n Workflow

# Tool: n8n Workflow auslösen
def trigger_n8n_workflow(workflow_name: str, data: str) -> str:
    """Löst einen n8n Workflow aus."""
    import requests
    response = requests.post(
        f"http://n8n:5678/webhook/{workflow_name}",
        json={"input": data}
    )
    return response.text

# Der Nutzer schreibt im Chat:
# "Erstelle einen Bericht über lokale KI"
# → Das Modell ruft trigger_n8n_workflow("bericht", "lokale KI") auf
# → n8n führt den Workflow aus
# → Ergebnis kommt zurück

Practical Example 3: Contextual Responses from External Systems

# Pipeline: Kontext aus anderen Systemen hinzufügen
class Pipeline:
    async def on_message(self, message, user):
        """Bei jeder Nachricht Kontext hinzufügen"""
        # Aktuelle Dokumente aus Nextcloud holen
        docs = await self.get_recent_documents()

        # Kontext zur Nachricht hinzufügen
        enriched = f"{message}\n\nRelevante Dokumente:\n{docs}"
        return enriched

Open WebUI + n8n Integration

Open WebUI Chat
    │
    ▼ (Tool oder Pipeline)
HTTP Request → n8n Webhook
    │
    ▼
n8n Workflow:
  ├─ Daten verarbeiten
  ├─ Ollama für KI
  ├─ Datenbank abfragen
  └─ Ergebnis zurückgeben
    │
    ▼
Antwort in Open WebUI Chat

Security Considerations

  • Audit Pipelines: Pipelines have full access to the system. Only deploy code you trust completely.
  • Restrict Tools: Tools can perform arbitrary actions. Enforce minimal permissions. See Tool Permissions.
  • Enable Authentication: Protect Open WebUI with a strong password. See Authentication.
  • Audit Logging: Log all pipeline and tool invocations. See Audit Logging.

Common Pitfalls

  • Blocking Pipelines: Slow pipelines stall the chat. Use async/await to keep things responsive.
  • Tool Descriptions: The model reads docstrings as descriptions. Write them precisely so the model understands what each tool does.
  • Context Length: Loading too much context exhausts the model’s capacity. Truncate strategically.
  • Missing Error Handling: If a tool fails, the chat should gracefully degrade, not crash.
  • Too Many Tools: More than 5-7 tools confuses the model. Keep it focused.

Further Reading

Key Takeaways:

  • Open WebUI is far more than a chat interface: pipelines, tools, and webhooks unlock real automation.
  • Pipelines: Python code that runs on every message.
  • Tools: Functions the model can invoke at will.
  • Connect to n8n and other systems via HTTP.
  • Security matters: review pipelines, lock down tools, enforce authentication.

FAQ

What are pipelines in Open WebUI?

Pipelines are Python functions that run on every message or file upload. They can filter messages, inject context, or call external systems.

What are tools in Open WebUI?

Tools are Python functions the model can call. Examples: web_search(), get_weather(), or trigger_workflow(). The model decides when and whether to use each tool.

How do I connect Open WebUI to n8n?

Use tools or pipelines to send HTTP requests to n8n webhooks. n8n executes the workflow and returns the result.

Can I use RAG in Open WebUI?

Yes. Open WebUI has built-in RAG. Upload documents, they’re automatically indexed, and the system retrieves relevant snippets as context for answers.

Are pipelines secure?

Pipelines run with full privileges. Only deploy code you trust. For production, implement code review, sandboxing, and the principle of least privilege.

Do pipelines slow down the chat?

Yes, if they run synchronously. Use async/await and keep pipelines fast. External calls should have timeouts to prevent hangs.

Open WebUI or n8n for automation?

Use Open WebUI for chat-driven automation (user types, AI acts). Use n8n for systematic workflows (trigger → steps → action). They work well together.

How do webhooks work?

External systems send HTTP POST requests to Open WebUI. Open WebUI generates a message or triggers an action. Useful for notifications and event-driven automation.

References

Back to Blog
Share:

Related Posts