Host Line Bot with Golang
-
Upload
evan-lin -
Category
Technology
-
view
198 -
download
1
Transcript of Host Line Bot with Golang
![Page 1: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/1.jpg)
Host Line Bot on Heroku with Golang
Evan Lin
![Page 2: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/2.jpg)
Agenda• Line Bot API Capability and Limitation
• Setup Line Bot Trial on Heroku
• Advance usage:
• Send a picture, when user type some text.
• Create a “Hello” message when add your bot as new friend.
• Project Demo: Line Bot
![Page 3: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/3.jpg)
Line Bot Capability and Limitation
• No Rich message (Link message)
• No dashboard
• Cannot talk with multiple People
• Cannot invite into chat room
![Page 4: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/4.jpg)
Step 1: Request Line Bot Trial AccountApply Line Bot trial account here
(Only 1 per Line Account)
![Page 5: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/5.jpg)
Step 2: Deploy to Heroku by one click
Link : https://github.com/kkdai/LineBotTemplate
![Page 6: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/6.jpg)
Step 2: Deploy to Heroku by one click
Remember this addreess
![Page 7: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/7.jpg)
Step 3: Setup Fixed IP for white list (not mandatory)
• NOT MANDATORY! (Let empty also works)
• Two ways to setup Fixie in Heroku
• Using Heroku Dashboard
• Using Heroku Toolbelt
![Page 8: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/8.jpg)
Step 3: Setup Fixed IP for white list (not mandatory)
• Through Heroku dashboard:
• Launch Heroju dashboard
• Go your deploy app page
• Go to “Resource"
• Go to "FIND MORE ADD-ONS”
• Find “Fixie"
• Through Heroku Toolbelt
![Page 9: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/9.jpg)
Step 3: Setup Fixed IP for white list (not mandatory)
• Through Heroku Toolbelt
• $ heroku login
• $ heroku git:clone -a <YOUR_HEROKU_APP_ID>
• $ cd linebotkkdaitest
• $ heroku addons:create fixie:tricycle
![Page 10: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/10.jpg)
Step 4. 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 11: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/11.jpg)
Step 5. Get related Line Bot info for Heroku App setting
• Need copy following variable:
• Channel ID
• Channel Secret
• MID
Need copy those three
![Page 12: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/12.jpg)
Step 6. 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 13: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/13.jpg)
Send a Image to user
Parse bot request to received result
![Page 14: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/14.jpg)
Send a Image to user
Make sure it is text message not operation
![Page 15: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/15.jpg)
Send a Image to user
Send image to who text to the bot
![Page 16: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/16.jpg)
“Hello” message from Line Bot
Hello
![Page 17: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/17.jpg)
Send a “Hello” message when add bot as friend
Determine the operation type
![Page 18: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/18.jpg)
Send a “Hello” message when add bot as friend
Get request from ID, this is only way for now
![Page 20: Host Line Bot with Golang](https://reader034.fdocuments.in/reader034/viewer/2022051123/58776f341a28ab5b568b566d/html5/thumbnails/20.jpg)
Q&A