Back to Engineering Notes
2026-12-05·Engineering Notes·7 min read

Zero-Public-IP IM Gateways: Real Engineering Notes & 4 Bugs Caught Connecting 6 Platforms

TL;DR

Connecting local AI agents to IM platforms no longer requires buying a VPS or running ngrok—Feishu, Slack, Telegram, Discord, and DingTalk all support outbound long connections or polling. The real engineering work is handling secret-safe error redaction, stdout protocol cleanliness, cursor truth tables, and preventing outbound writeback loops.

1. Why Outbound Long Connections Beat Webhooks for Local Agents

Traditional chatbots expect an always-on server with a public domain, TLS cert, and inbound webhook port. That is a terrible fit for local coding agents living next to your Mac repos and Obsidian notes—and exposed webhook ports became a major attack surface in 2026.

In TagTag, all 6 IM connectors are built directly in Go with zero extra go.mod bloat: Feishu WebSocket, Slack Socket Mode, Telegram getUpdates Long Polling, Discord Gateway v10, DingTalk Stream Mode, and WeCom (App API / Group Webhook). Each runs under an independent supervisor goroutine so one flaky platform never takes down the others.

2. Four Real Bugs Caught by Zero-Mock Live Testing

BUG-01 (Telegram Token Leak in *url.Error): Because Telegram Bot API puts the bot token right inside the URL path (/bot<TOKEN>/getUpdates), a Go *url.Error on network failure prints your raw token in the error string. We fixed this with full-path redaction replacing tokens with [REDACTED] and added unit tests covering every transport path.

BUG-02 (Feishu SDK Corrupting CLI --json Output): The default lark-oapi logger writes [Warn] lines straight to os.Stdout, breaking downstream scripts parsing `tagtag connector check --json`. We replaced it with a custom feishuSDKLogger routed to stderr with AppSecret redaction.

BUG-03 (WeCom & DingTalk Webhook URL Secrets + No-Spam Health Checks): Webhook URLs embed secret keys in query parameters, and naive health checks send test messages into real work groups. We added URL secret redaction plus a zero-send TCP/TLS reachability check for webhook-only instances.

BUG-04 (Bidirectional default_target Writeback Loop): Originally, default_target injection only ran on readonly/inbound-only connectors. When a bidirectional calendar connector (like Apple Calendar) fired an inbound reminder, the Bot tried to write its reply back to the calendar instead of routing to IM. Moving default_target resolution out of the readonly-only branch eliminated writeback loops completely (10/10 verified on live macOS Calendar.app).

Zero-token connector verification before ever invoking an LLM
# Inspect all configured instances
tagtag connector list --data-dir "$TAGTAG_HOME" --json

# Zero-send health probe (no test spam into team groups)
tagtag connector check --data-dir "$TAGTAG_HOME" --json feishu:default

# Safe dry-run poll (inspects next cursor without mutating state files)
tagtag connector poll --data-dir "$TAGTAG_HOME" --dry-run --json telegram:personal

3. Build Your Own Connector in 2 Files

Beyond the 14 built-in Go connectors and 17 zero-dependency Python stdlib plugins, you never need to recompile Go to add a new source. Drop a plugin.json manifest and a poll/stream script (in any language) under <data-dir>/plugins/<name>/, read `{cursor, config}` from stdin, print `{cursor, events}` to stdout, and TagTag handles scheduling, cursor persistence, crash backoff, and credential isolation automatically.

Local agents
IM platforms