# flewis88/webex-ai-bot-via-n8n architecture

> Architecture diagram of the GitHub repository flewis88/webex-ai-bot-via-n8n, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flewis88/webex-ai-bot-via-n8n
- Repository: https://github.com/flewis88/webex-ai-bot-via-n8n

## Overview

##### Project type and purpose
- This is an event-driven integration project built on the n8n workflow automation platform.
- Its purpose is to wire up a Cisco Webex Bot that listens for mentions in Webex Spaces, forwards message content to OpenAI via a “Basic LLM Chain” node, and then posts the AI-generated response back into the same Webex space.

##### File structure
- In this case, there is only a single top-level file (README.md) because the bulk of the “code” lives inside an n8n workflow (a JSON document you import into your n8n instance).
- Key artifacts are:
- Webhook trigger node (captures incoming Webex events)
- Webex by Cisco node (fetches full message content)
- AI Agent / Basic LLM Chain node (invokes OpenAI)
- HTTP Request node (posts replies back to Webex)
- Configuration is managed via n8n credentials (Webex Bot Token, OAuth2 integration for Webex, OpenAI API key).

##### README for additional insights
- The README walks through:
- Creating a Webex Bot and capturing its bearer token & Bot ID
- Setting up two different Webhooks (test vs. prod) in n8n
- Establishing an OAuth2 integration for the “Webex by Cisco” node
- Calling the OpenAI API via the “Basic LLM Chain” node
- Issuing an HTTP Request to the Webex REST API to send messages
- It shows the sequence in which data flows from Webex → n8n → OpenAI → Webex.

##### Detailed capture of essential architectural elements
- Two distinct Webex integrations (Webhook creation vs. REST API messaging).
- OAuth2 handshake for the “Webex by Cisco” node.
- Where the OpenAI API key is applied.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    User["End User<br/>(Webex Space)"]:::external
    Webex["Webex Platform<br/>(Webhooks & REST API)"]:::external
    OpenAI["OpenAI API Service"]:::external

    %% n8n Workflow
    subgraph "n8n Workflow Engine"
        direction TB
        WebhookNode["Webhook Trigger Node"]:::incoming
        FetchNode["Webex by Cisco Fetch Node"]:::enrichment
        LLMNode["Basic LLM Chain Node"]:::ai
        HTTPNode["HTTP Request Node"]:::outbound
        Credentials["Credentials Store 🔑"]:::credential
    end

    %% Documentation
    Doc["Project Documentation"]:::doc

    %% Data Flow
    User -->|"mentions bot"| Webex
    Webex -->|"messages.created webhook"| WebhookNode
    WebhookNode -->|"fetch messageId"| FetchNode
    FetchNode -->|"message text"| LLMNode
    LLMNode -->|"prompt request"| OpenAI
    OpenAI -->|"generated text"| HTTPNode
    HTTPNode -->|"POST /messages"| Webex
    Webex -->|"bot response"| User

    %% Click Events
    click Doc "https://github.com/flewis88/webex-ai-bot-via-n8n/blob/main/README.md"

    %% Styles
    classDef external fill:#cccccc,stroke:#333,stroke-width:1px;
    classDef incoming fill:#cce5ff,stroke:#0366d6,stroke-width:1px;
    classDef enrichment fill:#d4edda,stroke:#28a745,stroke-width:1px;
    classDef ai fill:#fff3cd,stroke:#856404,stroke-width:1px;
    classDef outbound fill:#ffe5b4,stroke:#e69500,stroke-width:1px;
    classDef credential fill:#f0f0f0,stroke:#999999,stroke-width:1px,stroke-dasharray: 5 5;
    classDef doc fill:#e6e6fa,stroke:#6a5acd,stroke-width:1px,stroke-dasharray: 2 2;
```
