InputTextMessageContent
Represents the content of a text message to be sent as the result of an inline query.
Fields
message_textStringRequiredminLen 1maxLen 4096Text of the message to be sent, 1-4096 characters
parse_modeStringOptionalOptional. Mode for parsing entities in the message text. See formatting options for more details.
Optional. List of special entities that appear in message text, which can be specified instead of parse\_mode
Optional. Link preview generation options for the message
GramIO Usage
message_text accepts a FormattableString (the result of format`…` ) directly — GramIO's formatMiddleware decomposes it into text + entities when serializing the request. You do not need parse_mode, and you must not call .toString().
Misleading type signature
The field is typed as string | { toString(): string }. Despite what the { toString(): string } implies, GramIO does not call .toString() on a FormattableString — entities are preserved. Pass the format`…` result directly.
typescript
import {
format,
bold,
link,
InlineQueryResult,
InputMessageContent,
} from "gramio";
bot.inlineQuery(/find (.*)/i, async (ctx) => {
await ctx.answer(
[
InlineQueryResult.article(
"result-1",
`Result for ${ctx.args![1]}`,
InputMessageContent.text(
format`Found ${bold(ctx.args![1])} — see ${link`details`("https://example.com")}`,
),
),
],
{ cache_time: 0 },
);
});Plain strings still work — only use format`…` when you need entities.
See Also
- InputMessageContent — the union this variant belongs to
answerInlineQuery- InlineQueryResultArticle
- MessageEntity
- Formatting guide