owned this note
owned this note
Published
Linked with GitHub
---
title: 2020 計理 Project
tags: ToC, 2020
description: View the slide with "Slide Mode".
---
# ToC Project 2020
slide:
https://hackmd.io/@TTW/ToC-2019-Project#
TAs: 陳彥儒、王麒淞
----
# Goal
Build a Line Bot with FSM ([SampleCode](https://github.com/NCKU-CCS/TOC-Project-2020))

---
## Outline
- Requestments
- Sample Code
- 評分標準
- 教學文件
- 參考題材
- 注意事項
---
## Requestments
1. Python ver. >= 3.6
2. Line Developer
3. 部署 - Heroku / AWS(加分項)
Deadline: 2019/12/11
---
# 1.Python
[python安裝教學](https://hackmd.io/@sky/local-pyenv)
---
# 2.Line Bot

----
註冊網站:https://developers.line.biz/zh-hant/

----
登入帳號

----
登入帳號

----
選擇 Create New Provider 以建立 Bot

----
設定 Provider name

----
Create

----
Messaging API > Create Channel

----
上傳照片、填寫 APP 名稱、描述、信箱

注意: APP 名稱註冊後 7 天內不能更改
----
Done

----
取得 secret

----
取得 access token

---
# 3.部署 - Heroku
----
註冊網站: https://signup.heroku.com/

語言選 python
----
new APP

----
new APP

app-name 只能小寫
地區只能選美國或歐洲, 選哪個都行
----
Get CLI

----
Get CLI

----
Get CLI

----
login CLI

在 terminal 輸入 `heroku login`
按下任意鍵會打開瀏覽器進行 login
----
login CLI

----
login CLI

----
login CLI

----
push to heroku (use git)
```
heroku git:remote -a {HEROKU_APP_NAME}
git add .
git commit -m "commint msg"
git push -f heroku master
```
[git tutorial](https://backlog.com/git-tutorial/tw/intro/intro2_1.html)
----
將 Heroku 與 Line 綁定

URL = https://{HEROKU_APP_NAME}.herokuapp.com/{route}
---
## Sample Code

https://github.com/NCKU-CCS/TOC-Project-2020
----
"go to state1" -> Triger state1
"go to state2" -> Triger state2

----
# 檔案結構

----
## 安裝套件 [ref](https://medium.com/@chihsuan/pipenv-%E6%9B%B4%E7%B0%A1%E5%96%AE-%E6%9B%B4%E5%BF%AB%E9%80%9F%E7%9A%84-python-%E5%A5%97%E4%BB%B6%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7-135a47e504f4)
`pip3 install -r requirements.txt`
or
`pipenv install --three`
----
/.env

----
/utils.py

----
/fsm.py

----
Webhook event objects
```{
"destination": "xxxxxxxxxx",
"events": [
{
"replyToken": "0f3779fba3b349968c5d07db31eab56f",
"type": "message",
"timestamp": 1462629479859,
"source": {
"type": "user",
"userId": "U4af4980629..."
},
"message": {
"id": "325708",
"type": "text",
"text": "Hello, world"
}
}
]
}
```
----
/app.py - fsm

----
/app.py - line setting

----
/app.py - line bot route

----
/app.py - print fsm

---
### 評分方式
- 基本(60%)
- 呈現(10%)
- 功能性(10%)
- 創意(10%)
- 額外加分(5~10%)
----
基本(60%)
1. FSM Diagram
2. Demo 運作正常
3. 最少兩個 states
----
呈現(10%)
- Doc
- Demo 操作流暢度
- 講解
----
功能性(10%)
- FSM 複雜度 (不是單看 states 多寡)
- CRUD (Create, Read, Update, Delete)
- Parsing
----
創意(10%)
- 主題, 產業, 時事
----
額外加分(4~10%)
```
1. AWS (10%)
AWS 教育版回報: https://forms.gle/vWMY1ZwVYbjHvw7S8
2. 增加功能
- 圖像, 影片 (4%)
- 爬蟲 (火車時刻表, 新聞, 天氣...) (6%)
- 連 DB (4%)
- ML (8%)
- BlockChain (8%)
- ...
```
----
額外加分(4~10%)
```
3. 用戶獨立的 state machine (10%)
讓每個連進 Bot 的用戶都有獨立的 machine,
而不是後加入的人會進到前面人目前的 state 並共用 machine
4. 多平台 (FB, IG, ...) (5%)
```
---
### 繳交方式
1. 截止日期前將專案上傳至 GitHub 並設成 public
2. 在 Google 表單填入 repo 網址
3. Deadline : 12/11 12pm
4. 預約 DEMO 時間 (12/12-12/17)
表單:https://forms.gle/VL3NA65jYyXvKWC2A
---
### 去年範例
1. [網美ig](https://github.com/iknowright/messengerbot) [name=張財實] 100分
2. [圈圈叉叉](https://hackmd.io/@44WIexypT0qDttURuc98iA/S1GCfktbE?type=slide#/) [name=林郁翔] 99分
3. [女朋友解惑](https://github.com/ire33164/Girlfriend_chatbot) [name=林志嘉] 91分
---
## 參考題材
[台灣事實查核中心](https://tfc-taiwan.org.tw/)
[2020總統候選人知識時查核計畫](https://www.readr.tw/project/fact-check-2020?fbclid=IwAR067uvtENS6lwUoh-W3yQGCNiKvnZ3kriRuRriKBiwynv2eiKbbpPJt1OM)
[Cofacts 真的假的](https://cofacts.g0v.tw/)
---
### 教學文件
- [Line Developer 註冊](/34brdrfLS92MpgTrECa5gg)
- [LINE 開發環境](/ZOyAxFZcRBe8v4kcscb0zQ)
- [Heroku](https://devcenter.heroku.com/articles/getting-started-with-python)
- [LineBot + python + Heroku](https://yaoandy107.github.io/line-bot-tutorial/)
- [ngrok](https://blog.techbridge.cc/2018/05/24/ngrok/)
---
## 注意事項
Heroku 太久沒用可能會休眠,請耐心等待
Line Reply Token 僅能使用一次
免費版 Line Bot 好友上限 50 人
----
### 如遇到問題想詢問,請 follow 以下格式
主旨:[Final Project] 簡述遇到的問題
```
內文:
- 姓名學號:
- 系統環境:
- 系統版本:
- 套件版本:
- 在哪一個步驟遇到的問題:
- 詳述問題:
- 完整的錯誤訊息:
- 已經試過的解決方法:
- 在這個問題上已經花費的時間:
```
---
## 參考資料
- [去年 FAQ](https://hackmd.io/@ccw/B1Xw7E8kN?type=view)
---