Popups & Interactions
Mini Apps provide various popup and interaction methods for displaying messages, scanning QR codes, reading clipboard, handling payments, and more.
Popups
showPopup
Telegram.WebApp.showPopup(params, callback)Displays a custom popup.
| Parameter | Type | Required | Description |
|---|---|---|---|
| params | Object | Yes | Popup parameters |
| params.title | String | No | Popup title, max 64 characters |
| params.message | String | Yes | Popup message text, max 256 characters |
| params.buttons | Array | No | Button list, max 3 buttons |
| callback | Function | No | Close callback with button ID parameter |
Button Object
| Field | Type | Required | Description |
|---|---|---|---|
| id | String | No | Button ID, max 64 characters, defaults to empty string |
| type | String | No | Button type: "default", "ok", "close", "cancel", "destructive" |
| text | String | Conditional | Button text (required when type is "default" or "destructive") |
Telegram.WebApp.showPopup({
title: 'Confirm Action',
message: 'Are you sure you want to proceed?',
buttons: [
{ id: 'confirm', type: 'default', text: 'Confirm' },
{ id: 'cancel', type: 'cancel' }
]
}, (buttonId) => {
if (buttonId === 'confirm') {
// User clicked confirm
}
});showAlert
Telegram.WebApp.showAlert(message, callback)Displays an alert popup with an "OK" button.
| Parameter | Type | Required | Description |
|---|---|---|---|
| message | String | Yes | Alert message text |
| callback | Function | No | Callback after user clicks "OK" |
Telegram.WebApp.showAlert('Operation successful!', () => {
console.log('User acknowledged');
});showConfirm
Telegram.WebApp.showConfirm(message, callback)Displays a confirmation popup with "OK" and "Cancel" buttons.
| Parameter | Type | Required | Description |
|---|---|---|---|
| message | String | Yes | Confirmation message text |
| callback | Function | No | Callback with confirmed (Boolean) parameter |
Telegram.WebApp.showConfirm('Are you sure you want to delete?', (confirmed) => {
if (confirmed) {
deleteItem();
}
});QR Code Scanning
showScanQrPopup
Telegram.WebApp.showScanQrPopup(params, callback)Displays a QR code scanning popup. Bot API 6.9+
| Parameter | Type | Required | Description |
|---|---|---|---|
| params | Object | No | Scan parameters |
| params.text | String | No | Hint text for the scan interface |
| callback | Function | No | Scan success callback with scanned text. Return true to close the popup |
Telegram.WebApp.showScanQrPopup({ text: 'Scan QR Code' }, (text) => {
console.log('Scan result:', text);
return true; // Close the scan popup
});closeScanQrPopup
Telegram.WebApp.closeScanQrPopup()Closes the QR code scanning popup. Bot API 6.9+
Clipboard
readTextFromClipboard
Telegram.WebApp.readTextFromClipboard(callback)Reads text content from the clipboard. Bot API 6.9+
| Parameter | Type | Required | Description |
|---|---|---|---|
| callback | Function | No | Callback with text (String | null) parameter |
Telegram.WebApp.readTextFromClipboard((text) => {
if (text) {
console.log('Clipboard content:', text);
}
});Invoices & Payments
openInvoice
Telegram.WebApp.openInvoice(url, callback)Opens the invoice payment interface.
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | String | Yes | Invoice link |
| callback | Function | No | Payment callback with status parameter |
Telegram.WebApp.openInvoice('https://t.me/$invoice_id', (status) => {
if (status === 'paid') {
showSuccess('Payment successful');
} else if (status === 'cancelled') {
showInfo('Payment cancelled');
}
});Payment status values:
| Status | Description |
|---|---|
paid | Payment successful |
cancelled | User cancelled payment |
failed | Payment failed |
pending | Payment processing |
Sharing
shareToStory
Telegram.WebApp.shareToStory(media_url, params)Shares content to a story. Bot API 7.8+
| Parameter | Type | Required | Description |
|---|---|---|---|
| media_url | String | Yes | Media file URL |
| params | Object | No | Share parameters |
| params.text | String | No | Additional text |
| params.widget_link | Object | No | Widget link |
| params.widget_link.url | String | No | Link URL |
| params.widget_link.name | String | No | Display name |
shareMessage
Telegram.WebApp.shareMessage(msg_id, callback)Shares a message prepared by the Bot. Bot API 8.0+
| Parameter | Type | Required | Description |
|---|---|---|---|
| msg_id | String | Yes | Prepared message ID |
| callback | Function | No | Callback with sent (Boolean) parameter |
Emoji Status
setEmojiStatus
Telegram.WebApp.setEmojiStatus(custom_emoji_id, params, callback)Sets a custom emoji status for the user. Bot API 8.0+
| Parameter | Type | Required | Description |
|---|---|---|---|
| custom_emoji_id | String | Yes | Custom emoji ID |
| params | Object | No | Parameters |
| params.duration | Integer | No | Duration in seconds |
| callback | Function | No | Callback with set (Boolean) parameter |
requestEmojiStatusAccess
Telegram.WebApp.requestEmojiStatusAccess(callback)Requests permission to set emoji status. Bot API 8.0+
| Parameter | Type | Required | Description |
|---|---|---|---|
| callback | Function | No | Callback with granted (Boolean) parameter |
File Download
downloadFile
Telegram.WebApp.downloadFile(params, callback)Requests a file download. Bot API 8.0+
| Parameter | Type | Required | Description |
|---|---|---|---|
| params | Object | Yes | Download parameters |
| params.url | String | Yes | File URL |
| params.file_name | String | Yes | Suggested file name |
| callback | Function | No | Callback with accepted (Boolean) parameter |
Telegram.WebApp.downloadFile({
url: 'https://example.com/report.pdf',
file_name: 'report.pdf'
}, (accepted) => {
if (accepted) {
console.log('User accepted the download');
}
});Permission Requests
requestWriteAccess
Telegram.WebApp.requestWriteAccess(callback)Requests write access to send messages to the user. Bot API 6.9+
| Parameter | Type | Required | Description |
|---|---|---|---|
| callback | Function | No | Callback with granted (Boolean) parameter |
requestContact
Telegram.WebApp.requestContact(callback)Requests the user's contact information (phone number). Bot API 6.9+
| Parameter | Type | Required | Description |
|---|---|---|---|
| callback | Function | No | Callback with sent (Boolean) parameter |
