https://github.com/alfex4936/rust-server
Frontend + Backend + 카카오톡 아주대 챗봇 in Rust language
https://github.com/alfex4936/rust-server
chatbot kakako-chatbot kakao mysql rest rest-api rust sql web
Last synced: 12 months ago
JSON representation
Frontend + Backend + 카카오톡 아주대 챗봇 in Rust language
- Host: GitHub
- URL: https://github.com/alfex4936/rust-server
- Owner: Alfex4936
- License: mit
- Created: 2021-07-09T14:16:56.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-07-18T04:39:15.000Z (over 2 years ago)
- Last Synced: 2025-03-29T03:04:14.113Z (about 1 year ago)
- Topics: chatbot, kakako-chatbot, kakao, mysql, rest, rest-api, rust, sql, web
- Language: Rust
- Homepage:
- Size: 19.8 MB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rocket + MySQL + HTML
카카오톡 챗봇 + Backend + Frontend 프로젝트 in Rust
# Structure
[chatbot/](https://github.com/Alfex4936/Rust-Server/tree/main/chatbot) : 카카오 챗봇 (actix)
[src/routes/](https://github.com/Alfex4936/Rust-Server/tree/main/src/routes) : endpoints
tests/ : unittest
# Endpoints
## TODO
카카오 챗봇 JSON 로컬에서 미리보는 사이트
어떠한 방식으로? 1번 구현 후 2번 버전 시도가 나을 듯
1. 자신의 JSON 데이터를 복사해서 입력하면 그걸 메시지로 변환 시키는 방식
(여기서 발화 메시지는 json 해석 후 알맞는 형태로)
(Rust로 메시지 Deserialize 하고 형식에 맞는 HTML 코드 GET return?)
2. 사이트 자체를 local에 받게한 후 실행 후 POST 방식

## GET `/front/`
프론트 엔드 테스트
숫자에 맞게 공지사항을 파싱해서 HTML에 전달


## GET `/db`
MySQL 연동 테스트
```json
[
{
"id": 1,
"start_date": "07.06 (화)",
"end_date": "07.09 (금)",
"content": "내용"
},
]
```
## POST `/notice`
HTML 파싱
```json
[
{
"id": 13727,
"title": "제목",
"date": "21.07.15",
"link": "링크",
"writer": "글쓴이"
},
]
```
## POST `/yesterday`
```sql
SELECT * FROM notices WHERE date = ? ORDER BY id DESC
```
=> query
```json
[
{
"id": 11111,
"title": "제목1",
"date": "21.07.15",
"link": "링크1",
"writer": "글쓴이1"
},
{
"id": 11110,
"title": "제목2",
"date": "21.07.15",
"link": "링크2",
"writer": "글쓴이2"
},
]
```
## 카카오 챗봇 `ListCard`
```rust
#[test]
fn result_json() {
let mut result = Template::new();
result.add_qr(QuickReply::new(
"message".to_string(),
"라벨".to_string(),
"메시지".to_string(),
));
let mut list_card = ListCard::new("title".to_string());
list_card.add_button(Box::new(
CallButton::new("msg".to_string()).set_number("010-1234-5678".to_string()),
));
list_card.add_button(Box::new(ShareButton::new("msg".to_string())));
list_card.add_item(ListItem::new("제목".to_string()).set_desc("설명".to_string()));
result.add_output(json!(list_card));
println!("Result: {}", serde_json::to_string(&result).expect("Woah"));
}
```
=>
```yaml
{
"template": {
"outputs": [
{
"listCard": {
"buttons": [
{
"action": "phone",
"label": "msg",
"phoneNumber": "010-1234-5678"
},
{
"action": "share",
"label": "msg"
}
],
"header": {
"title": "title"
},
"items": [
{
"description": "설명",
"title": "제목"
}
]
}
}
],
"quickReplies": [
{
"action": "message",
"label": "라벨",
"messageText": "메시지"
}
]
},
"version": "2.0"
}
```