Modern Web 2016
Using Golang to build smart IM Bot
Evan Lin @LinkerNetworks
Slide 2
Slide 2 text
Agenda
• Introduce Golang
• Build Line Bot
• Build FB Bot
• Build a smart IM Bot
• Future
• Q&A
Slide 3
Slide 3 text
About Me
• Cloud Architect @ Linker
Networks
• Top 10 Taiwan Golang open
source contributor (github
award)
• Developer, Curator, Blogger
Slide 4
Slide 4 text
What is Go(lang)
• Create by Google
• Design by
• Ken Thompson
• Rob Pike
• Robert Griesemer,
• Feature:
• Compiled
• Statically Typed
• Garbage Collection
Slide 5
Slide 5 text
Why Golang
• GO Fast!
• Compile Fast!
• Run Fast!
Slide 6
Slide 6 text
Why Golang
Slide 7
Slide 7 text
Why Golang
• Make programming
fun again.
Slide 8
Slide 8 text
gofmt / goimport
Slide 9
Slide 9 text
No content
Slide 10
Slide 10 text
No content
Slide 11
Slide 11 text
After file save..
Slide 12
Slide 12 text
GoRoutine:
Multiple Thread in C
Slide 13
Slide 13 text
GoRoutine:
Multiple Thread in Go
Slide 14
Slide 14 text
Golang - HTTPS Server
Slide 15
Slide 15 text
Golang - HTTPS Server
Supported
HTTP/2
After Go 1.6
Slide 16
Slide 16 text
Golang - Built-In Test
Slide 17
Slide 17 text
Golang - Built-In Benchmark Test
Slide 18
Slide 18 text
Build Line Bot
Slide 19
Slide 19 text
Step 1: Request Line Bot Trial Account
Apply Line Bot trial account here
(Only 1 per Line Account)
Slide 20
Slide 20 text
Step 2: Deploy to Heroku by
one click
Link : https://github.com/kkdai/LineBotTemplate
Slide 21
Slide 21 text
Step 2: Deploy to Heroku by
one click
Remember this address
Slide 22
Slide 22 text
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
Slide 23
Slide 23 text
Step 4. Get related Line Bot
info for Heroku App setting
• Need copy
following
variable:
• Channel ID
• Channel Secret
• MID
Need copy those three
Slide 24
Slide 24 text
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.
Slide 25
Slide 25 text
Send a Image to user
Parse bot request to received result
Slide 26
Slide 26 text
Send a Image to user
Make sure it is text message not operation
Slide 27
Slide 27 text
Send a Image to user
Send image to who text to the bot
Slide 28
Slide 28 text
“Hello” message from Line
Bot
Hello
Slide 29
Slide 29 text
Send a “Hello” message when add bot as
friend
Determine the operation type
Slide 30
Slide 30 text
Send a “Hello” message when add bot as
friend
Get request from ID, this is only way for now