diff --git a/docs/04-keyboard.md b/docs/04-keyboard.md index 80799ad..1cc45d5 100644 --- a/docs/04-keyboard.md +++ b/docs/04-keyboard.md @@ -33,7 +33,7 @@ button.link(text: string, url: string); ```typescript button.requestContact(text: string); ``` -Добавляет кнопку запроса контакта. При нажатии на неё боту будет отправлено сообщение с номером телефона, полным имененм и почтой пользователя во вложении в формате `VCF`. +Добавляет кнопку запроса контакта. При нажатии на неё боту будет отправлено сообщение с номером телефона, полным именем и почтой пользователя во вложении в формате `VCF`. #### RequestGeoLocation ```typescript @@ -50,3 +50,9 @@ button.chat(text: string, chatTitle: string, extra?: { }); ``` Добавляет кнопку создания чата. При нажатии на неё будет создан новый чат с ботом и пользователем. + +#### OpenApp +```typescript +button.openApp(text: string, webApp?: string, contactId?: number, payload?: string); +``` +Добавляет кнопку для запуска мини-приложения. При нажатии на неё откроется окно с мини-приложением бота, ссылка на которого указана в параметре webApp. diff --git a/src/core/helpers/buttons.ts b/src/core/helpers/buttons.ts index 183ca84..1be733a 100644 --- a/src/core/helpers/buttons.ts +++ b/src/core/helpers/buttons.ts @@ -2,6 +2,7 @@ import { Button, CallbackButton, ChatButton, LinkButton, + OpenAppButton, RequestContactButton, RequestGeoLocationButton, } from '../network/api'; @@ -51,3 +52,14 @@ export const chat = ( type: 'chat', text, chat_title: chatTitle, ...extra, }; }; + +export const openApp = ( + text: string, + webApp: string, + contactId?: number, + payload?: string, +): OpenAppButton => { + return { + type: 'open_app', text, web_app: webApp, contact_id: contactId, payload + }; +}; \ No newline at end of file diff --git a/src/core/network/api/types/keyboard.ts b/src/core/network/api/types/keyboard.ts index ff11d60..176eb58 100644 --- a/src/core/network/api/types/keyboard.ts +++ b/src/core/network/api/types/keyboard.ts @@ -33,9 +33,18 @@ export type ChatButton = { uuid?: string | null; }; +export type OpenAppButton = { + type: 'open_app'; + text: string; + web_app?: string | null; + contact_id?: number | null; + payload?: string | null; +}; + export type Button = | CallbackButton | LinkButton | RequestContactButton | RequestGeoLocationButton - | ChatButton; + | ChatButton + | OpenAppButton;