DEV Community

Cover image for Build Your Own AI Assistant on WordPress + Telegram (OpenClaw Alternative, Self-Hosted)
Evgeniy R
Evgeniy R

Posted on

Build Your Own AI Assistant on WordPress + Telegram (OpenClaw Alternative, Self-Hosted)

WordPress 7.0 quietly shipped three AI APIs that nobody outside the core community seems to be talking about. Here's a practical walkthrough of what's possible.

Why bother when ChatGPT exists?

ChatGPT is great. OpenClaw is slick. But neither of them is your infrastructure.

When an assistant runs on someone else's platform, the data flows through their servers, the pricing changes on their schedule, and the ToS updates on their lawyers' timeline. For personal tools, client projects, or anything touching sensitive workflows, that's a real constraint — not just philosophical FOSS posturing.

WordPress 7.0 changed the calculus. The new AI-native APIs make it genuinely practical to run production-grade conversational agents on a server you already own and pay for. The two open-source plugins covered here glue it all together.

Here's the stack:

WordPress 7.0
  └── Dot Agents Press        ← agent management engine
  └── OpenRouter Connector    ← 200+ models through one API key
       └── Telegram Webhook   ← your bot, your chat
Enter fullscreen mode Exit fullscreen mode

What WordPress 7.0 Actually Shipped

Three APIs. All in core. All relevant here.
AI Client — a provider-agnostic PHP/JS SDK. wp_ai_client_prompt() does the heavy lifting; the developer picks a model, WordPress handles transport. No curl boilerplate, no rolling your own retry logic.

Connectors API — a unified interface for registering AI providers. API keys live in Settings → Connectors, encrypted, auditable, never hardcoded. Third-party plugins hook in through wp_connectors_init. This is what makes swapping models trivial.

Abilities API — scoped permissions for agents: create posts, query users, read WooCommerce orders. Agents declare what they need; WordPress enforces what they get. Think OAuth scopes but for site actions.

Together these flip WordPress from "CMS that someone bolted an API onto" to a first-class AI runtime. That's not marketing copy — it's what the architecture actually enables.

The Two Plugins

OpenRouter Connector

Repo: github.com/aiiddqd/ai-connector-openrouter-wordpress
Registers OpenRouter as a native WP 7.0 AI provider. Concretely:

  • Admin UI for the OpenRouter API key lands in the standard Connectors screen — no custom settings page to hunt for
  • Automatic integration with WP's AI Client — no custom HTTP calls needed downstream
  • Single key unlocks 200+ models: Claude, GPT-4o, Gemini, Llama, Mistral, and whatever ships between now and when this is read
  • OpenAI-compatible endpoint means anything already speaking OpenAI API works as-is

Activation is standard WordPress plugin flow. One key. That's the whole setup.

DotAgentsPress

Repo: github.com/aiiddqd/dot-agents-press

The actual agent engine. What matters:

  • Multi-agent management from WP Admin → AI Agents — each agent has its own identity, prompt, model, temperature
  • Shortcode embed: [dot_agent id="1"] drops a responsive, accessible chat widget anywhere on the site
  • REST API: POST /wp-json/dot-agents-press/v1/chat for headless or JS-driven use
  • Native Telegram integration: webhook handler and WP-CLI commands included
  • .agents Protocol support: reads .agents/system-prompt.md and .agents/agents.md from the project root — agent config lives in git, not in a dashboard

Requirements: WordPress ≥ 6.0, PHP ≥ 8.0, openssl extension.

Step-by-Step Setup

What's needed before starting

  • WordPress 7.0+ with valid HTTPS (Telegram webhooks require real SSL)
  • An OpenRouter API key (~2 minutes to create)
  • Node.js LTS — only needed for local dev with wp-env, optional

Step 1: Install Both Plugins

bashcd wp-content/plugins/

git clone https://github.com/aiiddqd/ai-connector-openrouter-wordpress.git
git clone https://github.com/aiiddqd/dot-agents-press.git
Enter fullscreen mode Exit fullscreen mode

Activate both from Plugins → Installed Plugins.

Step 2: Add the OpenRouter Key

Go to Settings → Connectors in WP Admin. The OpenRouter connector shows up automatically. Enter the API key — it gets stored encrypted, never in plaintext.
For production, constants in wp-config.php take precedence over the UI:
phpdefine( 'DAP_OPENAI_API_KEY', 'sk-or-...' );

Step 3: Create the First Agent

Navigate to AI Agents → Add New.

Relevant fields:

  • Name: Something descriptive — "Personal Assistant", "Support Bot", etc.
  • System Prompt: The personality and context. "You are a helpful assistant. You have access to information about [project context] and help think through technical decisions." — keep it specific, it matters more than model choice.
  • Model: anthropic/claude-sonnet-4-5 or openai/gpt-4o or any OpenRouter model string
  • Temperature: 0.7 for conversational, lower for factual/support use cases
  • Welcome Message: First message users see when opening the widget

