Top Related Projects
Bot Framework provides the most comprehensive experience for building conversation applications.
Botkit is an open source developer tool for building chat bots, apps and custom integrations for major messaging platforms.
💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
Quick Overview
BotMan is a framework-agnostic PHP library for building chatbots. It provides a unified interface for various messaging platforms, including Facebook Messenger, Slack, Telegram, and more. BotMan simplifies the process of creating conversational interfaces and handling user interactions.
Pros
- Platform-agnostic: Works with multiple messaging platforms using a single codebase
- Easy to use: Provides a simple and intuitive API for building chatbots
- Extensible: Supports middleware and plugins for added functionality
- Well-documented: Comprehensive documentation and examples available
Cons
- Limited natural language processing capabilities out of the box
- Requires additional setup for more advanced features
- May have a steeper learning curve for developers new to chatbot development
Code Examples
- Creating a simple bot that responds to a message:
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
DriverManager::loadDriver(\BotMan\Drivers\Web\WebDriver::class);
$botman = BotManFactory::create([]);
$botman->hears('Hello', function (BotMan $bot) {
$bot->reply('Hi there!');
});
$botman->listen();
- Using conversation objects for multi-step interactions:
use BotMan\BotMan\Messages\Conversations\Conversation;
class OnboardingConversation extends Conversation
{
public function run()
{
$this->ask('What is your name?', function($answer) {
$name = $answer->getText();
$this->say("Nice to meet you, $name!");
});
}
}
$botman->hears('Start onboarding', function (BotMan $bot) {
$bot->startConversation(new OnboardingConversation());
});
- Handling button interactions:
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
use BotMan\BotMan\Messages\Outgoing\Question;
$botman->hears('Show me options', function (BotMan $bot) {
$question = Question::create('What would you like to do?')
->addButtons([
Button::create('Option 1')->value('option1'),
Button::create('Option 2')->value('option2'),
]);
$bot->ask($question, function ($answer) {
if ($answer->isInteractiveMessageReply()) {
$selectedValue = $answer->getValue();
// Handle the selected option
}
});
});
Getting Started
- Install BotMan using Composer:
composer require botman/botman
- Create a new PHP file (e.g.,
bot.php
) and add the following code:
<?php
require_once __DIR__.'/vendor/autoload.php';
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
DriverManager::loadDriver(\BotMan\Drivers\Web\WebDriver::class);
$botman = BotManFactory::create([]);
$botman->hears('Hello', function (BotMan $bot) {
$bot->reply('Hi there!');
});
$botman->listen();
- Run the bot using PHP's built-in server:
php -S localhost:8080
- Visit
http://localhost:8080
in your browser and interact with your bot.
Competitor Comparisons
Bot Framework provides the most comprehensive experience for building conversation applications.
Pros of Bot Framework SDK
- More comprehensive ecosystem with tools for building, testing, and deploying bots
- Supports multiple programming languages (C#, JavaScript, Python)
- Tight integration with Azure services and Microsoft's AI capabilities
Cons of Bot Framework SDK
- Steeper learning curve due to its extensive features and Microsoft-specific concepts
- Primarily designed for Microsoft platforms, which may limit flexibility in some scenarios
- Heavier framework with more dependencies compared to BotMan
Code Comparison
BotMan (PHP):
$botman->hears('hello', function ($bot) {
$bot->reply('Hi there!');
});
Bot Framework SDK (JavaScript):
bot.onMessage(async (context, next) => {
if (context.activity.text === 'hello') {
await context.sendActivity('Hi there!');
}
await next();
});
Both frameworks offer simple ways to handle incoming messages and respond, but Bot Framework SDK provides more context and uses async/await patterns for better scalability.
BotMan is lightweight and easy to get started with, especially for PHP developers. It's suitable for simpler chatbot projects and integrates well with various messaging platforms.
Bot Framework SDK offers a more robust solution with advanced features like natural language processing and multi-turn conversations. It's ideal for complex enterprise-level bot development, particularly within the Microsoft ecosystem.
Botkit is an open source developer tool for building chat bots, apps and custom integrations for major messaging platforms.
Pros of Botkit
- More extensive documentation and examples
- Larger community and ecosystem
- Built-in support for popular messaging platforms (Slack, Facebook, etc.)
Cons of Botkit
- Steeper learning curve for beginners
- Less flexibility for custom integrations
- Heavier footprint and more dependencies
Code Comparison
Botkit example:
const { Botkit } = require('botkit');
const controller = new Botkit({
webhook_uri: '/api/messages',
});
controller.hears('hello', 'message', async(bot, message) => {
await bot.reply(message, 'Hi there!');
});
Botman example:
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
$botman = BotManFactory::create($config);
$botman->hears('hello', function (BotMan $bot) {
$bot->reply('Hi there!');
});
Both frameworks offer similar functionality for creating conversational interfaces, but Botkit is more JavaScript-focused and has built-in support for popular platforms, while Botman is PHP-based and offers more flexibility for custom integrations. Botkit has a larger community and more extensive documentation, but may have a steeper learning curve for beginners. Botman, on the other hand, is lighter and more straightforward to set up, but may require more custom work for integrating with specific platforms.
💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
Pros of Rasa
- More comprehensive NLU capabilities with built-in intent classification and entity extraction
- Supports multiple languages out of the box
- Offers both open-source and enterprise versions with additional features
Cons of Rasa
- Steeper learning curve due to its more complex architecture
- Requires more computational resources for training and running models
Code Comparison
Rasa (Python):
from rasa_nlu.model import Interpreter
interpreter = Interpreter.load("./models/nlu/default/current")
result = interpreter.parse("Hello!")
print(result)
Botman (PHP):
$botman->hears('Hello', function ($bot) {
$bot->reply('Hi there!');
});
Key Differences
- Rasa is primarily focused on NLU and dialogue management, while Botman is a more general-purpose chatbot framework
- Rasa uses machine learning for intent classification, whereas Botman relies on pattern matching
- Botman is easier to set up for simple use cases, while Rasa offers more advanced features for complex scenarios
Use Cases
- Rasa: Ideal for building sophisticated conversational AI with complex dialogue flows and multi-language support
- Botman: Better suited for simpler chatbots or when quick integration with PHP applications is required
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
BotMan
If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming PHP Package Development video course.
About BotMan
BotMan is a framework agnostic PHP library that is designed to simplify the task of developing innovative bots for multiple messaging platforms, including Slack, Telegram, Microsoft Bot Framework, Nexmo, HipChat, Facebook Messenger and WeChat.
$botman->hears('I want cross-platform bots with PHP!', function (BotMan $bot) {
$bot->reply('Look no further!');
});
If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming PHP Package Development video course.
Documentation
You can find the BotMan documentation at https://botman.io.
Stand Alone Configuration
If you are installing Botman in a stand alone Laravel application, you can publish the configuration file with the following command:
php artisan vendor:publish --tag=config --provider="BotMan\BotMan\BotManServiceProvider"
Support the development
Do you like this project? Support it by donating
- PayPal: Donate
- Open Collective: Become A Backer
- Patreon: Become A Backer
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you discover a security vulnerability within BotMan, please send an e-mail to Marcel Pociot at m.pociot@gmail.com. All security vulnerabilities will be promptly addressed.
License
BotMan is free software distributed under the terms of the MIT license.
Top Related Projects
Bot Framework provides the most comprehensive experience for building conversation applications.
Botkit is an open source developer tool for building chat bots, apps and custom integrations for major messaging platforms.
💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot