Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Modern Web 2016
Using Golang to build smart IM Bot
Evan Lin @LinkerNetworkshttp://goo.gl/IYv1BU
About Me
• Cloud Architect @ Linker
Networks
• Top 10 Taiwan Golang open
source contributor (github
award)
• Developer, Cu...
Agenda
• What is IM Bot
• Introduce Golang
• Build Line Bot
• Build FB Bot
• Build a smart IM Bot
• Future
• Q&A
Instant Message Bot
What is IM?
(Instant Messenger)
What is IM Bot?
How to choose
programming language
• Easy to Write
• Fast in Run and
Compile
• Powerful Concurrency
• Powerful Built-in
To...
Pokemon GO
Programming GO
What is Go(lang)
• Create by Google
• Design by
• Ken Thompson
• Rob Pike
• Robert Griesemer,
• Feature:
• Compiled
• Stat...
Why Golang
• GO Fast!
• Compile Fast!
• Run Fast!
Go is Fast
Why Golang
• Make programming
fun again.
gofmt / goimport
Before we look code
Before we look code (cont)
After file save..
Go Vet
Analysis on source code and reports
suspicious constructs.
Go Lint
Coding style suggestions
GoRoutine:
Multiple Thread in C
GoRoutine:
Multiple Thread in Go
GoRoutine and Channel:
Multiple Thread in Go
GoRoutine and Channel:
Multiple Thread in Go
GoRoutine and Channel:
Multiple Thread in Go
https://talks.golang.org/2014/gocon-tokyo.slide
Golang - HTTPS Server
Golang - HTTPS Server
Supported
HTTP/2
After Go 1.6
Golang - Built-In Test
Golang - Built-In Benchmark Test
GoMobile
Original Work Flow
Golang
Sample Console
Sometime Failed
Work
Failed on Some Model
GoMobile
Using Golang in Mobile
Golang
GoMobile
Package


Golang
Sample Console
Go Playground:
Write A snippet Go code online
https://play.golang.org/
Go JSON Tutorial
Go JSON Tutorial
Go JSON Tutorial
Golang IDE
(Integrated Development Environment)
Golang IDE
(Integrated Development Environment)
VIM-GO
Golang IDE
(Integrated Development Environment)
Visual Studio Code Go Extension
Let’s build IM Bot.
Wait!
What is IM Bot working
flow?
IM Bot Working Flow:
HTTPS Webhook
How to prepare HTTPS
server?
• Prepare a machine with
public IP
• Install related OS and
runtime for your
programming lang...
Introduce Heroku
(Platform As A Service)
Free-tier
Heroku
(Platform As A Service)
• Free-tier:
• USES AN ACCOUNT-
BASED POOL
• OF FREE DYNO HOURS
• SLEEPS AFTER 30 MINS OF
I...
IM Bot Working Flow
(update)
HTTPS Webhook
Build IM Line Bot
Step 1: Request Line Bot Trial Account
Apply Line Bot trial account here
(Only 1 per Line Account)
Step 2: Deploy to Heroku by
one click
Link : https://github.com/kkdai/LineBotTemplate
Step 2: Deploy to Heroku by
one click
Remember this address
Step 3. Fill your Heroku App
Callback address to Line Bot
• Copy your app
address from
Heroku to Line
Dashboard.
• It will...
Step 4. Get related Line Bot
info for Heroku App setting
• Need copy
following
variable:
• Channel ID
• Channel Secret
• M...
Step 5. Fill your Line Bot
Information to Heroku Variables
• In Heroku [Dashboard] ->
[Settings]-> [Config
Variables]
• Cre...
Send a Image to user
Parse bot request to received result
Send a Image to user
Make sure it is text message not operation
Send a Image to user
Send image to who text to the bot
“Hello” message from Line
Bot
Hello
Send a “Hello” message when add bot as
friend
Determine the operation type
Send a “Hello” message when add bot as
friend
Get request from ID, this is only way for now
Example: PetNeedMe
https://github.com/kkdai/LineBotPetNeedMe
Build Facebook Bot
Step 1: Deploy to Heroku
Link : https://github.com/kkdai/FBBotTemplate
Remember this address
Step 2: Create Facebook
Page
Step 3: Create App for
Messenger
• Create new app
“Web App”
• Select new
product
“Messenger”
Step 4: Create App Token
• Select generate
token.
• Need a “Page”
Step 5: Paste token to
Heroku Variable
Step 6: Setup Page
Subscription for Messenger Bot
https://APP_ADDRESS.herokuapp.com/webhook
Token we just generate
Step 7: Select a Page for
your Webhooks
Step 8: Select a Page for
your Webhooks
Example: PetNeedMe
Build A Smart IM Bot
IM ?
IM Bot 10 years ago
“ ”
: https://briian.com/2536/msn-bot.html
IM Bot 10 years later
“Fugle ”
• Left Brain
• Logical
• Verbal
• Language
?
?
?
?
?
?
?
?
?
?
?
Intent: ??
Entity: ??
?
Intent: Check Weather
Entity: ??
?
Intent: Check Weather
Entity: Taipei
Use LUIS to build smart
Bot
Use LUIS to build smart
Bot
LUIS
Other Natural Language
Processing Tool
Future
Future :
Bot to Bot (No more API)
Future :
Customer Service Bot
http://www.mobile01.com/topicdetail.php?f=383&t=4078424
Future :
For Your Website and Business
Future :
For Your Website and Business
Future :
How About Build Right Brain?
We are Hiring..

