Host Line Bot with Golang

20
Host Line Bot on Heroku with Golang Evan Lin

Transcript of Host Line Bot with Golang

Page 1: Host Line Bot with Golang

Host Line Bot on Heroku with Golang

Evan Lin

Page 2: Host Line Bot with Golang

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

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

Step 1: Request Line Bot Trial AccountApply Line Bot trial account here

(Only 1 per Line Account)

Page 5: Host Line Bot with Golang

Step 2: Deploy to Heroku by one click

Link : https://github.com/kkdai/LineBotTemplate

Page 6: Host Line Bot with Golang

Step 2: Deploy to Heroku by one click

Remember this addreess

Page 7: Host Line Bot with Golang

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

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

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

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

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

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

Send a Image to user

Parse bot request to received result

Page 14: Host Line Bot with Golang

Send a Image to user

Make sure it is text message not operation

Page 15: Host Line Bot with Golang

Send a Image to user

Send image to who text to the bot

Page 16: Host Line Bot with Golang

“Hello” message from Line Bot

Hello

Page 17: Host Line Bot with Golang

Send a “Hello” message when add bot as friend

Determine the operation type

Page 18: Host Line Bot with Golang

Send a “Hello” message when add bot as friend

Get request from ID, this is only way for now

Page 19: Host Line Bot with Golang

Live Demohttps://github.com/kkdai/LineBotPetNeedMe

Page 20: Host Line Bot with Golang

Q&A