SlideShare a Scribd company logo
Creating chatbots
with BotMan
Adam Matysiak
CTO / Team Leader
adam@highsolutions.pl
What is chatbot?
Definition:
“A conversational
user interface
used for interaction
with application”
Where we can use it?
- Automatic/interactive deployments
- DevOps
- Sales support (E-commerce)
- Customer service support
- Brand marketing
- Blog/content promotion
- Self-service (e.g. weather forecast, bus timetable etc.)
- Fun
- … ?
Examples
https://highsolutions.pl/blog/wpis/7-zastosowan-chatbota-
o-ktorych-musisz-wiedziec-prowadzac-biznes
The time is now?
“Chatbot Market Size Is About To
Reach $1.25 Billion By 2025”
GrandViewResearch, August 2017
Efficiency
Data source: https://neilpatel.com/blog/open-rates-facebook-messenger
Creating Chatbots with Botman - English
BotMan
composer create-project --prefer-dist botman/studio your-awesome-bot
Requirements: PHP >= 7.0
● https://botman.io/ - Documentation / Demo
● https://buildachatbot.io/ - Video course
● https://playground.botman.io/ - On-line IDE
● https://christoph-rumpel.com/build-chatbots-with-php - E-book
Available services
- Amazon Alexa
- Cisco Spark
- Facebook Messenger
- HipChat
- Kik
- Microsoft Bot Framework
- Nexmo
- Slack
- Telegram
- Twilio
- WeChat
How chatbots work
1. Listening 🙉
2. Processing 🌀
3. Responding 📢
How chatbots work
Hear and respond...
File botman.php in routes directory
$botman->hears('Hi', function ($bot) {
$bot->reply('Hello World!');
});
// Process incoming message
$botman->listen();
Sending to controller...
$botman->hears('Hi', 'SomeNamespaceCommandController@respond');
class CommandController {
public function respond($bot) {
$bot->reply('Hello World!');
}
}
Parameters and regular expressions
$botman->hears('I like {team}', function ($bot, $team) {
$bot->reply('You like: '. $team);
});
$botman->hears('.*(hi|hey|hello).*', function ($bot) {
$bot->reply('Hello World!');
});
$botman->hears('I want to buy ([0-9]+) tickets', function ($bot, $number) {
$bot->reply('I am ordering ’. $number .’ tickets for you!’);
});
Attachments (images, videos, localization etc.)
$bot->receivesImages(function($bot, $images) {
foreach ($images as $image) {
$url = $image->getUrl(); // The direct url
$title = $image->getTitle(); // The title, if available
$payload = $image->getPayload(); // The original payload
}
});
Responding
$botman->hears('Hi!', function (BotMan $bot) {
$bot->reply("Foo");
$bot->reply("Bar");
$bot->typesAndWaits(2); // It shows typing icon for 2 seconds...
$bot->reply("Baz!");
});
Responding with an image
use BotManBotManMessagesAttachmentsImage;
use BotManBotManMessagesOutgoingOutgoingMessage;
$botman->hears('Show me your logo', function (BotMan $bot) {
// Create attachment
$attachment = new Image('https://highsolutions.pl/images/logo-image.png');
// Build message object
$message = OutgoingMessage::create('Our logo')
->withAttachment($attachment);
// Reply message object
$bot->reply($message);
});
Conversations
$botman->hears('I want to create an account', function($bot) {
$bot->startConversation(new AccountRegisterConversation);
});
Conversations
class AccountRegisterConversation extends Conversation
{
protected $name;
protected $email;
public function run()
{
$this->askName();
}
public function askName()
{
$this->ask('What is your name?', function(Answer $answer) {
$this->name = $answer->getText();
$this->say('Nice to meet you, '. $this->name);
$this->askEmail();
});
}
public function askEmail()
{
$this->ask('Please provide your e-mail address:', function(Answer $answer) {
$this->email = $answer->getText();
// ... sending e-mail
$this->say('Thank you. We send confirmation e-mail to: '. $this->email);
});
}
}
Questions
public function askWhoWillWinNextMatch()
{
$this->ask('Who will win next match?', function (Answer $response) {
$this->say('Great, your answer is - ' . $response->getText());
});
}
Questions with predefined options
public function askForNextMatchWinner()
{
$question = Question::create('Who will win next match?')
->fallback(“Can’t say...”)
->callbackId('who_will_win_next_match')
->addButtons([
Button::create('Team A')->value('a'),
Button::create('Team B')->value('b'),
]);
$this->ask($question, function (Answer $answer) {
// Detect if button was clicked:
if ($answer->isInteractiveMessageReply()) {
$selectedValue = $answer->getValue(); // will be either 'a' or 'b'
$selectedText = $answer->getText(); // will be either 'Team A' or 'Team B'
}
});
}
Questions with patterns
public function askWhoWillWinNextMatch()
{
$this->ask('Who will win next match? [Real - Barca]', [
[
'pattern' => 'real|madrid|hala',
'callback' => function () {
$this->say('In Cristiano you trust!');
}
],
[
'pattern' => 'barca|barcelona|fcb',
'callback' => function () {
$this->say('In Messi you trust!');
}
]
]);
}
User information
/**
* Retrieve User information.
* @param IncomingMessage $matchingMessage
* @return UserInterface
*/
public function getUser(IncomingMessage $matchingMessage)
{
return new User($matchingMessage->getSender());
}
// Access user
$user = $bot->getUser();
Cache
$storage = $botman->userStorage();
$storage = $botman->channelStorage();
$storage = $botman->driverStorage();
$bot->userStorage()->save([
'name' => $name
]);
$bot->userStorage()->all();
$userInformation = $bot->userStorage()->find($id);
$name = $userInformation->get('name');
$bot->userStorage()->delete();
NLP
Hey, I am going to match Real - Barca on Sunday at 15:00 with Suzy.
{
"intent": "create_meeting",
"entities": {
"name" : "Match Real - Barca",
"invitees" : [‘Suzy’],
"time": "2017-03-11 15:00:00"
}
}
Middleware
Testing
/** @test */
public function test_simple_reply()
{
$this->bot
->receives('Hi')
->assertReply('Hello World!');
}
/** @test */
public function test_image_reply()
{
$this->bot
->receivesImage(['https://highsolutions.pl/images/logo-image.png'])
->assertReply('This is our logo!');
}
Testing
/** @test */
public function test_conversation()
{
$this->bot
->receives('Hi')
->assertReplies([
'Foo',
'Bar',
])->receives('And?')
->assertReply('Baz');
}
Web driver
Web widget
NLP model
Creating Chatbots with Botman - English
Messenger / Button Template
$bot->reply(ButtonTemplate::create('How do you like BotMan so far?')
->addButton(ElementButton::create('Quite good')->type('postback')->payload('quite-good'))
->addButton(ElementButton::create('Love it!')->url('https://botman.io'))
);
Messenger / Generic Template
$bot->reply(GenericTemplate::create()
->addElements([
Element::create('BotMan Documentation')
->subtitle('All about BotMan')
->image('http://botman.io/img/botman-body.png')
->addButton(ElementButton::create('visit')
->url('http://botman.io')
)
->addButton(ElementButton::create('tell me more')
->payload('tellmemore')
->type('postback')
),
Element::create('BotMan Laravel Starter')
->subtitle('This is the best way to start...')
->image('http://botman.io/img/botman-body.png')
->addButton(ElementButton::create('visit')
->url('https://github.com/botman/botman')
),
])
);
Messenger / List Template
$bot->reply(ListTemplate::create()
->useCompactView()
->addGlobalButton(ElementButton::create('view more')->url('http://buildachatbot.io'))
->addElement(
Element::create('BotMan Documentation')
->subtitle('All about BotMan')
->image('http://botman.io/img/botman-body.png')
->addButton(ElementButton::create('tell me more')
->payload('tellmemore')->type('postback'))
)
->addElement(
Element::create('BotMan Laravel Starter')
->subtitle('This is the best way to start...')
->image('http://botman.io/img/botman-body.png')
->addButton(ElementButton::create('visit')
->url('http://botman.io')
)
)
);
Messenger / Media Template
$bot->reply(MediaTemplate::create()
->element(MediaAttachmentElement::create('image')
->addButton(ElementButton::create('Tell me more')
->type('postback')
->payload('Tell me more'))
->addButton(ElementButton::create('Documentation')
->url('https://botman.io/'))));
Messenger Demo Viewer
Questions?
adam@highsolutions.pl
@AdamMatysiak
chatbot.highsolutions.pl

More Related Content

PDF
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
PDF
Functional Design Patterns (DevTernity 2018)
PDF
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
PDF
はてなブックマークにおけるアクセス制御 - 半環構造に基づくモデル化
PDF
How to optimize background processes - when Sylius meets Blackfire
PDF
Data-Driven UI/UX Design with A/B Testing
PDF
Functional Programming Patterns (BuildStuff '14)
PDF
Monadic Java
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Functional Design Patterns (DevTernity 2018)
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
はてなブックマークにおけるアクセス制御 - 半環構造に基づくモデル化
How to optimize background processes - when Sylius meets Blackfire
Data-Driven UI/UX Design with A/B Testing
Functional Programming Patterns (BuildStuff '14)
Monadic Java

What's hot (20)

PDF
The Power of Composition (NDC Oslo 2020)
PPTX
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
PPTX
Regular Expressions for Regular Joes (and SEOs)
PDF
Ksug2015 - JPA2, JPA 기초와매핑
PDF
DBMS 5 | MySQL Practice List - HR Schema
PPTX
Function in PL/SQL
PDF
Why HATEOAS
PDF
Reinventing the Transaction Script (NDC London 2020)
PDF
You code sucks, let's fix it
PDF
Domain Modeling Made Functional (DevTernity 2022)
PPTX
Slack presentation
PPTX
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
PPTX
MVC - Introduction
PDF
Deep Dive Java 17 Devoxx UK
PDF
Models for hierarchical data
PDF
The lazy programmer's guide to writing thousands of tests
PDF
Integrating React.js Into a PHP Application
PPTX
Express JS
PDF
Domain Modeling Made Functional (KanDDDinsky 2019)
PDF
SEO for Changing E-commerce Product Pages - How to Optimize your Online Store...
The Power of Composition (NDC Oslo 2020)
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Regular Expressions for Regular Joes (and SEOs)
Ksug2015 - JPA2, JPA 기초와매핑
DBMS 5 | MySQL Practice List - HR Schema
Function in PL/SQL
Why HATEOAS
Reinventing the Transaction Script (NDC London 2020)
You code sucks, let's fix it
Domain Modeling Made Functional (DevTernity 2022)
Slack presentation
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
MVC - Introduction
Deep Dive Java 17 Devoxx UK
Models for hierarchical data
The lazy programmer's guide to writing thousands of tests
Integrating React.js Into a PHP Application
Express JS
Domain Modeling Made Functional (KanDDDinsky 2019)
SEO for Changing E-commerce Product Pages - How to Optimize your Online Store...
Ad

Similar to Creating Chatbots with Botman - English (20)

PPTX
Laravel ua chatbot
PDF
Clustaar chatbot intervention for Crédit Agricole 19/05/2017
PDF
IRJET - A Study on Building a Web based Chatbot from Scratch
PDF
Oyoty - Lessons learnt building a “chatbot” for children
PPTX
Using Chatbots in Extension Programming
PDF
The PHP developer stack for building chatbots | Christoph Rumpel | CODEiD
PPTX
Isa632 final-presentation
PDF
PDF
chatbots.pdf
PPTX
Chatbots: It's like Uber for Conversations
DOCX
A Comprehensive Overview of Chatbot Development_ Tools and Best Practices.docx
PPTX
Building bots to automate common developer tasks - Writing your first smart c...
PDF
Chatbots for Brand Representation in Comparison with Traditional Websites
PDF
Chatler.ai Országos Ügyfélszolgálati Konferencia, 2017 Sümeg
PPTX
Banking Chatbot
PDF
Build powerful AI chatbots effortlessly with chatbot builder
 
DOCX
DEEPESH KUSHWAH PROJECT 3rd sem 1.docx
PDF
A concise guide to chatbots
PDF
The rise of Chatbots and Virtual Assistants in Customer Experience
PPTX
Chatbot Abstract
Laravel ua chatbot
Clustaar chatbot intervention for Crédit Agricole 19/05/2017
IRJET - A Study on Building a Web based Chatbot from Scratch
Oyoty - Lessons learnt building a “chatbot” for children
Using Chatbots in Extension Programming
The PHP developer stack for building chatbots | Christoph Rumpel | CODEiD
Isa632 final-presentation
chatbots.pdf
Chatbots: It's like Uber for Conversations
A Comprehensive Overview of Chatbot Development_ Tools and Best Practices.docx
Building bots to automate common developer tasks - Writing your first smart c...
Chatbots for Brand Representation in Comparison with Traditional Websites
Chatler.ai Országos Ügyfélszolgálati Konferencia, 2017 Sümeg
Banking Chatbot
Build powerful AI chatbots effortlessly with chatbot builder
 
DEEPESH KUSHWAH PROJECT 3rd sem 1.docx
A concise guide to chatbots
The rise of Chatbots and Virtual Assistants in Customer Experience
Chatbot Abstract
Ad

More from Laravel Poland MeetUp (20)

PDF
WebRTC+Websockety - Jak stworzyłem aplikację do kamerek internetowych w Larav...
PDF
xD bug - Jak debugować PHP-owe aplikacje (Xdebug)
PDF
Kilka slajdów o castowaniu atrybutów w Eloquent
PDF
Licencje otwartego oprogramowania
PDF
Jak przyspieszyłem aplikację produkcyjną o ponad 40%
PDF
Jak przemycić Shape Up do Scruma?
PDF
Cykl życia zapytania HTTP (pod maską)
PDF
Enumy w Laravelu - dlaczego warto stosować?
PDF
Laravelowe paczki do uwierzytelniania
PDF
Przegląd najciekawszych wtyczek do Laravela
PDF
Walidacja w Laravelu
PDF
(prawie) Wszystko o Tinkerze
PDF
Laravel Dusk - prosty przepis na testy E2E
PDF
Laravel Octane - czy na pewno taki szybki?
PDF
Laravel Jobs i PHP8
PDF
Wszystko o Laravel Livewire
PDF
Laravel/PHP - zderzenie z PDFami
PDF
Action-based Laravel
PDF
Automatyzacja utrzymania jakości w środowisku PHP
PDF
Wstęp do Gitlab CI/CD w aplikacjach napisanych w Laravel
WebRTC+Websockety - Jak stworzyłem aplikację do kamerek internetowych w Larav...
xD bug - Jak debugować PHP-owe aplikacje (Xdebug)
Kilka slajdów o castowaniu atrybutów w Eloquent
Licencje otwartego oprogramowania
Jak przyspieszyłem aplikację produkcyjną o ponad 40%
Jak przemycić Shape Up do Scruma?
Cykl życia zapytania HTTP (pod maską)
Enumy w Laravelu - dlaczego warto stosować?
Laravelowe paczki do uwierzytelniania
Przegląd najciekawszych wtyczek do Laravela
Walidacja w Laravelu
(prawie) Wszystko o Tinkerze
Laravel Dusk - prosty przepis na testy E2E
Laravel Octane - czy na pewno taki szybki?
Laravel Jobs i PHP8
Wszystko o Laravel Livewire
Laravel/PHP - zderzenie z PDFami
Action-based Laravel
Automatyzacja utrzymania jakości w środowisku PHP
Wstęp do Gitlab CI/CD w aplikacjach napisanych w Laravel

Recently uploaded (20)

DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Download FL Studio Crack Latest version 2025 ?
PDF
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PDF
Cost to Outsource Software Development in 2025
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Monitoring Stack: Grafana, Loki & Promtail
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Design an Analysis of Algorithms II-SECS-1021-03
Download FL Studio Crack Latest version 2025 ?
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Wondershare Filmora 15 Crack With Activation Key [2025
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Patient Appointment Booking in Odoo with online payment
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Digital Systems & Binary Numbers (comprehensive )
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Internet Downloader Manager (IDM) Crack 6.42 Build 41
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Cost to Outsource Software Development in 2025
Reimagine Home Health with the Power of Agentic AI​
wealthsignaloriginal-com-DS-text-... (1).pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Navsoft: AI-Powered Business Solutions & Custom Software Development
Monitoring Stack: Grafana, Loki & Promtail

Creating Chatbots with Botman - English

  • 2. Adam Matysiak CTO / Team Leader adam@highsolutions.pl
  • 3. What is chatbot? Definition: “A conversational user interface used for interaction with application”
  • 4. Where we can use it? - Automatic/interactive deployments - DevOps - Sales support (E-commerce) - Customer service support - Brand marketing - Blog/content promotion - Self-service (e.g. weather forecast, bus timetable etc.) - Fun - … ?
  • 6. The time is now? “Chatbot Market Size Is About To Reach $1.25 Billion By 2025” GrandViewResearch, August 2017
  • 9. BotMan composer create-project --prefer-dist botman/studio your-awesome-bot Requirements: PHP >= 7.0 ● https://botman.io/ - Documentation / Demo ● https://buildachatbot.io/ - Video course ● https://playground.botman.io/ - On-line IDE ● https://christoph-rumpel.com/build-chatbots-with-php - E-book
  • 10. Available services - Amazon Alexa - Cisco Spark - Facebook Messenger - HipChat - Kik - Microsoft Bot Framework - Nexmo - Slack - Telegram - Twilio - WeChat
  • 11. How chatbots work 1. Listening 🙉 2. Processing 🌀 3. Responding 📢
  • 13. Hear and respond... File botman.php in routes directory $botman->hears('Hi', function ($bot) { $bot->reply('Hello World!'); }); // Process incoming message $botman->listen();
  • 14. Sending to controller... $botman->hears('Hi', 'SomeNamespaceCommandController@respond'); class CommandController { public function respond($bot) { $bot->reply('Hello World!'); } }
  • 15. Parameters and regular expressions $botman->hears('I like {team}', function ($bot, $team) { $bot->reply('You like: '. $team); }); $botman->hears('.*(hi|hey|hello).*', function ($bot) { $bot->reply('Hello World!'); }); $botman->hears('I want to buy ([0-9]+) tickets', function ($bot, $number) { $bot->reply('I am ordering ’. $number .’ tickets for you!’); });
  • 16. Attachments (images, videos, localization etc.) $bot->receivesImages(function($bot, $images) { foreach ($images as $image) { $url = $image->getUrl(); // The direct url $title = $image->getTitle(); // The title, if available $payload = $image->getPayload(); // The original payload } });
  • 17. Responding $botman->hears('Hi!', function (BotMan $bot) { $bot->reply("Foo"); $bot->reply("Bar"); $bot->typesAndWaits(2); // It shows typing icon for 2 seconds... $bot->reply("Baz!"); });
  • 18. Responding with an image use BotManBotManMessagesAttachmentsImage; use BotManBotManMessagesOutgoingOutgoingMessage; $botman->hears('Show me your logo', function (BotMan $bot) { // Create attachment $attachment = new Image('https://highsolutions.pl/images/logo-image.png'); // Build message object $message = OutgoingMessage::create('Our logo') ->withAttachment($attachment); // Reply message object $bot->reply($message); });
  • 19. Conversations $botman->hears('I want to create an account', function($bot) { $bot->startConversation(new AccountRegisterConversation); });
  • 20. Conversations class AccountRegisterConversation extends Conversation { protected $name; protected $email; public function run() { $this->askName(); } public function askName() { $this->ask('What is your name?', function(Answer $answer) { $this->name = $answer->getText(); $this->say('Nice to meet you, '. $this->name); $this->askEmail(); }); } public function askEmail() { $this->ask('Please provide your e-mail address:', function(Answer $answer) { $this->email = $answer->getText(); // ... sending e-mail $this->say('Thank you. We send confirmation e-mail to: '. $this->email); }); } }
  • 21. Questions public function askWhoWillWinNextMatch() { $this->ask('Who will win next match?', function (Answer $response) { $this->say('Great, your answer is - ' . $response->getText()); }); }
  • 22. Questions with predefined options public function askForNextMatchWinner() { $question = Question::create('Who will win next match?') ->fallback(“Can’t say...”) ->callbackId('who_will_win_next_match') ->addButtons([ Button::create('Team A')->value('a'), Button::create('Team B')->value('b'), ]); $this->ask($question, function (Answer $answer) { // Detect if button was clicked: if ($answer->isInteractiveMessageReply()) { $selectedValue = $answer->getValue(); // will be either 'a' or 'b' $selectedText = $answer->getText(); // will be either 'Team A' or 'Team B' } }); }
  • 23. Questions with patterns public function askWhoWillWinNextMatch() { $this->ask('Who will win next match? [Real - Barca]', [ [ 'pattern' => 'real|madrid|hala', 'callback' => function () { $this->say('In Cristiano you trust!'); } ], [ 'pattern' => 'barca|barcelona|fcb', 'callback' => function () { $this->say('In Messi you trust!'); } ] ]); }
  • 24. User information /** * Retrieve User information. * @param IncomingMessage $matchingMessage * @return UserInterface */ public function getUser(IncomingMessage $matchingMessage) { return new User($matchingMessage->getSender()); } // Access user $user = $bot->getUser();
  • 25. Cache $storage = $botman->userStorage(); $storage = $botman->channelStorage(); $storage = $botman->driverStorage(); $bot->userStorage()->save([ 'name' => $name ]); $bot->userStorage()->all(); $userInformation = $bot->userStorage()->find($id); $name = $userInformation->get('name'); $bot->userStorage()->delete();
  • 26. NLP Hey, I am going to match Real - Barca on Sunday at 15:00 with Suzy. { "intent": "create_meeting", "entities": { "name" : "Match Real - Barca", "invitees" : [‘Suzy’], "time": "2017-03-11 15:00:00" } }
  • 28. Testing /** @test */ public function test_simple_reply() { $this->bot ->receives('Hi') ->assertReply('Hello World!'); } /** @test */ public function test_image_reply() { $this->bot ->receivesImage(['https://highsolutions.pl/images/logo-image.png']) ->assertReply('This is our logo!'); }
  • 29. Testing /** @test */ public function test_conversation() { $this->bot ->receives('Hi') ->assertReplies([ 'Foo', 'Bar', ])->receives('And?') ->assertReply('Baz'); }
  • 34. Messenger / Button Template $bot->reply(ButtonTemplate::create('How do you like BotMan so far?') ->addButton(ElementButton::create('Quite good')->type('postback')->payload('quite-good')) ->addButton(ElementButton::create('Love it!')->url('https://botman.io')) );
  • 35. Messenger / Generic Template $bot->reply(GenericTemplate::create() ->addElements([ Element::create('BotMan Documentation') ->subtitle('All about BotMan') ->image('http://botman.io/img/botman-body.png') ->addButton(ElementButton::create('visit') ->url('http://botman.io') ) ->addButton(ElementButton::create('tell me more') ->payload('tellmemore') ->type('postback') ), Element::create('BotMan Laravel Starter') ->subtitle('This is the best way to start...') ->image('http://botman.io/img/botman-body.png') ->addButton(ElementButton::create('visit') ->url('https://github.com/botman/botman') ), ]) );
  • 36. Messenger / List Template $bot->reply(ListTemplate::create() ->useCompactView() ->addGlobalButton(ElementButton::create('view more')->url('http://buildachatbot.io')) ->addElement( Element::create('BotMan Documentation') ->subtitle('All about BotMan') ->image('http://botman.io/img/botman-body.png') ->addButton(ElementButton::create('tell me more') ->payload('tellmemore')->type('postback')) ) ->addElement( Element::create('BotMan Laravel Starter') ->subtitle('This is the best way to start...') ->image('http://botman.io/img/botman-body.png') ->addButton(ElementButton::create('visit') ->url('http://botman.io') ) ) );
  • 37. Messenger / Media Template $bot->reply(MediaTemplate::create() ->element(MediaAttachmentElement::create('image') ->addButton(ElementButton::create('Tell me more') ->type('postback') ->payload('Tell me more')) ->addButton(ElementButton::create('Documentation') ->url('https://botman.io/'))));