ak-dev-new-messaging-integration

ak-dev-new-messaging-integration is a skill for Claude Code, Codex from yaalalabs/agent-kernel. It costs 74 tokens per session (2,600 once invoked), scanned A, original, Apache-2.0.

A step-by-step development guide for adding support for a new chat or messaging platform to Agent Kernel, an agent software framework. It covers the platform's incoming messages, webhooks, settings, and replies.

In plain words
What is it for?
Use it to build a new messaging integration, including its webhook routes, message and attachment handling, configuration, agent calls, and response formatting.
Why use it?
It explains where a new platform connects to the framework, reducing the chance of bypassing the framework's intended message-processing path.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/yaalalabs/agent-kernel/ak-dev-new-messaging-integration
Any agent
npx skills add yaalalabs/agent-kernel --skill ak-dev-new-messaging-integration
Clone the repo
git clone --depth 1 https://github.com/yaalalabs/agent-kernel

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ak-dev-new-messaging-integration

README.md
[![agentmods](https://agentmods.dev/badge/skills/yaalalabs/agent-kernel/ak-dev-new-messaging-integration.svg)](https://agentmods.dev/skills/yaalalabs/agent-kernel/ak-dev-new-messaging-integration)
Your own site
<a href="https://agentmods.dev/skills/yaalalabs/agent-kernel/ak-dev-new-messaging-integration"><img src="https://agentmods.dev/badge/skills/yaalalabs/agent-kernel/ak-dev-new-messaging-integration.svg" alt="Measured on agentmods" height="20"></a>
Per session 74 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,600 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00074 $0.02600
Opus 5 $0.00037 $0.01300
Sonnet 5 $0.00015 $0.00520
Haiku 4.5 $0.00007 $0.00260

Measured 6d ago against content hash 0cb3dadbbff7, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

ak-dev-new-messaging-integration scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/ak-dev-new-messaging-integration/SKILL.md · 312 lines

How it starts

The opening of the file, as written. The whole thing — 312 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Adding a New Messaging Integration

This guide walks through adding a new messaging platform integration to Agent Kernel. Use the Slack integration (ak-py/src/agentkernel/integration/slack/) as the canonical reference.

Architecture Overview

Messaging integrations follow a consistent pattern:

  1. A request handler class that extends RESTRequestHandler
  2. The handler exposes FastAPI routes for webhooks
  3. Incoming messages are parsed into AgentRequest models (platform attachments downloaded and base64-encoded by the handler)
  4. The ChatService execution core runs the agent: build a BaseChatRequest and call execute(req, requests=<prebuilt list>), which returns the typed reply. Integrations own their transport and reply formatting, so they call the core, never the HTTP-shaped process_* wrappers and never AgentService directly (see the chat execution layering rubric in ak-dev-architecture)
  5. The reply is formatted and sent back via the platform's API; a ValueError from execute maps to the platform's "no agent available" message
  6. Configuration is added to AKConfig (accessed via the Config.get() alias) for platform-specific settings

Exception: Gmail does not follow the webhook pattern. AgentGmailRequestHandler (integration/gmail/gmail_chat.py) has no base class and polls email via OAuth instead of exposing webhook routes; its config (_GmailConfig in core/config.py) has token_file, poll_interval, and label_filter rather than a webhook secret.

Step-by-Step

1. Create the Integration Directory

ak-py/src/agentkernel/integration/<platform>/
├── __init__.py
└── <platform>_chat.py

2. Implement the Request Handler

# ak-py/src/agentkernel/integration/<platform>/<platform>_chat.py
import logging
from agentkernel.api.handler import RESTRequestHandler
from agentkernel.core import ChatService, Config
from agentkernel.core.model import AgentRequestText, AgentRequestImage, AgentRequestFile, BaseChatRequest
from fastapi import APIRouter, Request

logger = logging.getLogger("ak.integration.<platform>")


class Agent<Platform>RequestHandler(RESTRequestHandler):
    """Handles incoming messages from <Platform> and routes them to Agent Kernel agents."""

    def __init__(self):
        config = Config.get().<platform>
        self._agent_name = config.agent if config else None
        self._chat_service = ChatService()
        # Initialize platform-specific client/SDK here
        # e.g., self._client = PlatformClient(token=config.bot_token)

    def get_router(self) -> APIRouter:
        router = APIRouter()

        @router.get("/health")
        async def health():
            return {"status": "ok"}

        @router.post("/<platform>/webhook")
        async def webhook(request: Request):
            body = await request.json()
            await self._handle_message(body)
            return {"status": "ok"}

        return router

    async def _handle_message(self, body: dict):
        """Parse platform message and route to agent."""
        # 1. Extract message content from platform-specific format
        user_id = body.get("user_id", "unknown")
        text = body.get("text", "")
        attachments = body.get("attachments", [])

        # 2. Build request list
        requests = []
        if text:
            requests.append(AgentRequestText(prompt=text))

        for attachment in attachments:
            # Handle images
            if attachment.get("type") == "image":
                image_data = await self._download_file(attachment["url"])
                requests.append(AgentRequestImage(
                    image_data=image_data,
                    name=attachment.get("name", "image"),
                    mime_type=attachment.get("mime_type")
                ))
            # Handle files
            elif attachment.get("type") == "file":
                file_data = await self._download_file(attachment["url"])
                requests.append(AgentRequestFile(
                    file_data=file_data,
                    name=attachment.get("name", "file"),
                    mime_type=attachment.get("mime_type")
                ))

        if not requests:
            return

        # 3. Run through the ChatService execution core with the prebuilt request list
        #    (prompt may be empty for attachment-only messages; user_id/group_id are
        #    best-effort platform identity)
        req = BaseChatRequest(prompt=text, agent=self._agent_name, session_id=user_id, user_id=user_id)
        try:
            reply, _ = await self._chat_service.execute(req, requests=requests)
        except ValueError as ve:
            logger.warning(f"Agent execution rejected: {ve}")
            await self._send_reply(user_id, "Sorry, no agent is available to handle your request.")
            return

        # 4. Send reply back via platform API
        await self._send_reply(user_id, str(reply))

    async def _download_file(self, url: str) -> str:
        """Download a file and return base64-encoded content."""
        import base64
        import httpx
        async with httpx.AsyncClient() as client:
            response = await client.get(url, headers=self._auth_headers())
            return base64.b64encode(response.content).decode("utf-8")

    async def _send_reply(self, channel: str, text: str):
        """Send reply back to the messaging platform."""
        # Platform-specific API call to send message
        # e.g., self._client.send_message(channel=channel, text=text)
        pass

    def _auth_headers(self) -> dict:
        """Return auth headers for platform API calls."""
        return {}

Read the full file on GitHub · 312 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 312 lines · 74 tokens per session scan A 0cb3dadbbff7

Subscribe to this mod's changes

ak-dev-new-messaging-integration is a skill published in the GitHub repository yaalalabs/agent-kernel (166 stars, last pushed yesterday), licensed Apache-2.0. It adds 74 tokens to every session and 2,600 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.