Save. Note the agent ID from the URL — it's needed for Telegram config.

Step 4: Embed a Chat Widget (Optional)

On any page or post:
[dot_agent id="1"]

Or by slug:
[dot_agent slug="personal-assistant"]

The widget is responsive and keyboard-navigable out of the box. CSS custom properties handle theming:

css.dap-chat-widget {
  --dap-user-bg:   #7c3aed;
  --dap-header-bg: #5b21b6;
  --dap-radius:    8px;
}
Enter fullscreen mode Exit fullscreen mode

Step 5: Connect Telegram

5a. Create a bot via BotFather

/newbot
→ Name: My Assistant
→ Username: my_assistant_bot
→ Token: 123456:ABC-DEF1234ghIkl
Enter fullscreen mode Exit fullscreen mode

Copy the token.

5b. Get the Telegram user ID
Message @userinfobot. Copy the numeric ID — this locks the bot to a single user (personal assistant mode). Skip this for multi-user bots.

5c. Configure in WordPress
Go to Settings → Dot Agents Config:

Telegram Bot Token → Token from BotFather
Telegram User ID → Numeric ID from @userinfobot
Webhook Secret → Random string (optional but worth adding)
Default Agent ID → Agent ID from Step 3

Save.

5d. Register the webhook

wp dap telegram set-webhook
wp dap telegram status
Enter fullscreen mode Exit fullscreen mode

Expected output:

URL: https://yoursite.com/wp-json/dot-agents-press/v1/telegram/webhook
Has custom cert: no
Pending updates: 0
Enter fullscreen mode Exit fullscreen mode

If it fails: check that the site URL resolves publicly and SSL is valid. Local dev needs ngrok or similar.

5e. Send a message
Open the bot in Telegram. Send anything. The agent replies.

How It Works Under the Hood

Telegram message
    │
    ▼
POST /wp-json/dot-agents-press/v1/telegram/webhook
    │
    ├── Verify webhook secret
    ├── Authorize user (by Telegram user ID)
    ├── Resolve agent
    │
    ├── Build system prompt:
    │     .agents/system-prompt.md  (priority 1)
    │     .agents/agents.md         (priority 2)
    │     DB system_prompt          (priority 3)
    │
    ├── AI API call via WP AI Client → OpenRouter → model
    │
    └── sendMessage(chat_id, reply) → Telegram
Enter fullscreen mode Exit fullscreen mode

The .agents/ layering is worth pausing on. Agent instructions can live in the filesystem — plain Markdown, committed to git, diffable in PRs, readable by any AI coding tool. The same convention that Cursor, Claude Code, and others are converging on. It means agent config is not trapped in a database or a vendor dashboard.

Use Case Patterns

Personal assistant bot — system prompt loaded with personal context: projects, working style, recurring decisions. Drafts emails, reviews code snippets, thinks through architecture choices. Runs on existing hosting, costs nothing extra beyond token usage.

Customer support bot — connected to a WooCommerce store, the agent knows products, policies, and FAQs. Same agent responds in Telegram and via embedded chat widget simultaneously.

Content automation — an agent that generates draft posts, suggests SEO structures, and creates outlines based on the site's existing content. Triggered via REST API from editorial workflows.
Multi-agent team — separate agents for sales, technical support, and analytics. A Telegram inline keyboard lets users route to the right specialist.

Internal team tool — private Telegram group bot with access to internal documentation, project status, and client history. No external SaaS in the loop.

Cost Reality Check

OpenRouter pricing is pay-per-token. A personal assistant on Claude Sonnet or GPT-4o-mini at moderate daily use lands around $1–5/month.
WordPress hosting is already paid. The agent layer adds effectively nothing to the bill.

Local Development

Both plugins ship with wp-env config. WordPress Playground runtime means no Docker required:

npm -g i @wordpress/env

cd ai-connector-openrouter-wordpress
wp-env start --runtime=playground
Enter fullscreen mode Exit fullscreen mode

Dev site at http://localhost:8888, credentials admin/password. Plugin auto-activated.

What's on the Roadmap

The Dot Agents Press roadmap points toward:

  • Full Abilities API integration — agents that actually modify site content, not just respond
  • Multi-agent orchestration — agents passing context to other agents
  • Conversation memory persistence
  • Additional channel integrations beyond Telegram

The .agents Protocol standardization is moving fast in the agentic tooling space. WordPress sites that adopt this structure early will have agent configs that plug into whatever comes next without migration work.

Resources

📘 Original article
🔌 OpenRouter Connector plugin
🤖 Dot Agents Press plugin
📖 WP 7.0 AI Client announcement
📖 WP 7.0 Connectors API announcement
🔑 OpenRouter API keys

Running an agent setup on WordPress already? The comment section is useful here — what use case, what model, what broke first.

Top comments (0)