Download the PHP package erfanvahabpour/bale-bot-sdk without Composer
On this page you can find all versions of the php package erfanvahabpour/bale-bot-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download erfanvahabpour/bale-bot-sdk
More information about erfanvahabpour/bale-bot-sdk
Files in erfanvahabpour/bale-bot-sdk
Package bale-bot-sdk
Short Description The Unofficial Bale Bot API PHP SDK
License BSD-4-Clause
Homepage https://github.com/ErfanVahabpour/Bale-Bot-SDK
Rated 5.00 based on 1 reviews
Informations about the package bale-bot-sdk
🌐 **Language / زبان:** **English** | [**فارسی (Persian)**](README.fa.md)
کتابخانه جامع و مدرن ساخت ربات پیامرسان بله برای PHP و لاراول (Laravel 10, 11, 12, 13)
Modern, strongly-typed PHP 8.2+ SDK for Bale Messenger Bot API with full support for Webhooks, Inline Keyboards, Media uploads, and In-App Payments.
🌟 Overview / معرفی
Bale Bot PHP SDK is an enterprise-grade, developer-friendly PHP library designed to seamlessly interact with the Bale Messenger Bot API. Whether you are building an e-commerce assistant, customer support bot, payment automation service, or interactive mini-app in Standalone PHP or Laravel, this SDK offers an expressive, robust, and strongly-typed toolkit.
[!NOTE] راهنمای فارسی / Persian Documentation:
اگر به دنبال ساخت ربات پیامرسان بله در زبان PHP یا فریمورک لاراول (Laravel 10, 11, 12, 13) هستید، این کتابخانه کاملترین SDK پیاچپی برای وبسرویس بله است. تمامی قابلیتها از جمله ارسال انواع پیام، دکمههای شیشهای (Inline Keyboard)، وبهوک (Webhook)، درگاه پرداخت درونبرنامهای، آپلود رسانه و مدیریت چندین بات به طور کامل پیادهسازی شدهاند. برای مطالعه راهنمای کامل به زبان فارسی به README.fa.md مراجعه فرمایید.
✨ Key Features
- ⚡ Complete API Coverage — 100% full implementation of all official endpoints from docs.bale.ai (Messages, Media, Chats, Webhooks, Payments, Commands, Stickers).
- 🚀 First-Class Laravel Support — Auto-discovered Service Provider, Facade (
Bale::), configuration publishing, Artisan CLI helpers, and IoC container resolution. - 🤖 Multi-Bot Manager — Effortlessly configure and switch between multiple bot accounts in a single codebase (
Bale::bot('support_bot')). - 🎯 Flexible Update Handling — Built-in support for Webhook handling and Long-Polling CLI runners.
- 💳 Bale In-App Payments — Create digital invoice links, send structured invoices, handle pre-checkout verification, and query transaction statuses.
- 💬 Interactive UI & Mini-Apps — Support for Inline Keyboards, Reply Keyboards, WebApps / Mini-Apps (
WebAppInfo), and Copy Text buttons. - 🧠 Command Bus System — Create modular, self-contained Command classes with regex pattern arguments and automatic dependency injection.
- 🔔 Event-Driven Architecture — Decoupled event dispatcher (
UpdateWasReceived) powered byIlluminate\Events. - ⚡ Async Requests & Custom Clients — Make non-blocking asynchronous HTTP calls or plug in custom HTTP client handlers.
- 🛡️ Modern & Secure — Built for PHP 8.2+, strictly typed objects (
BaseObject), and backed by comprehensive PHPUnit test suites.
📖 Table of Contents
- Requirements
- Installation
- Laravel Integration
- 1. Publish Configuration
- 2. Configure Environment Variables
- 3. Multi-Bot Configuration
- 4. Artisan CLI Commands
- Quick Start
- In Standalone PHP
- In Laravel
- Comprehensive Usage Guide
- 1. Sending & Managing Messages
- 2. Interactive Keyboards & Mini-Apps
- 3. Media & File Uploads
- 4. Chat Actions & Typing Status
- 5. Chat, Group & Channel Administration
- 6. Webhooks & Polling Update Handling
- 7. Command Bus & Custom Commands
- 8. Bale In-App Payments & Invoices
- 9. Stickers & Custom Sticker Sets
- 10. Bot Commands Menu Management
- 11. Event Dispatcher & Listeners
- 12. Error & Exception Handling
- 13. Advanced Configuration & Custom Clients
- API Method Reference
- Frequently Asked Questions (FAQ)
- Testing
- Contributing
- Funding & Support
- License & Disclaimer
📋 Requirements
| Requirement | Minimum Version | Notes |
|---|---|---|
| PHP | >= 8.2 |
PHP 8.2, 8.3, 8.4+ supported |
| Laravel (Optional) | ^10.0 \| ^11.0 \| ^12.0 \| ^13.0 |
For Laravel-based projects |
| Extensions | ext-json, ext-curl, ext-mbstring |
Required PHP core extensions |
📦 Installation
Install the package via Composer into your project:
🚀 Laravel Integration
1. Publish Configuration
The package registers EFive\Bale\Laravel\BaleServiceProvider and the Bale Facade automatically. Publish the configuration file:
This publishes config/bale.php into your Laravel application.
2. Configure Environment Variables
Add your bot token and optional parameters to your .env file:
3. Multi-Bot Configuration
Configure single or multiple bots in config/bale.php:
4. Artisan CLI Commands
Manage bot webhooks directly from the terminal:
🏁 Quick Start
In Standalone PHP
In Laravel
💡 Comprehensive Usage Guide
1. Sending & Managing Messages
Plain & Formatted Messages
Forwarding & Copying Messages
Editing & Deleting Messages
2. Interactive Keyboards & Mini-Apps
Inline Keyboards (Buttons attached to messages)
Reply Keyboards (Custom bottom input buttons)
3. Media & File Uploads
The SDK provides the flexible InputFile helper which supports local files, remote URLs, raw string contents, or open stream resources.
Downloading Files
4. Chat Actions & Typing Status
Send temporary chat status indicators (e.g. typing, uploading photo, recording video):
5. Chat, Group & Channel Administration
Manage chats, admins, bans, permissions, and invite links:
6. Webhooks & Polling Update Handling
Webhook Controller in Laravel
Define a webhook route in routes/api.php:
Long Polling in CLI Workers
For local development or daemon workers:
7. Command Bus & Custom Commands
The SDK includes a built-in Command Bus system. You can create organized Command classes that automatically resolve arguments, respond to updates, and leverage Laravel dependency injection.
Creating a Custom Command
Create a command class extending EFive\Bale\Commands\Command:
Registering & Processing Commands
In config/bale.php:
In your webhook route:
8. Bale In-App Payments & Invoices
Integrate digital sales and payments natively within Bale Messenger using the Bale Banking API:
9. Stickers & Custom Sticker Sets
10. Bot Commands Menu Management
Configure the command hints displayed to users in the Bale Messenger chat menu:
11. Event Dispatcher & Listeners
The SDK fires EFive\Bale\Events\UpdateWasReceived whenever an update is processed. In Laravel, you can register listeners in your EventServiceProvider:
In your listener:
12. Error & Exception Handling
The SDK provides structured exceptions for robust error handling:
13. Advanced Configuration & Custom Clients
Asynchronous Non-Blocking Requests
Enable async requests globally in .env (BALE_ASYNC_REQUESTS=true) or per instance:
Custom Base URL / API Proxy
For local mock servers or custom Bale reverse proxies:
Custom HTTP Client Handler
Implement EFive\Bale\HttpClients\HttpClientInterface to plug in your own HTTP transport client (e.g. customized cURL, Guzzle middleware stack, or HTTP/2 client).
📚 API Method Reference
All SDK methods return strongly-typed BaseObject models, arrays, or boolean statuses:
| Category | Method | Parameters | Return Type | Description |
|---|---|---|---|---|
| Bot & Updates | getMe |
[] |
User |
Get bot profile information |
getUpdates |
['offset'?, 'limit'?, 'timeout'?, ...] |
Update[] |
Poll for updates | |
setWebhook |
['url', 'certificate'?, 'allowed_updates'?] |
bool |
Set webhook URL | |
deleteWebhook / removeWebhook |
[] |
bool |
Remove current webhook | |
getWebhookInfo |
[] |
WebhookInfo |
Get current webhook status | |
getWebhookUpdate |
[$shouldEmitEvents, $request] |
Update |
Parse incoming webhook update | |
| Messaging | sendMessage |
['chat_id', 'text', 'reply_markup'?, ...] |
Message |
Send text message |
forwardMessage |
['chat_id', 'from_chat_id', 'message_id'] |
Message |
Forward existing message | |
copyMessage |
['chat_id', 'from_chat_id', 'message_id', ...] |
MessageId |
Copy message without forward tag | |
editMessageText |
['chat_id', 'message_id', 'text', ...] |
Message\|bool |
Edit message text | |
editMessageCaption |
['chat_id', 'message_id', 'caption', ...] |
Message\|bool |
Edit media caption | |
editMessageReplyMarkup |
['chat_id', 'message_id', 'reply_markup'] |
Message\|bool |
Edit inline keyboard markup | |
deleteMessage |
['chat_id', 'message_id'] |
bool |
Delete message | |
sendChatAction |
['chat_id', 'action'] |
bool |
Broadcast chat status (e.g. typing) | |
askReview |
['chat_id', ...] |
Message |
Send review prompt | |
| Media Uploads | sendPhoto |
['chat_id', 'photo', 'caption'?, ...] |
Message |
Send photo |
sendAudio |
['chat_id', 'audio', 'caption'?, ...] |
Message |
Send audio file | |
sendDocument |
['chat_id', 'document', 'caption'?, ...] |
Message |
Send general file / document | |
sendVideo |
['chat_id', 'video', 'caption'?, ...] |
Message |
Send video | |
sendAnimation |
['chat_id', 'animation', 'caption'?, ...] |
Message |
Send animation / GIF | |
sendVoice |
['chat_id', 'voice', 'caption'?, ...] |
Message |
Send voice audio message | |
sendMediaGroup |
['chat_id', 'media'] |
Message[] |
Send photo/video album | |
sendLocation |
['chat_id', 'latitude', 'longitude'] |
Message |
Send map location coordinates | |
sendContact |
['chat_id', 'phone_number', 'first_name', ...] |
Message |
Send user vCard contact | |
getFile |
['file_id'] |
File |
Retrieve file info | |
downloadFile |
($file, $saveTo) |
string |
Download file to disk | |
| Chat Management | getChat |
['chat_id'] |
ChatFullInfo |
Get chat details |
getChatAdministrators |
['chat_id'] |
ChatMember[] |
List chat administrators | |
getChatMembersCount |
['chat_id'] |
int |
Get total chat member count | |
getChatMember |
['chat_id', 'user_id'] |
ChatMember |
Get specific member info | |
banChatMember |
['chat_id', 'user_id'] |
bool |
Ban user from chat | |
unbanChatMember |
['chat_id', 'user_id'] |
bool |
Unban user in chat | |
promoteChatMember |
['chat_id', 'user_id', ...] |
bool |
Promote member to admin | |
leaveChat |
['chat_id'] |
bool |
Leave group or channel | |
setChatTitle |
['chat_id', 'title'] |
bool |
Change chat title | |
setChatDescription |
['chat_id', 'description'] |
bool |
Change chat description | |
setChatPhoto |
['chat_id', 'photo'] |
bool |
Set new chat profile photo | |
deleteChatPhoto |
['chat_id'] |
bool |
Delete chat profile photo | |
pinChatMessage |
['chat_id', 'message_id', ...] |
bool |
Pin message in chat | |
unpinChatMessage |
['chat_id', 'message_id'] |
bool |
Unpin message in chat | |
unpinAllChatMessages |
['chat_id'] |
bool |
Unpin all messages | |
createChatInviteLink |
['chat_id', 'expire_date'?, ...] |
string |
Create custom invite link | |
revokeChatInviteLink |
['chat_id', 'invite_link'] |
string |
Revoke invite link | |
exportChatInviteLink |
['chat_id'] |
string |
Export primary invite link | |
| Interactions | answerCallbackQuery |
['callback_query_id', 'text'?, ...] |
bool |
Respond to inline button click |
| In-App Payments | sendInvoice |
['chat_id', 'title', 'prices', ...] |
Message |
Send payment invoice |
createInvoiceLink |
['title', 'prices', 'provider_token', ...] |
string |
Generate invoice payment link | |
answerPreCheckoutQuery |
['pre_checkout_query_id', 'ok', ...] |
bool |
Approve/reject checkout | |
inquireTransaction |
['payment_charge_id'] |
Transaction |
Check payment transaction state | |
| Bot Commands | setMyCommands |
['commands'] |
bool |
Set bot commands list |
getMyCommands |
[] |
BotCommand[] |
Retrieve registered bot commands | |
deleteMyCommands |
[] |
bool |
Delete registered bot commands | |
| Stickers | sendSticker |
['chat_id', 'sticker'] |
Message |
Send sticker |
uploadStickerFile |
['user_id', 'sticker', 'sticker_format'] |
File |
Upload sticker file | |
createNewStickerSet |
['user_id', 'name', 'title', 'stickers', ...] |
bool |
Create custom sticker set | |
addStickerToSet |
['user_id', 'name', 'sticker'] |
bool |
Add sticker to existing set |
❓ Frequently Asked Questions (FAQ) / سوالات متداول
1. How do I get a Bale Bot API Token? / چگونه توکن ربات بله دریافت کنم؟
To create a bot and get an API token: 1. Open the [Bale Messenger](https://bale.ai/) app. 2. Search for the official **`@BotFather`** account and start a conversation. 3. Send the command `/newbot` and follow the on-screen instructions to select a display name and a unique username ending with `bot`. 4. BotFather will provide an authorization token formatted like `123456789:ABCdefGhIJKlmNoPQRsTUVwxyZ`. 5. Set this token in your `.env` file as `BALE_BOT_TOKEN=your_token_here`.
2. How to build a Bale bot in Laravel? / چگونه در لاراول ربات بله بسازیم؟
Install the package via Composer and publish the configuration: Add your bot token to `.env`: You can now use the `Bale` Facade anywhere in your Laravel application (Controllers, Jobs, Commands, or Routes):
3. Webhook vs Long-Polling: Which update mechanism should I use? / تفاوت وبهوک (Webhook) و پولینگ (Polling) چیست؟
- **Webhook (Recommended for Production)**: Bale servers push updates to your secure HTTPS webhook URL via POST requests in real time. It is high-performance, asynchronous, and scalable: - **Long-Polling (Ideal for Local Development & Testing)**: Your application polls Bale servers periodically for new messages. No public domain, static IP, or SSL certificate is required. Run:
4. How to create Inline Keyboards (Glass Buttons) with callback queries? / نحوه ساخت دکمه شیشهای (Inline Keyboard) در ربات بله چیست؟
Inline keyboards are attached directly under messages. You can pass URLs, callback data, or mini-app WebApp triggers: Handle button clicks in your webhook or controller by inspecting `$update->getCallbackQuery()`, and acknowledge them using `Bale::answerCallbackQuery(['callback_query_id' => $id])`.
5. How does Bale In-App Payment work? / پرداخت و فاکتور درونبرنامهای بله چگونه کار میکند؟
Bale provides a native in-app payment system. You can send a structured invoice card or create a direct invoice link: When the user clicks pay, respond to the `pre_checkout_query` update, and verify completion using `Bale::inquireTransaction(['payment_charge_id' => $chargeId])`.
6. Can I manage multiple Bale bots in a single Laravel codebase? / آیا امکان مدیریت چندین بات بله به طور همزمان وجود دارد؟
Yes, Multi-Bot management is supported out of the box! Register extra bot tokens in `config/bale.php`: Switch between bots seamlessly in your code:
🧪 Testing
Run the automated test suite using PHPUnit:
🤝 Contributing
Contributions are welcome and greatly appreciated!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Ensure all tests pass (
composer test) - Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request
💖 Funding & Support
If this SDK helps you build awesome Bale bots, please consider supporting its ongoing maintenance and development:
- 👤 Author: Erfan Vahabpour
- 📧 Email: [email protected]
- 🌐 Website: efive.net
- ☕ Donate: Aqayepardakht (آقای پرداخت)
📄 License & Disclaimer
- License: Released under the BSD 4-Clause License.
- Disclaimer: This project is an unofficial community library and is not officially affiliated with, maintained, or endorsed by Bale.
Keywords
- کتابخانه بله
- کتابخانه بله PHP
- کتابخانه بله لاراول
- کتابخانه PHP بله
- کتابخانه Laravel بله
- ربات بله PHP
- ربات بله Laravel
- Bale Bot PHP
- Bale Bot Laravel
- Bale PHP SDK
- Bale Laravel SDK
All versions of bale-bot-sdk with dependencies
ext-json Version *
guzzlehttp/guzzle Version ^7.8
guzzlehttp/psr7 Version ^2.7
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/events Version ^10.0|^11.0|^12.0|^13.0
psr/container Version ^1.1 || ^2.0