chatbots in php - highsolutions phpce - matysiak - chatbots.pdf · where we can use it? •...

64
How to create chatbots in PHP (and why)?

Upload: others

Post on 25-May-2020

1 views

Category:

Documents


0 download

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

How to create chatbots

in PHP (and why)?

Page 2: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer

Adam Matysiak

CTO

[email protected]

Page 3: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer

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

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
Page 6: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer

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
Page 8: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer

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

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

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
Page 12: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer

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

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
Page 15: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer

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

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

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

Available services

Amazon Alexa

Cisco Spark

Facebook

Messenger

HipChat

Kik

Microsoft Bot

Framework

Nexmo

Slack

Telegram

Twilio

WeChat

Page 19: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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
Page 42: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Link to this presentation

https://joind.in/talk/968d2

Page 64: Chatbots in PHP - HighSolutions PHPCE - Matysiak - Chatbots.pdf · Where we can use it? • Automatic/interactive deployments • DevOps • Sales support (E-commerce) • Customer

Adam Matysiak

@adammatysiak

[email protected]