chatbots in php - highsolutions phpce - matysiak - chatbots.pdf · where we can use it? •...
TRANSCRIPT
![Page 1: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/1.jpg)
How to create chatbots
in PHP (and why)?
![Page 3: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/3.jpg)
Link to this presentation
https://joind.in/talk/968d2
![Page 4: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/4.jpg)
What is chatbot?
Definition:
“A conversational
user interface
used for interaction
with application”
![Page 5: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/5.jpg)
![Page 6: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/6.jpg)
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
• … ?
![Page 7: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/7.jpg)
![Page 8: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/8.jpg)
The time is now?
“Chatbot Market Size Is About To
Reach $1.25 Billion By 2025” GrandViewResearch, August 2017
![Page 9: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/9.jpg)
Data source: https://neilpatel.com/blog/open-rates-facebook-messenger
![Page 10: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/10.jpg)
How chatbot works?
1. Listening 🙉
2. Processing 🌀
3. Responding 📢
![Page 11: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/11.jpg)
![Page 12: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/12.jpg)
Mixed
Conversational Wizard-like
Types of chatbots
![Page 13: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/13.jpg)
Broadcasting
![Page 14: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/14.jpg)
![Page 15: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/15.jpg)
Marcel Pociot
Managing Partner @beyondcode
@marcelpociot
![Page 16: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/16.jpg)
Installation
Laravel:
composer global require "botman/installer"
botman new <directory>
php artisan serve
Vanilla PHP:
composer require "botman/botman"
![Page 17: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/17.jpg)
Requirements
PHP >= 7.1.3
![Page 18: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/18.jpg)
Available services
Amazon Alexa
Cisco Spark
Messenger
HipChat
Kik
Microsoft Bot
Framework
Nexmo
Slack
Telegram
Twilio
![Page 19: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/19.jpg)
routes/botman.php
![Page 20: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/20.jpg)
Controllers
![Page 21: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/21.jpg)
Parameters
![Page 22: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/22.jpg)
Regular expressions
![Page 23: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/23.jpg)
Attachments
![Page 24: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/24.jpg)
Responding
![Page 25: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/25.jpg)
Response with an image
![Page 26: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/26.jpg)
Questions
![Page 27: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/27.jpg)
Predefined options
![Page 28: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/28.jpg)
Starting conversations
![Page 29: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/29.jpg)
Simple conversation
![Page 30: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/30.jpg)
Questions with patterns
![Page 31: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/31.jpg)
User information
![Page 32: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/32.jpg)
Cache
![Page 33: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/33.jpg)
NLP / NLU
![Page 34: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/34.jpg)
NLP
Hey, I am going to PHPCE conference in Prague on Saturday at 10:00 with Grzegorz.
{"intent": "create_meeting","entities": {
"name": "PHPCE conference in Prague","invitees": ["Grzegorz"],"time": "2018-10-27 10:00:00"
}}
![Page 35: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/35.jpg)
NLP
![Page 36: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/36.jpg)
Middlewares
![Page 37: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/37.jpg)
Testing
![Page 38: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/38.jpg)
Testing
![Page 39: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/39.jpg)
Web driver
![Page 40: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/40.jpg)
Web widget
![Page 41: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/41.jpg)
![Page 42: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/42.jpg)
Button Template
![Page 43: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/43.jpg)
Button Template
![Page 44: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/44.jpg)
Generic Template
![Page 45: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/45.jpg)
Generic Template
![Page 46: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/46.jpg)
List Template
![Page 47: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/47.jpg)
List Template
![Page 48: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/48.jpg)
Media Template
![Page 49: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/49.jpg)
Media Template
![Page 50: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/50.jpg)
Quick replies
![Page 51: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/51.jpg)
Quick replies
![Page 52: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/52.jpg)
Quick replies
![Page 53: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/53.jpg)
Quick replies
![Page 54: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/54.jpg)
Quick replies
![Page 55: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/55.jpg)
Menu
https://developers.facebook.com/docs/messenger-platform/reference/messenger-profile-api/persistent-menu
![Page 56: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/56.jpg)
User information
• Facebook Identifier
• First name and Last name
• Avatar
• Gender
• Interface language
• Timezone
• …
![Page 57: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/57.jpg)
Messenger Demo Viewer
![Page 58: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/58.jpg)
Connecting bot with Messenger
1. Create a Facebook page
2. Create a Facebook app
3. Get your page token
1. Add new product > Messenger
2. Select your new Facebook Page
3. Copy token and paste into configuration
4. Setup webhook for Messenger
1. Provide URL to your BotMan instance (/botman)
2. Provide verification token
5. Activate your bot on the Page
![Page 59: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/59.jpg)
BotMan Playground
![Page 60: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/60.jpg)
BotMan Playgroundhttps://playground.botman.io/user/zjezak/test#botman.php
![Page 61: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/61.jpg)
Where to get knowledge from?
• https://botman.io/ - Documentation / Demo
• https://botman.github.com - GitHub
• https://slack.botman.io/ - Slack for BotMan programmers
• https://buildachatbot.io/ - Video course
• https://playground.botman.io/ - On-line IDE
• https://christoph-rumpel.com/build-chatbots-with-php - E-book
• https://leanpub.com/chatbot – E-book
• https://www.youtube.com/watch?v=rz1lN-fKHHw - Marcel Pociot’s speech at PHP UK Conference 2018
![Page 62: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/62.jpg)
Questions?
![Page 63: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer](https://reader034.vdocument.in/reader034/viewer/2022042303/5ece31176bbfcd2591179174/html5/thumbnails/63.jpg)
Link to this presentation
https://joind.in/talk/968d2