Advertisement

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

Evan Lin
Software Professional with Passion at Linker Networks Inc.
Aug. 17, 2016
Advertisement

More Related Content

Advertisement
Advertisement

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

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