<commit_before># PHP BotMan 🤖 Create messaging bots in PHP with ease

[![Build Status](https://travis-ci.org/mpociot/slackbot.svg?branch=master)](https://travis-ci.org/mpociot/slackbot)
[![codecov](https://codecov.io/gh/mpociot/botman/branch/master/graph/badge.svg)](https://codecov.io/gh/mpociot/botman)
[![Packagist](https://img.shields.io/packagist/l/mpociot/botman.svg)]()

BotMan is a framework agnostic PHP library that is designed to simplify the task of developing innovative bots for multiple messaging platforms, including [Slack](http://slack.com), [Telegram](http://telegram.me) and [Facebook Messenger](http://messenger.com). 

## Getting Started

1) Open the Laravel/Symfony/PHP project your new Bot will live in

2) [Install BotMan with composer](#installation-using-composer)

3) Configure your messaging platform

4) Implement your bot logic
 
## Installation using Composer

Require this package with composer using the following command:

```sh
$ composer require mpociot/botman
```

### Using BotMan within a Laravel app

BotMan comes with a Service Provider to make using this library in your [Laravel](http://laravel.com) application as simple as possible.

Go to your `config/app.php` and add the service provider:

```php
Mpociot\BotMan\BotManServiceProvider::class,
```

Also add the alias / facade:

```php
'BotMan' => Mpociot\BotMan\Facades\BotMan::class
```

Add your Facebook access token / Slack token to your `config/services.php`:

```php
    'botman' => [
    	'slack_token' => 'YOUR-SLACK-TOKEN-HERE',
    	'telegram_token' => 'YOUR-TELEGRAM-TOKEN-HERE',
        'facebook_token' => 'YOUR-FACEBOOK-TOKEN-HERE'
    ],
```

That's it.

## Getting Started

After you've installed BotMan, the first thing you'll need to do is register your bot with a messaging platform, and get a few configuration options set. This will allow your bot to connect, send and receive messages.

You can support all messaging platforms using the exact same Bot-API.

- [Setup and connect Telegram](readme-telegram.md)
- [Setup and connect Facebook Messenger](readme-facebook.md)
- Setup and connect Slack

## Core Concepts

Bots built with BotMan have a few key capabilities, which can be used to create clever, conversational applications. 
These capabilities map to the way real human people talk to each other.

Bots can [hear things](#receiving-messages), [say things and reply](#sending-messages) to what they hear.

With these two building blocks, almost any type of conversation can be created.

## Basic Usage


This sample bot listens for the word "hello" - either in a direct message (a private message inside Slack between the user and the bot) or in a message the bot user is invited to.

```php<commit_msg>Add example to the top<commit_after># PHP BotMan 🤖 Create messaging bots in PHP with ease

[![Build Status](https://travis-ci.org/mpociot/slackbot.svg?branch=master)](https://travis-ci.org/mpociot/slackbot)
[![codecov](https://codecov.io/gh/mpociot/botman/branch/master/graph/badge.svg)](https://codecov.io/gh/mpociot/botman)
[![Packagist](https://img.shields.io/packagist/l/mpociot/botman.svg)]()

BotMan is a framework agnostic PHP library that is designed to simplify the task of developing innovative bots for multiple messaging platforms, including [Slack](http://slack.com), [Telegram](http://telegram.me) and [Facebook Messenger](http://messenger.com). 

```php
BotMan::hears('I want cross-platform bots with PHP!', function($bot) {
    $bot->reply('Look no further!');
});
```

## Getting Started

1) Open the Laravel/Symfony/PHP project your new Bot will live in

2) [Install BotMan with composer](#installation-using-composer)

3) Configure your messaging platform

4) Implement your bot logic
 
## Installation using Composer

Require this package with composer using the following command:

```sh
$ composer require mpociot/botman
```

### Using BotMan within a Laravel app

BotMan comes with a Service Provider to make using this library in your [Laravel](http://laravel.com) application as simple as possible.

Go to your `config/app.php` and add the service provider:

```php
Mpociot\BotMan\BotManServiceProvider::class,
```

Also add the alias / facade:

```php
'BotMan' => Mpociot\BotMan\Facades\BotMan::class
```

Add your Facebook access token / Slack token to your `config/services.php`:

```php
    'botman' => [
    	'slack_token' => 'YOUR-SLACK-TOKEN-HERE',
    	'telegram_token' => 'YOUR-TELEGRAM-TOKEN-HERE',
        'facebook_token' => 'YOUR-FACEBOOK-TOKEN-HERE'
    ],
```

That's it.

## Connect with your messaging service

After you've installed BotMan, the first thing you'll need to do is register your bot with a messaging platform, and get a few configuration options set. This will allow your bot to connect, send and receive messages.

You can support all messaging platforms using the exact same Bot-API.

- [Setup and connect Telegram](readme-telegram.md)
- [Setup and connect Facebook Messenger](readme-facebook.md)
- Setup and connect Slack

## Core Concepts

Bots built with BotMan have a few key capabilities, which can be used to create clever, conversational applications. 
These capabilities map to the way real human people talk to each other.

Bots can [hear things](#receiving-messages), [say things and reply](#sending-messages) to what they hear.

With these two building blocks, almost any type of conversation can be created.

## Basic Usage


This sample bot listens for the word "hello" - either in a direct message (a private message inside Slack between the user and the bot) or in a message the bot user is invited to.

```php
{'fraction_non_alphanumeric': 0.10689470871191876, 'fraction_numerical': 0.0014252627828255835, 'mean_word_length': 4.5639246778989095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1285278', 'n_tokens_mistral': 1739, 'n_tokens_neox': 1665, 'n_words': 635}