Page 1
Golang Taipei Gathering #16
Using Golang to build smart IM Bot
Evan Lin @LinkerNetworks
Page 2
About Me
• Cloud Architect @ Linker Networks
• Top 10 Taiwan Golang open source contributor (github award)
• Developer, Curator, Blogger
Page 3
How to choose programming language
• Easy to Write
• Fast in Run and Compile
• Powerful Concurrency
• Powerful Built-in Toolchain
Page 6
https://talks.golang.org/2014/gocon-tokyo.slide
Page 8
Before we look code
Page 9
Before we look code (cont)
Page 12
After file save..
Page 13
GoMobileOriginal Work Flow
GolangSample Console
Sometime Failed
Work
Failed on Some Model
Page 14
GoMobileUsing Golang in Mobile
GolangGoMobilePackage
GolangSample Console
Page 15
Golang IDE(Integrated Development Environment)
Visual Studio Code Go Extension
Page 16
Build IM Line Bot
Page 17
Step 1: Request Line Bot Trial Account
Apply Line Bot trial account here (Only 1 per Line Account)
Page 18
Step 2: Deploy to Heroku by one click
Link : https://github.com/kkdai/LineBotTemplate
Page 19
Step 2: Deploy to Heroku by one click
Remember this address
Page 20
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
Page 21
Step 4. Get related Line Bot info for Heroku App setting
• Need copy following variable:
• Channel ID
• Channel Secret
• MID
Need copy those three
Page 22
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.
Page 23
Send a Image to user
Parse bot request to received result
Page 24
Send a Image to user
Make sure it is text message not operation
Page 25
Send a Image to user
Send image to who text to the bot
Page 26
“Hello” message from Line Bot
Hello
Page 28
Send a “Hello” message when add bot as friend
Determine the operation type
Page 29
Expect Result Actual Result
No “id” and “from” in “content”.We need use the value from “param[0]” to find who send the invitation
http://www.evanlin.com/line-bot-sdk-survey/
Page 30
Send a “Hello” message when add bot as friend
Get request from ID, this is only way for now
Page 31
Example: PetNeedMehttps://github.com/kkdai/LineBotPetNeedM
e
Page 32
Build Facebook Bot
Page 33
Step 1: Deploy to Heroku
Link : https://github.com/kkdai/FBBotTemplate
Page 34
Remember this address
Page 35
Step 2: Create Facebook Page
Page 36
Step 3: Create App for Messenger
• Create new app “Web App”
• Select new product “Messenger”
Page 37
Step 4: Create App Token
• Select generate token.
• Need a “Page”
Page 38
Step 5: Paste token to Heroku Variable
Page 39
Step 6: Setup Page Subscription for Messenger Bot
https://APP_ADDRESS.herokuapp.com/webhook
Token we just generate
Page 40
Step 7: Select a Page for your Webhooks
Page 41
Step 8: Select a Page for your Webhooks
Page 42
Example: PetNeedMe
Page 44
IM Bot 10 years ago“有問必達”
圖片重灌狂人: https://briian.com/2536/msn-bot.html
Page 45
IM Bot 10 years later“Fugle股市小幫手”
Page 47
• Left Brain
• Logical
• Verbal
• Language
Page 50
台北天氣如何?台北冷嗎
?
台北天氣好嗎
?
台北天氣怎麼樣?
台北天空是什麼顏色?
台北有下雨嗎?
去台北需要帶傘嗎?
Page 51
台北天氣如何?Intent: ??
Entity: ??
Page 52
台北天氣如何?Intent: Check Weather
Entity: ??
Page 53
台北天氣如何?Intent: Check Weather
Entity: Taipei
Page 54
Use LUIS to build smart Bot
Page 55
Use LUIS to build smart Bot
Page 57
Other Natural Language Processing Tool
Page 59
Future : Bot to Bot (No more API)
\
Page 60
Future : Customer Service Bot
http://www.mobile01.com/topicdetail.php?f=383&t=4078424
Page 61
Future : For Your Website and
Business
Page 62
Future : For Your Website and
Business
Page 63
Future : How About Build Right Brain?
\
Page 64
\
We are Hiring..
1. Senior Data ScientistFr
2. Senior Front-end
Page 65
歡迎訂閱 碼天狗
http://weekly.codetengu.com/