Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/grammy/mod.ts>InlineQueryResultBuilder

The Telegram Bot Framework.
Very Popular
Latest
variable InlineQueryResultBuilder
import { InlineQueryResultBuilder } from "https://deno.land/x/grammy@v1.31.0/mod.ts";

Holds a number of helper methods for building InlineQueryResult* objects.

For example, letting the user pick one out of three photos can be done like this.

const results = [
    InlineQueryResultBuilder.photo('id0', 'https://grammy.dev/images/Y.png'),
    InlineQueryResultBuilder.photo('id1', 'https://grammy.dev/images/Y.png'),
    InlineQueryResultBuilder.photo('id2', 'https://grammy.dev/images/Y.png'),
];
await ctx.answerInlineQuery(results)

If you want the message content to be different from the content in the inline query result, you can perform another method call on the resulting objects.

const results = [
    InlineQueryResultBuilder.photo("id0", "https://grammy.dev/images/Y.png")
        .text("Picked photo 0!"),
    InlineQueryResultBuilder.photo("id1", "https://grammy.dev/images/Y.png")
        .text("Picked photo 1!"),
    InlineQueryResultBuilder.photo("id2", "https://grammy.dev/images/Y.png")
        .text("Picked photo 2!"),
];
await ctx.answerInlineQuery(results)

Be sure to check the documentation on inline mode.

type

{ article(
id: string,
title: string,
options?: InlineQueryResultOptions<InlineQueryResultArticle, "title">,
); audio(
id: string,
title: string,
audio_url: string | URL,
options?: InlineQueryResultOptions<InlineQueryResultAudio, "title" | "audio_url">,
); audioCached(
id: string,
audio_file_id: string,
options?: InlineQueryResultOptions<InlineQueryResultCachedAudio, "audio_file_id">,
); contact(
id: string,
phone_number: string,
first_name: string,
options?: InlineQueryResultOptions<InlineQueryResultContact, "phone_number" | "first_name">,
); documentPdf(
id: string,
title: string,
document_url: string | URL,
options?: InlineQueryResultOptions<InlineQueryResultDocument, "mime_type" | "title" | "document_url">,
); documentZip(
id: string,
title: string,
document_url: string | URL,
options?: InlineQueryResultOptions<InlineQueryResultDocument, "mime_type" | "title" | "document_url">,
); documentCached(
id: string,
title: string,
document_file_id: string,
options?: InlineQueryResultOptions<InlineQueryResultCachedDocument, "title" | "document_file_id">,
); game(
id: string,
game_short_name: string,
options?: InlineQueryResultOptions<InlineQueryResultGame, "game_short_name">,
); gif(
id: string,
gif_url: string | URL,
thumbnail_url: string | URL,
options?: InlineQueryResultOptions<InlineQueryResultGif, "gif_url" | "thumbnail_url">,
); gifCached(
id: string,
gif_file_id: string,
options?: InlineQueryResultOptions<InlineQueryResultCachedGif, "gif_file_id">,
); location(
id: string,
title: string,
latitude: number,
longitude: number,
options?: InlineQueryResultOptions<InlineQueryResultLocation, "title" | "latitude" | "longitude">,
); mpeg4gif(
id: string,
mpeg4_url: string | URL,
thumbnail_url: string | URL,
options?: InlineQueryResultOptions<InlineQueryResultMpeg4Gif, "mpeg4_url" | "thumbnail_url">,
); mpeg4gifCached(
id: string,
mpeg4_file_id: string,
options?: InlineQueryResultOptions<InlineQueryResultCachedMpeg4Gif, "mpeg4_file_id">,
); photo(
id: string,
photo_url: string | URL,
options?: InlineQueryResultOptions<InlineQueryResultPhoto, "photo_url">,
); photoCached(
id: string,
photo_file_id: string,
options?: InlineQueryResultOptions<InlineQueryResultCachedPhoto, "photo_file_id">,
); stickerCached(
id: string,
sticker_file_id: string,
options?: InlineQueryResultOptions<InlineQueryResultCachedSticker, "sticker_file_id">,
); venue(
id: string,
title: string,
latitude: number,
longitude: number,
address: string,
options?: InlineQueryResultOptions<InlineQueryResultVenue,
| "title"
| "latitude"
| "longitude"
| "address"
>
,
); videoHtml(
id: string,
title: string,
video_url: string | URL,
thumbnail_url: string | URL,
options?: InlineQueryResultOptions<InlineQueryResultVideo,
| "mime_type"
| "title"
| "video_url"
| "thumbnail_url"
>
,
); videoMp4(
id: string,
title: string,
video_url: string | URL,
thumbnail_url: string | URL,
options?: InlineQueryResultOptions<InlineQueryResultVideo,
| "mime_type"
| "title"
| "video_url"
| "thumbnail_url"
>
,
); videoCached(
id: string,
title: string,
video_file_id: string,
options?: InlineQueryResultOptions<InlineQueryResultCachedVideo, "title" | "video_file_id">,
); voice(
id: string,
title: string,
voice_url: string | URL,
options?: InlineQueryResultOptions<InlineQueryResultVoice, "title" | "voice_url">,
); voiceCached(
id: string,
title: string,
voice_file_id: string,
options?: InlineQueryResultOptions<InlineQueryResultCachedVoice, "title" | "voice_file_id">,
); }