Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/screenshots/what_agents_are_available.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions examples/workflows-creator/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Inference Gateway
OPENAI_API_KEY=
DEEPSEEK_API_KEY=
GOOGLE_API_KEY=
COHERE_API_KEY=
GROQ_API_KEY=
MISTRAL_API_KEY=
ANTHROPIC_API_KEY=

# A2A Client and Server
A2A_AGENT_CLIENT_PROVIDER=deepseek
A2A_AGENT_CLIENT_MODEL=deepseek-chat

# N8N
N8N_API_KEY=
47 changes: 47 additions & 0 deletions examples/workflows-creator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Workflows Creator

An advanced example demonstrating how to dynamically create n8n workflows using AI and deploy them to your n8n instance.

## Table of Contents

- [🎯 What You'll Learn](#-what-youll-learn)


## 🎯 What You'll Learn

- How to create workflows from a single prompt using the A2A protocol
- How to sync the generated workflow to your n8n instance

## 🚀 Getting Started

1. First we will create a `.env` file based on the `.env.example` file:

```bash
cp .env.example .env
```

2. Next, fill in the required environment variables in the `.env` file, including your API keys for the AI providers you intend to use.

3. Start the services using Docker Compose:

```bash
docker compose up -d
```

4. Visit the local n8n instance and create a dummy account. It's all local so you can enter whatever you like (Not sure why there is no environment variable just to skip this authentication form - seems to be required so just signup with dummy data):

```
open http://localhost:5678/
```

5. Create an n8n API key from the user settings page and add it to your `.env` file as `N8N_API_KEY`.

6. Now that n8n is properly setup, let's continue with the workflows-creator setup. Let's enter the `a2a-cli` container:

```bash
docker compose run --rm a2a-cli
```

You should see a chat prompt. Ask it what agents does it have available or just type /a2a to list them:

![What agents are available](../../assets/screenshots/what_agents_are_available.png)
138 changes: 138 additions & 0 deletions examples/workflows-creator/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
services:
inference-gateway:
image: ghcr.io/inference-gateway/inference-gateway:latest
container_name: inference-gateway
environment:
ENVIRONMENT: development
SERVER_READ_TIMEOUT: 530s
SERVER_WRITE_TIMEOUT: 530s
CLIENT_TIMEOUT: 530s
CLIENT_IDLE_CONN_TIMEOUT: 30s
OPENAI_API_KEY: ${OPENAI_API_KEY}
DEEPSEEK_API_KEY: ${DEEPSEEK_API_KEY}
GOOGLE_API_KEY: ${GOOGLE_API_KEY}
COHERE_API_KEY: ${COHERE_API_KEY}
GROQ_API_KEY: ${GROQ_API_KEY}
MISTRAL_API_KEY: ${MISTRAL_API_KEY}
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
networks:
- a2a-network

n8n-agent:
image: ghcr.io/inference-gateway/n8n-agent:latest
container_name: n8n-agent
environment:
A2A_PORT: 8080
A2A_DEBUG: true
A2A_AGENT_CLIENT_PROVIDER: ${A2A_AGENT_CLIENT_PROVIDER:-deepseek}
A2A_AGENT_CLIENT_MODEL: ${A2A_AGENT_CLIENT_MODEL:-deepseek-chat}
A2A_AGENT_CLIENT_BASE_URL: http://inference-gateway:8080/v1
A2A_AGENT_STREAMING_ENABLED: true
A2A_STREAMING_STATUS_UPDATE_INTERVAL: 1s
A2A_QUEUE_CLEANUP_INTERVAL: 500s
networks:
- a2a-network

a2a-cli:
image: ghcr.io/inference-gateway/cli:latest
pull_policy: always
volumes:
- ./workflows:/workflows
environment:
INFER_GATEWAY_URL: http://inference-gateway:8080
INFER_A2A_ENABLED: true
INFER_TOOLS_ENABLED: true
INFER_TOOLS_QUERY_ENABLED: true
INFER_TOOLS_TASK_ENABLED: true
INFER_A2A_AGENTS: 'http://n8n-agent:8080'
INFER_A2A_CACHE_ENABLED: false
INFER_AGENT_MODEL: ${A2A_AGENT_CLIENT_PROVIDER:-deepseek}/${A2A_AGENT_CLIENT_MODEL:-deepseek-chat}
INFER_AGENT_SYSTEM_PROMPT: |
You are an n8n expert, you work together with the http://n8n-agent:8080 to provide a full deployable workflow.

When you're being asked about an n8n workflow you simply delegate the task to the n8n-agent.
command:
- chat
networks:
- a2a-network
profiles:
- manual

cli:
image: ubuntu:24.04
volumes:
- ./:/home/ubuntu/app
working_dir: /home/ubuntu/app
environment:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin
N8N_API_KEY: ${N8N_API_KEY}
N8N_INSTANCE_URL: ${N8N_INSTANCE_URL:-http://n8n:5678}
command:
- bash
- -c
- "apt-get update && apt-get install -y curl && curl -sSLf https://raw.github.com/edenreich/n8n-cli/main/install.sh | sh && bash"
profiles:
- manual

n8n:
image: n8nio/n8n:latest
container_name: contact-form-ai-n8n
restart: unless-stopped
ports:
- "5678:5678"
environment:
NODE_ENV: development
N8N_HOST: localhost
N8N_PORT: 5678
N8N_PROTOCOL: http
N8N_DIAGNOSTICS_ENABLED: false
N8N_VERSION_NOTIFICATIONS_ENABLED: false
N8N_ENCRYPTION_KEY: your-encryption-key-here
volumes:
- n8n_data:/home/node/.n8n
- ./workflows:/workflows:ro
healthcheck:
test:
- CMD
- wget
- -q
- --spider
- http://localhost:5678/healthz
interval: 30s
timeout: 5s
retries: 3
start_period: 30s

mailhog:
image: mailhog/mailhog:latest
container_name: contact-form-ai-mailhog
restart: unless-stopped
ports:
- "8025:8025"
- "1025:1025"
environment:
MH_HOSTNAME: mailhog

cli-dev:
image: golang:1.25-alpine
volumes:
- ../..:/go/src/project
- ./:/go/src/example
working_dir: /go/src/project
env_file:
- .env
command:
- sh
- -c
- "go build -o $(go env GOPATH)/bin/n8n . && cd /go/src/example && sh"
profiles:
- manual

volumes:
n8n_data:
driver: local

networks:
a2a-network:
driver: bridge
Loading