Files
openclaw/extensions/telegram/src/interactive-fallback.ts
Josh Avant 51f4a5e8a0 Fix Telegram presentation-only payload sends (#82449)
* fix telegram presentation payload fallback

* changelog telegram presentation payload fallback

* fix telegram presentation reply delivery
2026-05-16 00:16:51 -05:00

42 lines
1.2 KiB
TypeScript

import {
interactiveReplyToPresentation,
normalizeMessagePresentation,
normalizeInteractiveReply,
renderMessagePresentationFallbackText,
resolveInteractiveTextFallback,
} from "openclaw/plugin-sdk/interactive-runtime";
export function resolveTelegramInteractiveTextFallback(params: {
text?: string | null;
interactive?: unknown;
presentation?: unknown;
}): string | undefined {
const interactive = normalizeInteractiveReply(params.interactive);
const text = resolveInteractiveTextFallback({
text: params.text ?? undefined,
interactive,
});
if (text?.trim()) {
return text;
}
const presentation = normalizeMessagePresentation(params.presentation);
if (presentation) {
const fallback = renderMessagePresentationFallbackText({
text: params.text ?? undefined,
presentation,
});
if (fallback.trim()) {
return fallback;
}
}
if (!interactive) {
return text;
}
const interactivePresentation = interactiveReplyToPresentation(interactive);
if (!interactivePresentation) {
return text;
}
const fallback = renderMessagePresentationFallbackText({ presentation: interactivePresentation });
return fallback.trim() ? fallback : text;
}