Skip to content

Alfex4936/KakaoChatBot-Golang

Repository files navigation

카카오톡 챗봇 Gin 서버 (Go언어)

@아주대 공지 챗봇 MIT LICENSE

block1 / block2

AWS RDS (MySQL 모델)

사용

AWS EC2 + S3 + RDS

ubuntu:~$ export GOROOT=/usr/local/go/
ubuntu:~$ export GOPATH=~/gopath
ubuntu:~$ export PATH=$PATH:$GOROOT/bin

ubuntu:~$ aws s3 sync s3://bucket/kakao_server kakao_server

ubuntu:~/kakao_server$ go run main.go

기능

카카오 챗봇

title, items, text... 길이를 넘기면 제대로 출력이 안될 수도 있다.

simpleText: text(1000)

ListCard: header(15), list_title(35), list_description(16), lists(5)

Carousel: items(10)

카카오 챗봇 API JSON Model

type KakaoJSON struct {
	Action struct {
		ID          string `json:"id"`
		ClientExtra struct {
		} `json:"clientExtra"`
		DetailParams map[string]interface{} `json:"detailParams"`
		Name         string                 `json:"name"`
		Params       map[string]interface{} `json:"params"`
	} `json:"action"`
	Bot struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"bot"`
	Contexts []interface{} `json:"contexts"`
	Intent   struct {
		ID    string `json:"id"`
		Extra struct {
			Reason struct {
				Code    int64  `json:"code"`
				Message string `json:"message"`
			} `json:"reason"`
		} `json:"extra"`
		Name string `json:"name"`
	} `json:"intent"`
	UserRequest struct {
		Block struct {
			ID   string `json:"id"`
			Name string `json:"name"`
		} `json:"block"`
		Lang   string `json:"lang"`
		Params struct {
			IgnoreMe bool   `json:"ignoreMe,string"`
			Surface  string `json:"surface"`
		} `json:"params"`
		Timezone string `json:"timezone"`
		User     struct {
			ID         string `json:"id"`
			Properties struct {
				BotUserKey  string `json:"botUserKey"`
				BotUserKey2 string `json:"bot_user_key"`
			} `json:"properties"`
			Type string `json:"type"`
		} `json:"user"`
		Utterance string `json:"utterance"`
	} `json:"userRequest"`
}

예제 JSON 반응

"2021 검색"

INFO: server - "POST /search HTTP/1.1" 200 OK

{
    "action": {
        "clientExtra": {},
        "detailParams": {
            "sys_text": {
                "groupName": "",
                "origin": "2021",
                "value": "2021"
            }
        },
        "id": "id",
        "name": "스킬 이름",
        "params": {
            "sys_text": "2021"
        }
    },
    "bot": {
        "id": "id",
        "name": "AjouNotice"
    },
    "contexts": [],
    "intent": {
        "extra": {
            "reason": {
                "code": 1,
                "message": "OK"
            }
        },
        "id": "id",
        "name": "공지 키워드 검색"
    },
    "userRequest": {
        "block": {
            "id": "id",
            "name": "공지 키워드 검색"
        },
        "lang": "kr",
        "params": {
            "ignoreMe": "true",
            "surface": "BuilderBotTest"
        },
        "timezone": "Asia/Seoul",
        "user": {
            "id": "id",
            "properties": {
                "botUserKey": "key",
                "bot_user_key": "key"
            },
            "type": "botUserKey"
        },
        "utterance": "2021 검색\n"
    }
}

POST = /today, /yesterday | 발화 = "어제 공지 알려줘", "오늘 공지 알려줘"...

POST = /today2

"오늘" 공지에서 더보기를 누르면 10개+ 정도의 공지를 더 불러옵니다.

(5개 이하일 시 아주대 홈피로 이동됨)

POST = /last | 발화 = "지난 공지 알려줘", "마지막 공지"...

entity =

POST = /ask | 발화 = "카테고리", "분류"...

POST = /search | 발화 = "카테고리", "분류"...

entity = 분류 필요

POST = /schedule | 발화 = "달력", "일정" ...

entity = 분류 필요

TO-DO: Selenium을 통한 자동 db 업데이트

(수원 영통구 날씨를 weather.naver.com에서 불러옴)

POST = /info/weather2 | 발화 = "날씨", "아주대 날씨", "날씨 좋아?" ...

POST = /info/prof | 발화 = "인물"

"인물" 입력 후 키워드 검색

TO-DO: 더 나은 발화문

POST = /info/library | 발화 = "도서관", "좌석"

발화문 입력 시 중앙도서관 좌석 이용 현황을 불러옵니다.

TO-DO: 더 나은 메시지 포맷

POST = /info/meal | 발화 = "오늘 학식", "내일 학생", "내일 교직원", "내일 기숙사" ...

오늘/내일 장소를 입력하면 시간에 맞는 장소의 학식 정보를 불러옵니다.

TO-DO: 더 나은 메시지 포맷

About

Go언어 gin 웹 프레임워크를 이용한 아주대학교 카카오 챗봇 (KakaoTalk Chatbot w/ Go)

Topics

Resources

License

Stars

Watchers

Forks