Download the PHP package andre/bionic without Composer
On this page you can find all versions of the php package andre/bionic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package bionic
Bionic
Bionic is a simple chat bot development library in PHP.
It is driven by a very simple but powerful event dispatching library Événement and Guzzle a PHP HTTP client that makes it easy to send HTTP requests
Platform support
- Facebook Messenger
- Telegram
- Viber
Facebook Messenger and Instagram
What is covered
- Create a FB Page
- Create a FB app
- Create a webhook
- Connect the Facebook app to the Facebook page
- Setup Bionic
Installation
Create a FB page
First login to Facebook and create a Facebook page. Choose the settings that fits best your bot, but for testing it is not important.
Create a FB Messenger app
Go to the developer's app page. Click "Add a New App" and fill the basic app fields.
On the "Product Setup" page choose Messenger and click "Get Started".
Now you need to create a token to give your app access to your Facebook page. Select the created page, grant permissions and copy the generated token. You need that one later.
Create a webhook for the Facebook app for either Messenger or Instagram
Your application needs to have a webhook. This means a public URL that Facebook can communicate with. Every time a user sends a message inside the FB chat, FB will send it to this URL which is the entry point to your application.
Connect the Facebook app to your application
Now that you got the URL you need to setup the webhook. Go back to you Facebook app settings and click Setup Webhooks
inside the Webhooks part.
Fill in the public URL, check the subscription fields you want to with and click Verify and Save
.
Note: You need to write your own webhook verification logic in your application.
Setup Bionic
The recommended way to install Bionic is through composer.
Just create a composer.json file for your project and require it:
Now you can add the autoloader, and you will have access to the library:
Usage
Creating a Bionic instance
Registering event listeners
Syntax
With an anonymous function
With a defined function
With a class method
With a static class method
Usage with messenger and Instagram
Basic example
Available events provided for messenger and Instagram
Some events do not apply for Instagram, consult documentation
-
entry
-
entry.item
-
messaging
-
standby
-
messaging.item
-
standby.item
-
message
-
message.echo
-
message.text
-
message.attachments
-
message.attachments.image
-
message.attachments.audio
-
message.attachments.video
-
message.attachments.location
-
message.attachments.file
-
message.attachments.fallback
-
postback
-
referral
-
optin
-
account_linking
-
delivery
-
read
-
policy_enforcement
-
payment
-
checkout_update
-
pre_checkout
-
pass_thread_control
-
take_thread_control
- app_roles
Supported Buttons
NOTE: Explore class files for a better understanding of provided methods
-
UrlButton
-
PostBackButton
-
ShareButton
-
CallButton
-
LoginButton
-
LogoutButton
- BuyButton
Sending Messages
-
Text and quick replies
- Sender action
Attachments
-
Image
-
Audio
- Video
Supported Templates
-
Generic Template
-
List Template
-
Button Template
- Receipt Template
Others
- Open Graph Template
- Media Template
Accessing a user profile information
Messenger Profile
-
Setting the Get Started Button Postback
-
Setting the Greeting Text
-
Whitelisting domains
-
Persistent menu
-
Deleting Messenger Profile Properties
-
Setting public key for Tokenized Payments
- Setting Payment Privacy Policy URL
Handover Protocol
-
Passing Thread Control
- Taking Thread Control
Usage with Telegram
Usage with Viber
Exception Handling
Any exceptions not caught when you are defining your event listeners logic are automatically captured. So remember to register a listener that listens for these exceptions.
Bugs
For any bugs found, please email me at [email protected] or register an issue at issues