Skip to content

eddielin0926/LineTalk

Repository files navigation

LineTalk - TOC Project 2021

A Line bot based on a finite state machine for TOC Project 2021
Github repository: https://github.com/Eddielin0926/FSM-Line-Bot

Usage

  • Enter @bot for calling the menu

  • Select 設定個人資訊 to set your personal profile

  • Select 配對設定 to set your personal preference

  • Select 開始配對 to start talking to others

  • While chatting, enter @bot to call the menu

  • Select 我要猜拳🖐 to start a rock paper scissors

  • Select 幫我想話題💬 to list some random topic

  • Select 我要離開🏃 to leave the chat

Setup

Prerequisite

  • Conda (Anaconda/Miniconda)

Install Dependency

  • Create Conda environment
$ conda create --name toc python=3.6
$ conda activate toc
  • Install pygraphviz
(toc) $ conda install -c conda-forge pygraphviz
  • Install other dependencies
(toc) pip install python-dotenv pygraphviz transitions line-bot-sdk flask colorama

Secret Data

  • Creat .env file and fill in your channel info
LINE_CHANNEL_SECRET=<your_line_channel_secret>
LINE_CHANNEL_ACCESS_TOKEN=<your_line_channel_access_token>
PORT=8000

Ngrok

  • Download Ngrok and execute
ngrok http 8000

Line Webhook

  • Update webhook url Concate the url generate by Ngrok with /webhook (/callback) and put it to line bot channel

Run Locally

  • Start Conda environment
$ conda activate toc
  • Execute program
(toc) $ python app.py

Finite State Machine

fsm

Deploy

Deploy the Line-bot server on Heroku.

Heroku

Connect to Heroku

$ heroku login

Setup Environment on Heroku

  • Setup environment variables
heroku config:set LINE_CHANNEL_SECRET=<your_line_channel_secret>
heroku config:set LINE_CHANNEL_ACCESS_TOKEN=<your_line_channel_access_token>
  • Fix pygraphviz intall error
heroku buildpacks:set heroku/python
heroku buildpacks:add --index 1 heroku-community/apt

Connect Github Repository to Heroku

  • Connect to your Github repository

  • If you have pushed to Github, you can use manual deploy

  • You can also use automatic deploy. Once you push your repository, Heroku will start deploy.

Complete

  • url: {HEROKU_APP_NAME}.herokuapp.com/callback
  • logs: heroku logs --tail --app {HEROKU_APP_NAME}

Reference

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published