The Telegram service sends PDF ticket files directly to a configured Telegram chat using the Bot API. It handles multipart form data uploads and provides graceful error handling to never interrupt the user experience.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Diego31-10/TableOrderApp/llms.txt
Use this file to discover all available pages before exploring further.
Functions
sendTicketToTelegram
Sends a PDF file to the configured Telegram chat with a formatted caption.Local file URI returned by expo-print (e.g.,
file:///path/to/ticket.pdf)Returns void. Errors are logged to console but never thrown.
Example
Complete payment flow
Behavior
Silent failure
The function never throws errors to avoid interrupting the payment success flow. All errors are logged to console:Missing credentials
If bot credentials are not configured, the function logs a warning and returns early:File upload format
The function constructs a FormData object compatible with React Native:Caption format
Each PDF is sent with a Spanish-language caption:Configuration
The service requires two environment variables:Config.restaurant.name- Included in the PDF caption
Getting credentials
- Create a bot: Message @BotFather on Telegram and use
/newbot - Get token: BotFather will provide a token like
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11 - Get chat ID:
- Add your bot to a group or message it directly
- Visit
https://api.telegram.org/bot<TOKEN>/getUpdates - Find the chat ID in the response
API reference
This service uses the Telegram Bot API:multipart/form-data
Form fields:
chat_id(string) - Target chat identifierdocument(file) - PDF file to sendcaption(string) - Optional message to accompany the file
Error handling
Possible error scenarios (all handled gracefully):- Missing credentials → Warning logged, function returns
- Network failure → Error logged to console
- Invalid chat ID → Error logged with API response
- Bot blocked by user → Error logged with API response
- File too large → Error logged with API response
Best practices
-
Never await unnecessarily: Since errors are silent, you can fire-and-forget
- Test credentials early: Check console warnings during development
- Monitor delivery: Check your Telegram chat to verify receipts are arriving
- Privacy consideration: Ensure the chat ID is for an authorized recipient (business owner, not customers)