> For the complete documentation index, see [llms.txt](https://vkfast.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vkfast.gitbook.io/docs/other/first-bot.md).

# Первый бот

Здесь мы создадим первого нашего бота!

## Инициализация необходимых классов

```php
$api = new VkApi('access_token', 5.131);
$bot = new VkBot($api);
```

## Добавим обработчик

```php
$bot->message(function (MessageNew $event) {
    $event->answer('Твой текст: ' . $event->message->text);
});
```

Простой эхо-бот готов!

## Добавим команду

```php
$bot->message(function (MessageNew $event, $command, ...$arguments) { // ...$arguments - это все аргументы в виде массива
    $text = implode(' ', $arguments); // склеиваем все аргументы пробелом
    $event->answer('Аргументы команды: ' . $text);
})->command('echo'); // команда !echo
```

{% hint style="info" %}
По умолчанию префикс будет "!", изменить его можно через $bot->setPrefix()
{% endhint %}
