[RUBY] A note about getting stuck when making a parrot return LINE bot on Heroku + Sinatra

I tried to develop LINE Bot for the first time. First of all, it is a LINE Bot that returns from simple things. If you have any suggestions such as "misunderstanding", I would appreciate it if you could let me know.

Let's make a LINE Bot using Sinatra

I made a LineBot that returns parrots to Reply with Heroku + Ruby + Sinatra

The outline was done according to this article. Although I went to the end, I got into a situation where ** "I did not get a reply" **, so I will make a note of the solution.

スクリーンショット 2020-05-16 14.14.10.png

Cause / what you did for "no reply"

Cause 1: You were entering a token or channel secret directly in your code

https://github.com/line/line-bot-sdk-ruby

There is such a ↓ code in the SDK of LINE Bot, but I have entered the TOKEN etc. that I wrote down directly. This was a mistake and I set it as an environment variable in Heroku's [Config Vars], so this was fine.

app.rb


# app.rb
require 'sinatra'
require 'line/bot'

def client
  @client ||= Line::Bot::Client.new { |config|
#The following three IDs,SECRET,I was typing TOKEN.This is OK as it is!
    config.channel_id = ENV["LINE_CHANNEL_ID"]
    config.channel_secret = ENV["LINE_CHANNEL_SECRET"]
    config.channel_token = ENV["LINE_CHANNEL_TOKEN"]
  }
end

↓ ↓ Heroku setting screen ↓ ↓ Set ID, SECRET, TOKEN here

スクリーンショット_2020-05-16_14_41_21.jpg

Cause 2: You didn't push your local changes to Heroku

I modified the code locally to fix cause 1. The change wasn't reflected in Heroku because it was only changed locally. If you look closely, Herokun also had such a description. Execute the following command to push to Heroku

Deploy your changes Make some changes to the code you just cloned and deploy them to Heroku using Git.

$ git add . $ git commit -am "make it better" $ git push heroku master

After trying these two, it came back safely.

Safely completed

gazou.jpg

Completed, but still not sure

Do you need Fixie, Heroku's add on? ??

Through trial and error, I found the following article. I looked at the article and tried to insert Fixie, but it works even if I delete it, so I will investigate it a little more.

Run LINE BOT on Heroku for free

I was addicted to the LINE BOT API

Recommended Posts

A note about getting stuck when making a parrot return LINE bot on Heroku + Sinatra
A note when the heroku command becomes unavailable
I made a LINE bot with Rails + heroku
Deploy Line bot with rails5 + Docker + Heroku Note
Let's make a LINE Bot with Ruby + Sinatra --Part 2
Let's make a LINE Bot with Ruby + Sinatra --Part 1