1. NFV/SDN Expert
2. Data Engineer
http://weekly.codetengu.com/
Go
Call For Speaker
Modern Web 2016: Using Golang to build a smart IM Bot
Modern Web 2016: Using Golang to build a smart IM Bot
Modern Web 2016: Using Golang to build a smart IM Bot
Modern Web 2016: Using Golang to build a smart IM Bot
Modern Web 2016: Using Golang to build a smart IM Bot
Upcoming SlideShare
Loading in …5
×

Modern Web 2016: Using Golang to build a smart IM Bot

3,132 views

Published on

A talk for modern web 2016 to introduce how to use Golang to write a smart IM Bot

Published in: Internet

Modern Web 2016: Using Golang to build a smart IM Bot

  1. 1. Modern Web 2016 Using Golang to build smart IM Bot Evan Lin @LinkerNetworkshttp://goo.gl/IYv1BU
  2. 2. About Me • Cloud Architect @ Linker Networks • Top 10 Taiwan Golang open source contributor (github award) • Developer, Curator, Blogger
  3. 3. Agenda • What is IM Bot • Introduce Golang • Build Line Bot • Build FB Bot • Build a smart IM Bot • Future • Q&A
  4. 4. Instant Message Bot
  5. 5. What is IM? (Instant Messenger)
  6. 6. What is IM Bot?
  7. 7. How to choose programming language • Easy to Write • Fast in Run and Compile • Powerful Concurrency • Powerful Built-in Toolchain
  8. 8. Pokemon GO
  9. 9. Programming GO
  10. 10. What is Go(lang) • Create by Google • Design by • Ken Thompson • Rob Pike • Robert Griesemer, • Feature: • Compiled • Statically Typed • Garbage Collection
  11. 11. Why Golang • GO Fast! • Compile Fast! • Run Fast!
  12. 12. Go is Fast
  13. 13. Why Golang • Make programming fun again.
  14. 14. gofmt / goimport
  15. 15. Before we look code
  16. 16. Before we look code (cont)
  17. 17. After file save..
  18. 18. Go Vet Analysis on source code and reports suspicious constructs.
  19. 19. Go Lint Coding style suggestions
  20. 20. GoRoutine: Multiple Thread in C
  21. 21. GoRoutine: Multiple Thread in Go
  22. 22. GoRoutine and Channel: Multiple Thread in Go
  23. 23. GoRoutine and Channel: Multiple Thread in Go
  24. 24. GoRoutine and Channel: Multiple Thread in Go
  25. 25. https://talks.golang.org/2014/gocon-tokyo.slide
  26. 26. Golang - HTTPS Server
  27. 27. Golang - HTTPS Server Supported HTTP/2 After Go 1.6
  28. 28. Golang - Built-In Test
  29. 29. Golang - Built-In Benchmark Test
  30. 30. GoMobile Original Work Flow Golang Sample Console Sometime Failed Work Failed on Some Model
  31. 31. GoMobile Using Golang in Mobile Golang GoMobile Package 
 Golang Sample Console
  32. 32. Go Playground: Write A snippet Go code online https://play.golang.org/
  33. 33. Go JSON Tutorial
  34. 34. Go JSON Tutorial
  35. 35. Go JSON Tutorial
  36. 36. Golang IDE (Integrated Development Environment)
  37. 37. Golang IDE (Integrated Development Environment) VIM-GO
  38. 38. Golang IDE (Integrated Development Environment) Visual Studio Code Go Extension
  39. 39. Let’s build IM Bot.
  40. 40. Wait! What is IM Bot working flow?
  41. 41. IM Bot Working Flow: HTTPS Webhook
  42. 42. How to prepare HTTPS server? • Prepare a machine with public IP • Install related OS and runtime for your programming language • Purchase CA signed for SSL Key ($$) • Run a HTTPS Webserver (Apache or Go native Web Server)
  43. 43. Introduce Heroku (Platform As A Service) Free-tier
  44. 44. Heroku (Platform As A Service) • Free-tier: • USES AN ACCOUNT- BASED POOL • OF FREE DYNO HOURS • SLEEPS AFTER 30 MINS OF INACTIVITY • CUSTOM DOMAINS • HTTPS connection (for non-custom domains) • Support one click deploy
  45. 45. IM Bot Working Flow (update) HTTPS Webhook
  46. 46. Build IM Line Bot
  47. 47. Step 1: Request Line Bot Trial Account Apply Line Bot trial account here (Only 1 per Line Account)
  48. 48. Step 2: Deploy to Heroku by one click Link : https://github.com/kkdai/LineBotTemplate
  49. 49. Step 2: Deploy to Heroku by one click Remember this address
  50. 50. Step 3. Fill your Heroku App Callback address to Line Bot • Copy your app address from Heroku to Line Dashboard. • It will be something like “https:// xxxxxx.herokuapp. com:443/callback” Fill your app dress here
  51. 51. Step 4. Get related Line Bot info for Heroku App setting • Need copy following variable: • Channel ID • Channel Secret • MID Need copy those three
  52. 52. Step 5. Fill your Line Bot Information to Heroku Variables • In Heroku [Dashboard] -> [Settings]-> [Config Variables] • Create following variables: • ChannelID • ChannelSecret • MID • Fill with you just got from Line Bot Dashboard.
  53. 53. Send a Image to user Parse bot request to received result
  54. 54. Send a Image to user Make sure it is text message not operation
  55. 55. Send a Image to user Send image to who text to the bot
  56. 56. “Hello” message from Line Bot Hello
  57. 57. Send a “Hello” message when add bot as friend Determine the operation type
  58. 58. Send a “Hello” message when add bot as friend Get request from ID, this is only way for now
  59. 59. Example: PetNeedMe https://github.com/kkdai/LineBotPetNeedMe
  60. 60. Build Facebook Bot
  61. 61. Step 1: Deploy to Heroku Link : https://github.com/kkdai/FBBotTemplate
  62. 62. Remember this address
  63. 63. Step 2: Create Facebook Page
  64. 64. Step 3: Create App for Messenger • Create new app “Web App” • Select new product “Messenger”
  65. 65. Step 4: Create App Token • Select generate token. • Need a “Page”
  66. 66. Step 5: Paste token to Heroku Variable
  67. 67. Step 6: Setup Page Subscription for Messenger Bot https://APP_ADDRESS.herokuapp.com/webhook Token we just generate
  68. 68. Step 7: Select a Page for your Webhooks
  69. 69. Step 8: Select a Page for your Webhooks
  70. 70. Example: PetNeedMe
  71. 71. Build A Smart IM Bot
  72. 72. IM ?
  73. 73. IM Bot 10 years ago “ ” : https://briian.com/2536/msn-bot.html
  74. 74. IM Bot 10 years later “Fugle ”
  75. 75. • Left Brain • Logical • Verbal • Language
  76. 76. ?
  77. 77. ? ?
  78. 78. ? ? ? ? ? ? ?
  79. 79. ? Intent: ?? Entity: ??
  80. 80. ? Intent: Check Weather Entity: ??
  81. 81. ? Intent: Check Weather Entity: Taipei
  82. 82. Use LUIS to build smart Bot
  83. 83. Use LUIS to build smart Bot
  84. 84. LUIS
  85. 85. Other Natural Language Processing Tool
  86. 86. Future
  87. 87. Future : Bot to Bot (No more API)
  88. 88. Future : Customer Service Bot http://www.mobile01.com/topicdetail.php?f=383&t=4078424
  89. 89. Future : For Your Website and Business
  90. 90. Future : For Your Website and Business
  91. 91. Future : How About Build Right Brain?
  92. 92. We are Hiring..
 1. NFV/SDN Expert 2. Data Engineer
  93. 93. http://weekly.codetengu.com/
  94. 94. Go Call For Speaker

×