The bot provides subscribing and notifying open data - air pollution.
Using 所有縣市
trigger and start bot.
It builds by:
- flask/Python 3.8
- LINE v10.12
- LINE Notify
- LINE Login/LIFF v2.3
- PostgreSQL
You need Github, LINE, Heroku accounts to deploy this bot.
These properties are need to export in environment.
LINE_CHANNEL_ACCESS_TOKEN=
LINE_CHANNEL_SECRET=
LINE_NOTIFY_CLIENT_ID=
LINE_NOTIFY_CLIENT_SECRET=
LINE_NOTIFY_REDIRECT_URI=
LIFF_BIND_ID=
LIFF_CONFIRM_ID=
LIFF_SHARE_ID=
DATABASE_URL=postgres://USER:[email protected]:5432/postgres
- Got A LINE Bot API developer account Make sure you already registered, if you need use LINE Bot.
- Go to LINE Developer Console
- Close auto-reply setting on "Messaging API" Tab.
- Setup your basic account information. Here is some info you will need to know.
- Callback URL:
https://{YOUR_URL}/webhooks/line
- Verify your webhook.
- Callback URL:
- You will get following info, need fill back to
.env
file.- Channel Secret
- Channel Access Token (You need to issue one here)
- Input
https://{YOUR_URL}/notify
into binding LIFF app. - Input
https://{YOUR_URL}/notify/callback
into callback LIFF app.
- Input your key into
LINE_NOTIFY_CLIENT_ID
andLINE_NOTIFY_CLIENT_SECRET
- Copy
callback LIFF app
url to NOTIFY callback url column.
- first terminal window
cp .env.example .env
pip install -r requirements.txt --user
python api.py
- Create a provisional Https:
ngrok http 5000
or maybe you have npm environment:
npx ngrok http 5000
- Copy url to LINE Developer Console
Click Configure Add-ons
and input Heroku Scheduler
to install scheduler.
-
Add two jobs on
Heroku Schedular
:python scripts/sync_to_sql.py
python scripts/notify_me.py
-
Add
Heroku Postgres
and it would createDATABASE_URL
environment variable automatically.
If you are not sure where are files in, use following up commands:
heroku run bash
heroku logs --tail
You need to install openapi-generator
, and use the following command to generate the SDK.(example is JavaScript)
openapi-generator generate -i https://{YOUR_URL}.herokuapp.com/api/swagger.json -g javascript -o lotifySampleApi
cd lotifySampleApi
npm install
npm run build
Push to your Repository Center(e.g. GitHub, GitLab).
Then you can install it by git.
MIT License