Repository navigation
MESSAGING
Status: Partial
Last Updated: 2026-11-13
Audience: People who connect Telegram or WhatsApp to Martlet
Last verified: 2026-11-13 against 29b352d47
Code: src/Martlet.Messaging/, src/Martlet.Desktop/Messaging.cs, src/Martlet.Desktop/MainWindow.Messaging.cs, src/Martlet.Desktop/LiveConversationWindow.Messaging.cs, src/Martlet.Desktop/WindowsMessagingSecretVault.cs, src/Martlet.Desktop/MainWindow.SettingsSync.SettingsSyncClaim_Click.cs, src/Martlet.Mcp.Protocol/Tools/AppsTools.cs
Martlet can answer paired one-to-one chats through Telegram and WhatsApp.
Both transports use MessagingBridge for pairing, message limits and retries.
Other messaging transports are planned.
What it does: you write to your own Telegram bot, and Martlet on your companion PC answers in the same conversation as the talk window: the same Thinking model, personality, memory, lorebooks and conversation history. Replies come back as text.
Set it up in Companion › Messaging:
- In Telegram, open BotFather, send
/newbotand pick a name. BotFather gives you a token like123456789:AAH.... - Paste the token and press Connect. Martlet checks it with Telegram
(
getMe), keeps it in Windows Credential Manager on this PC (Martlet/v3/messaging/telegram/<id>, a new entry per connection) and turns on Answer Telegram messages on this PC. - Press Pair a chat. Martlet shows a six-digit code for 10 minutes; send it
to the bot (or open the Open in Telegram link, which sends
/start <code>). That chat is now paired.
How it works:
- Martlet uses the Bot API's long polling (
getUpdates), so it needs no public address, open port or webhook. Messages travel through Telegram's servers. The token goes only toapi.telegram.org. - Only paired one-to-one chats are answered. Group chats are ignored; an unpaired chat never reaches the Thinking model. Martlet tells at most 1,000 unpaired chats per run how to pair, once each. Each chat gets five guesses. Fifty wrong guesses across all chats end the pairing code.
- Each text message becomes a typed message in the conversation (shown in the talk window as "Name (Telegram)"); the conversation starts hidden when none is running. While Martlet answers, the chat shows "typing". Replies longer than 4096 characters are split at paragraph, line or word breaks. A message waits at most 3 minutes for its reply.
- Messages are answered while Windows is locked too, since that is when you are away: text in, text out, never the microphone, the screen or Martlet's voice. Locking still starts a fresh conversation, as it does for the talk window.
- Also say replies aloud on this PC (off by default) speaks them with the chosen voice, never while Windows is locked.
- Only one program can read a bot's messages, so Martlet answers an app only on
the PC where you turn it on. The connected bot or number with its secrets, the
paired chats and Also say replies aloud are the same on all your computers
(the
messagingshared setting): on a new PC the app is already connected, and you turn on answering there only if that PC should run it. WhatsApp's webhook port and your own public address stay with each PC. A host PC never answers. - Martlet reads text only for now (photos, voice notes and stickers get a short note). A tool call or smart-home action that asks first waits for you at the PC and otherwise times out.
- Each answered message is on the Conversations page with its Telegram message IDs (yours and Martlet's reply pieces). Deleting a message there deletes it in Telegram too (within Telegram's 48 hours), and editing Martlet's reply edits it there; your own messages can't be edited by a bot. See Conversation history. WhatsApp's Cloud API can't delete or edit sent messages, so WhatsApp messages are deleted and edited on this PC only.
Disconnect stops the bot, deletes the token and forgets the paired chats. Remove unpairs one chat.
What it does: the same as Telegram, from WhatsApp. You write to a WhatsApp business number you own (Meta's free test number is enough), and Martlet on your companion PC answers in the same conversation as the talk window.
Martlet uses Meta's official WhatsApp Cloud API, so nothing unofficial runs against your personal WhatsApp account. The Cloud API delivers messages to a public web address (a webhook); Martlet sets that up itself.
Set it up in Companion › Messaging › WhatsApp (the card has buttons for each link):
- Create a Meta app with WhatsApp Cloud API access and a WhatsApp Business account.
- Use Meta's WhatsApp API setup to add a business number and a destination number. Follow Meta's current steps to verify each number.
- Create an access token with
whatsapp_business_messagingandwhatsapp_business_management. A temporary API setup token works for 24 hours; use a system-user token for continued use. - In the app, open App settings › Basic and copy the App secret.
- Paste both in Martlet and press Connect. Leave the phone number ID and
WhatsApp Business account ID empty and Martlet finds them from the token
(
debug_token, then the account's first number); type them to pick another. You don't configure Webhooks in Meta. - Press Pair a chat and send the six-digit code to the number (or open
Open in WhatsApp, a
wa.melink with the code filled in).
What Martlet does on Connect and at every start:
- Checks the token with Meta and the app secret against the token's app, then
keeps both in Windows Credential Manager
(
Martlet/v3/messaging/whatsapp/<id>). They go only tograph.facebook.com. - Listens on
http://localhost:<port>(no administrator rights, no open firewall port) at a random secret path, accepting only deliveries signed with the app secret (X-Hub-Signature-256) for its phone number. - Opens a public address: by default a free
Cloudflare quick tunnel
(
https://….trycloudflare.com; no account, port or router change). It needs Cloudflare'scloudflared: Martlet uses one already installed (PATH, Program Files, winget) or, after you agree, downloads Cloudflare's official build from GitHub into<data directory>\tools. The address changes at each start, so Martlet waits until it resolves and points the webhook at it again. - Sets the app's webhook (
POST /<app>/subscriptions, fieldmessages, with a fresh verify token, using the app access token) and subscribes the app to the WhatsApp Business account (POST /<waba>/subscribed_apps). Meta checks the webhook right away. - Marks each message read with "typing" while Martlet answers, and replies as text (split at 4096 characters).
Already have a public HTTPS address (a named Cloudflare tunnel, a reverse
proxy)? Put it in Public address; it must forward to the
http://localhost:<port> Martlet shows, with Host: localhost (or
127.0.0.1). The app's webhook belongs to Martlet while it runs, so use a Meta
app for Martlet only.
Everything else matches Telegram: only paired one-to-one chats are answered, unpaired chats get the same capped pairing notice, text only, answered while Windows is locked, optional Also say replies aloud on this PC, Disconnect deletes the secrets and forgets the chats, Remove unpairs one chat. Martlet stops waiting for a reply after three minutes. Meta controls which outbound messages it accepts.
-
messaging.json(data directory):Telegram.Enabled,BotName,BotUsername,CredentialId(which Credential Manager entry),Chats(Id,Name) andSpeakReplies;WhatsAppwithEnabled,Name,Number,AppId,BusinessAccountId,PhoneNumberId,Port,PublicAddress,CredentialId,ChatsandSpeakReplies. Never a token or app secret. - The desktop log records when Telegram or WhatsApp connects, a chat pairs and a paired chat's message is answered (never message text).
- MCP:
messaging_statusreadsmessaging.json(counts chats, never their names or IDs); Companion › Messaging's status lines are readable throughui_*(MCP).MARTLET_TELEGRAM_APIandMARTLET_WHATSAPP_API(a loopbackhttp://127.0.0.1:<port>/address only) point the desktop at a local fake Bot API or Graph API for MCP verification; with the latter, a loopbackhttp://public address is accepted too.
A new app implements IMessagingTransport (connect, receive, send, typing,
longest message) and reuses MessagingBridge for pairing, the allow-list,
typing, splitting and retries. An app whose bot may find, delete and edit its
messages also implements IMessagingMessageControl (send returning the
message's ID, delete, edit), so the record of conversations keeps those IDs and
deletes or edits there through MessagingPlatform. Discord has its own, richer
foundation (servers, channels, people and chat modes) in Discord.
These candidate transports are not implemented:
Matrix (/sync long polling, no public address needed) and Signal through
signal-cli. A webhook-based app can reuse WhatsApp's pieces: a local
listener and IPublicAddress (Cloudflare quick tunnel or an own address).
Martlet: download · repository · changelog · issues
These pages come from docs/wiki in the repository. To suggest a change, open an issue or a pull request there.
- Home
- Accounts and households
- Accounts and Household
- Android phones and tablets: what it takes, and the plan
- Martlet's API for other apps and scripts
- App Guides
- App Settings and Updates
- App guides: game and app knowledge from the web
- Architecture
- Bounded PCM playback
- Audio dependency inventory and notices
- Avatar guide: Live2D, VRM and speech animation
- V01a explicit microphone capture
- Chatterbox voice engines
- Cleaning up disk space
- One Martlet on all your computers
- Companion controls and behavior requirements
- Components, jobs and placement (design)
- Live conversation
- Creations
- Decision map: which file owns each decision
- Deep research: web search and long research jobs
- The desktop app: updates, notification area, exiting and appearance
- Linux and macOS desktop companion: research, decision and plan
- Developer Guide
- Dia voice engine
- Diagnostics
- Discord
- Architecture and provider contracts
- Discord
- Memory (P03a/P03b/P03c)
- Singing
- Desktop troubleshooting and local support
- Recognizing people by voice, and Parakeet
- Echo cancellation
- ElevenLabs voice: your cloned voice with tones
- F5 worker and reference-voice foundation
- FAQ
- First Steps
- Game state plan: implementation history
- Glossary: one name for each concept
- GPT-SoVITS voice
- Hosted Thinking: cloud models when Thinking can't run on this PC
- Installation and support
- Installing Martlet
- iOS and iPadOS: what it takes, and the plan
- Repository instructions for coding agents
- Repository knowledge base
- Knowledge base maintenance
- GitHub Wiki mirror
- Linux and Mac
- Listening and Voice ID
- Local model apps
- Lorebooks
- macOS: what it takes, and the plan
- Martlet MCP Server
- MCP in Martlet
- MCP: The app's window
- MCP: Apps, home and memory
- MCP: Characters
- MCP: Diagnostics and logs
- MCP: Computers, network and accounts
- MCP: Other
- MCP: Tool permissions
- MCP pages
- MCP: Server and protocol internals
- MCP: Settings
- MCP: Start here
- MCP: Thinking and models
- MCP: Voice and listening
- Memory
- Messaging apps
- Model catalog: sources, conflicts and design
- Motion host role
- Multiple Computers
- Your Martlet network
- OCR host role
- Share your language models: the OpenAI-compatible endpoint
- Packaging
- Perception worker contracts
- Personality and Characters
- Picture making
- Pictures and Creations
- Picture making host role
- Platforms: what each device can do
- Prerequisites: what Martlet bundles, installs for you, or needs from you
- Privacy and Safety
- Reading the text on your screen
- Wiki source
- Recommendation design: ask three questions, plan for three situations
- Recommended setups: one machine to unlimited budget
- Releasing
- Repository Layout
- Research and provenance ledger
- Resource footprints
- Roadmap
- Watch my screen: screen-aware commentary
- Search engine
- Image and audio models: who sees, who hears, who answers
- Setting Up a Host
- Setup, Windows credentials and local audio
- Sharing with Friends
- Singing
- Smart Home
- Smart home and cameras
- Source Projects
- Talking to Martlet
- Telegram and WhatsApp
- The Character
- Thinking
- Tools and MCP
- Troubleshooting
- Martlet desktop UI design
- User stories and target flows
- Voice activity detection
- Validating changes
- Validation and Testing
- Vision
- Voice latency: from you stopping talking to Martlet's voice
- Voice recognition host role
- Multi-engine voice setup and comparison
- Voices
- The welcome wizard
- XTTS-v2 voice engine