Options
All
  • Public
  • Public/Protected
  • All
Menu

Module telegram

Telegram Platform

Receive events and send messages through Telegram.

Install

npm install @sociably/core @sociably/http @sociably/telegram
# or with yarn
yarn add @sociably/core @sociably/http @sociably/telegram

Docs

Check the platform document and the package reference.

Setup

import Sociably from '@sociably/core';
import Http from '@sociably/http';
import Telegram from '@sociably/telegram';

const {
TELEGRAM_BOT_NAME,
TELEGRAM_BOT_TOKEN,
TELEGRAM_SECRET_PATH,
} = process.env;

const app = Sociably.createApp({
modules: [
Http.initModule({ /* ... */ }),
],
platforms: [
Telegram.intiModule({
webhookPath: '/webhook/telegram',
botName: TELEGRAM_BOT_NAME,
botToken: TELEGRAM_BOT_TOKEN,
secretPath: TELEGRAM_SECRET_PATH,
}),
],
});

Index

Exports

Root

Provider

Event

Other

Event

Other

BotApiResult: Record<string, any>
FailApiResult: { description?: string; error_code: number; ok: false; parameters?: { migrate_to_chat_id?: number; retry_after?: number } }

Type declaration

  • Optional description?: string
  • error_code: number
  • ok: false
  • Optional parameters?: { migrate_to_chat_id?: number; retry_after?: number }
    • Optional migrate_to_chat_id?: number
    • Optional retry_after?: number
RawAnimation: any
RawAudio: any
RawCallbackQuery: any
RawChat: { bio?: string; description?: string; first_name?: string; id: number; last_name?: string; title?: string; type: TelegramChatType; username?: string }

Type declaration

  • Optional bio?: string
  • Optional description?: string
  • Optional first_name?: string
  • id: number
  • Optional last_name?: string
  • Optional title?: string
  • type: TelegramChatType
  • Optional username?: string
RawChatMember: any
RawChatMemberUpdated: any
RawChosenInlineResult: any
RawContact: any
RawDice: any
RawDocument: any
RawFile: any
RawGame: any
RawInlineKeyboardMarkup: any
RawInlineQuery: any
RawInvoice: any
RawLocation: any
RawMaskPosition: any
RawMessage: any
RawMessageEntity: any
RawOrderInfo: any
RawPassportData: any
RawPhotoSize: any
RawPoll: any
RawPollAnswer: any
RawPollOption: any
RawPreCheckoutQuery: any
RawShippingAddress: any
RawShippingQuery: any
RawSticker: any
RawSuccessfulPayment: any
RawUser: { first_name: string; id: number; is_bot: boolean; language_code?: string; last_name?: string; username?: string }

Type declaration

  • first_name: string
  • id: number
  • is_bot: boolean
  • Optional language_code?: string
  • Optional last_name?: string
  • Optional username?: string
RawVenue: any
RawVideo: any
RawVideoNote: any
RawVoice: any
TelegramChatType: "private" | "group" | "supergroup" | "channel"
TelegramComponent<Props, Segment>: NativeComponent<Props, Segment>

Type parameters

TelegramConfigs: { botName: string; botToken: string; dispatchMiddlewares?: TelegramDispatchMiddleware[]; eventMiddlewares?: TelegramEventMiddleware[]; maxRequestConnections?: number; secretPath?: string; webhookPath?: string }

Type declaration

  • botName: string

    The username of the bot without the prefixing @. Like MyBot

  • botToken: string

    The access token of the bot. Like: 1234567890:AaBbCc_321-DdEeFf

  • Optional dispatchMiddlewares?: TelegramDispatchMiddleware[]
  • Optional eventMiddlewares?: TelegramEventMiddleware[]
  • Optional maxRequestConnections?: number

    The max API request connections at the same time

  • Optional secretPath?: string

    A secret string suffixed after the webhookPath. This helps to filter out requests not from Telegram platform

  • Optional webhookPath?: string

    The webhook path to receive events. Default to /

TelegramDispatchFrame: DispatchFrame<TelegramChat, TelegramJob>
TelegramDispatchResponse: DispatchResponse<TelegramJob, TelegramResult>
TelegramEventContext: { bot: TelegramBot; event: TelegramEvent; metadata: WebhookMetadata; platform: "telegram"; reply: any }

Type declaration

TelegramEventMiddleware: EventMiddleware<TelegramEventContext, null>
TelegramJob: { key: undefined | string; method: string; parameters: {}; uploadingFiles: null | UploadingFile[] }

Type declaration

  • key: undefined | string
  • method: string
  • parameters: {}
    • [k: string]: any
  • uploadingFiles: null | UploadingFile[]
TelegramParseMode: "HTML" | "MarkdownV2" | "Markdown" | "None"
TelegramRawEvent: { callback_query?: RawCallbackQuery; channel_post?: RawMessage; chat_member?: RawChatMemberUpdated; chosen_inline_result?: RawChosenInlineResult; edited_channel_post?: RawMessage; edited_message?: RawMessage; inline_query?: RawInlineQuery; message?: RawMessage; my_chat_member?: RawChatMemberUpdated; poll?: RawPoll; poll_answer?: RawPollAnswer; pre_checkout_query?: RawPreCheckoutQuery; shipping_query?: RawShippingQuery; update_id: number }

Type declaration

  • Optional callback_query?: RawCallbackQuery

    New incoming callback query

  • Optional channel_post?: RawMessage

    New incoming channel post of any kind — text, photo, sticker, etc.

  • Optional chat_member?: RawChatMemberUpdated
  • Optional chosen_inline_result?: RawChosenInlineResult

    The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.

  • Optional edited_channel_post?: RawMessage

    New version of a channel post that is known to the bot and was edited

  • Optional edited_message?: RawMessage

    New version of a message that is known to the bot and was edited

  • Optional inline_query?: RawInlineQuery

    New incoming inline query

  • Optional message?: RawMessage

    New incoming message of any kind — text, photo, sticker, etc.

  • Optional my_chat_member?: RawChatMemberUpdated
  • Optional poll?: RawPoll

    New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot

  • Optional poll_answer?: RawPollAnswer

    A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.

  • Optional pre_checkout_query?: RawPreCheckoutQuery

    New incoming pre-checkout query. Contains full information about checkout

  • Optional shipping_query?: RawShippingQuery

    New incoming shipping query. Only for invoices with flexible price

  • update_id: number

    The update's unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you're using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.

TelegramResult: { description?: string; ok: true; result: BotApiResult }

Type declaration

TelegramSegmentValue: { method: string; parameters: {}; toNonChatTarget?: boolean; uploadingFiles?: UploadingFile[] }

Type declaration

  • method: string
  • parameters: {}
    • [k: string]: any
  • Optional toNonChatTarget?: boolean
  • Optional uploadingFiles?: UploadingFile[]
UploadingFile: { assetTag?: string; fieldName: string; fileData: string | Buffer | NodeJS.ReadableStream; fileInfo?: UploadingFileInfo }

Type declaration

  • Optional assetTag?: string
  • fieldName: string
  • fileData: string | Buffer | NodeJS.ReadableStream
  • Optional fileInfo?: UploadingFileInfo
UploadingFileInfo: { contentType?: string; filename?: string; filepath?: string; knownLength?: number }

Type declaration

  • Optional contentType?: string
  • Optional filename?: string
  • Optional filepath?: string
  • Optional knownLength?: number

Generated using TypeDoc