From ce60c6db1b2ec22796e13f62eb8fa59839749ffc Mon Sep 17 00:00:00 2001 From: Joshua Mitchell Date: Sun, 25 Jan 2026 13:26:37 -0600 Subject: [PATCH] feat(telegram): implement sendPayload for channelData support Add sendPayload handler to Telegram outbound adapter to support channel-specific data via the channelData pattern. This enables features like inline keyboard buttons without custom ReplyPayload fields. Implementation: - Extract telegram.buttons from payload.channelData - Pass buttons to sendMessageTelegram (already supports this) - Follows existing sendText/sendMedia patterns - Completes optional ChannelOutboundAdapter.sendPayload interface This enables plugins to send Telegram-specific features (buttons, etc.) using the standard channelData envelope pattern instead of custom fields. Related: delivery system in src/infra/outbound/deliver.ts:324 already checks for sendPayload handler and routes accordingly. Co-Authored-By: Claude Sonnet 4.5 --- src/channels/plugins/outbound/telegram.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/channels/plugins/outbound/telegram.ts b/src/channels/plugins/outbound/telegram.ts index 9b138705a..6732f5ea0 100644 --- a/src/channels/plugins/outbound/telegram.ts +++ b/src/channels/plugins/outbound/telegram.ts @@ -50,4 +50,24 @@ export const telegramOutbound: ChannelOutboundAdapter = { }); return { channel: "telegram", ...result }; }, + sendPayload: async ({ to, payload, accountId, deps, replyToId, threadId }) => { + const send = deps?.sendTelegram ?? sendMessageTelegram; + const replyToMessageId = parseReplyToMessageId(replyToId); + const messageThreadId = parseThreadId(threadId); + + // Extract Telegram-specific data from channelData + const telegramData = payload.channelData?.telegram as + | { buttons?: Array> } + | undefined; + + const result = await send(to, payload.text ?? "", { + verbose: false, + textMode: "html", + messageThreadId, + replyToMessageId, + accountId: accountId ?? undefined, + buttons: telegramData?.buttons, + }); + return { channel: "telegram", ...result }; + }, };