https://github.com/kerkerjoking/businesscard_linebot_gemini_notion
The NameCard_Bot is a Python-based application that integrates with LINE Messaging API and Google Gemini API to extract information from business card images.
https://github.com/kerkerjoking/businesscard_linebot_gemini_notion
gemini linebot notion python
Last synced: 10 days ago
JSON representation
The NameCard_Bot is a Python-based application that integrates with LINE Messaging API and Google Gemini API to extract information from business card images.
- Host: GitHub
- URL: https://github.com/kerkerjoking/businesscard_linebot_gemini_notion
- Owner: KerKerJoking
- Created: 2024-06-06T09:21:52.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-08-29T09:26:18.000Z (9 months ago)
- Last Synced: 2025-04-02T05:03:15.114Z (about 2 months ago)
- Topics: gemini, linebot, notion, python
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [Python] Line名片機器人(Gemini、Notion) - 部署及操作說明
## 一、 取得程式碼
**從 GitHub 取得程式碼**
在選定的資料夾開啟命令提示字元(cmd),並執行以下指令從 GitHub Clone專案:
```bash
git clone https://github.com/KerKerJoking/BusinessCard_LineBot_Gemini_Notion
```## 二、 Gemini、Line、Notion 環境準備
### 取得 Google API Key
前往 [Google AI Studio](https://aistudio.google.com/app/apikey) 創建 API Key,這會用於將名片照面提交給 Google Gemini 模型進行識別並回傳 Json 格式資料。

### 取得 LINE Access Token / Channel Secret
登入 [LINE Developers](https://developers.line.biz/console/),如果還沒有建立Bot就先建立一個,Access Token 可以在 Messaging API 頁面找到,Channel Secret 可以在 Basic settings 頁面找到。


### 取得 Notion Integration Secret
登入 Notion,進入 [Integrations](https://www.notion.so/profile/integrations),創建新的 Integration 並取得 Integration Secret。

### 建立 Notion DB
在你的 Notion 頁面建立一個新的 Data Base 用來儲存名片資訊,Data Base ID 會是 DB 頁面網址中 "/" 之後 "?v=" 之前的中間這段文字。
Data Base 的 Tittle 欄位名稱改為 "UUID",另外分別建立欄位: "Name"、"Phone"、"Email"、"Address"、"Tittle"、"Company",欄位格式一律使用 Text。
另外需要將剛剛建立的 Integration 連結到這個 Data Base,這樣我們才能透過 API 存取這裡面的資料。

## 三、 執行程式
### 執行 setup.bat
進入 Clone 下來的專案目錄,並執行 `setup.bat`,首次執行會自動建立一個 `venv` 環境,並安裝所有使用到的套件。
### 依序填入資訊
首次執行時程式會要求填入你所使用的 API 資訊,此時將稍早取得的所有 API 資訊依序填入即可,完成後會顯示 “Running on http://127.0.0.1:5000",表示執行成功了。

## 四、 Ngrok 與 LINE Webhook 設定
這段主要是要讓我們執行的程式有一個對外服務的網址,若可以的話,修改程式碼自行對外 host 是更好的做法,但測試時可以用 ngrok。
### 下載並設定 Ngrok
前往 [Ngrok 官方網站](https://dashboard.ngrok.com/get-started/setup/windows),下載適用於 Windows 的 Ngrok 執行檔,並將兩行指令複製下來。

### 執行 Ngrok
從 ngrok 所在資料夾開啟命令提示字元(cmd),並執行剛剛從 ngrok 網站複製下來的兩條指令,不過第二條指令的 port 號 8000 要修改為 5000。執行成功後會出現一個 Forwarding 的網址,這個要複製起來貼給我們的 Linebot。



## 五、功能實測
### 新增名片紀錄
透過 Linebot 對話視窗傳送名片照片,程式會將名片的資訊提取出來回復在對話視窗,並同時將資料儲存到 Notion Data Base。

### 查詢名片資料
直接輸入名片擁有者的名字、公司名稱、職稱等訊息片段,Linebot 會從 Notion Data Base 查詢相關的名片資料,並直接回覆在對話視窗。

### 編輯名片資料
若需編輯某一筆名片資料,可以使用 `/edit` 指令,編輯成功後,Linebot 會回應該欄位已成功更新的訊息,並重新查詢該名片的資料以確認更新是否正確。

### 刪除名片資料
使用 `/del` 指令來刪除特定的名片資料,刪除成功後,Linebot 會回應已成功刪除該 UUID 的訊息。
