sgomez/botman-bundle
Composer 安装命令:
composer require sgomez/botman-bundle
包简介
BotMan integration for Symfony
README 文档
README
BotMan integration for Symfony
This is a bundle to use BotMan framework in Symfony.
Supported drivers
Only the marked drivers are supported. See the official driver documentation to have more information:
- Amazon Alexa
- Cisco Spark
- Facebook Messenger
- Hangouts Chat
- HipChat
- Microsoft Bot Framework
- Nexmo
- Slack
- Telegram
- Twilio
- Web
Installation
Step 1: Download the bundle
Install the library via Composer by running the following command:
composer require sgomez/botman-bundle
Step 2: Enable the bundle
You can skip this step if you are using Symfony Flex.
Enable the bundle in your app/AppKernel.php file:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Sgomez\Bundle\BotmanBundle\BotmanBundle(), // ... ); }
Step 3: Configure the bundle
You can see a template of config file by running console config:dump-reference botman.
botman: drivers: telegram: parameters: token: ~ facebook: parameters: token: ~ app_secret: ~ verification: ~ start_button_payload: ~ # Optional greeting: # Optional # Array of - locale: ~ # Required text: ~ # Required whitelisted_domains: [] # Optional
You only must add the drivers than you want to use.
Step 4: Configure the webhook
Add the router configuration for the webhook in your routing.yaml:
BotmanBundle: resource: . type: extra
The webhook path is /botman by default, but we recommend to change it by security issues.
botman: path: /botman57637357-65ce-4faf-a9d9-ee2c13011d87
Now, you must create the webhook controller class. By default is configured as App\Controller\WebhookController:
<?php // file: src/Controller/WebhookController.php declare(strict_types=1); namespace App\Controller; use BotMan\BotMan\BotMan; use Symfony\Component\HttpFoundation\Response; class WebhookController { public function __invoke(BotMan $bot): Response { // Add your logic here // Echo bot example $bot->fallback(function (BotMan $bot): void { $bot->reply($bot->getMessage()->getText()); }); // Stop touching $bot->listen(); return new Response('', Response::HTTP_OK); } }
If you want to change the controller class or you are not using Symfony Flex, you will need to specify the controller class in the config file:
botman: controller: AppBundle\Controller\WebhookController
To know more about how to listen or send messages read the official documentation.
Services
This bundle configure the Symfony container in the BotMan instance. So, you can inject dependencies via constructor in Conversations classes.
In you want to use BotMan instance in your services, you can inject BotMan\BotMan\BotMan class or botman alias.
Drivers command
Some driver will have commands to help to configure it:
The next commands are available:
| Command | Description |
|---|---|
botman:facebook:greeting |
Configure greeting message from driver configuration |
botman:facebook:info |
Retrieve the current values of Messenger Profile Properties |
botman:facebook:start-button |
Configure Messenger Get started button from driver configuration |
botman:facebook:whitelist-domains |
Configure Messenger whitelisted domains from driver configuration |
Telegram
| Command | Description |
|---|---|
botman:telegram:info |
Retrieve the current values of Telegram bot and its webhook status |
botman:telegram:webhook |
Configure the system webhook to be used by Telegram bot |
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository. However, this project is in very alpha status and config file format can change very quickly.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
sgomez/botman-bundle 适用场景与选型建议
sgomez/botman-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 308 次下载、GitHub Stars 达 12, 最近一次更新时间为 2018 年 08 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 sgomez/botman-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sgomez/botman-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 308
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-28