Upload
seongsik-choi
View
574
Download
1
Embed Size (px)
Citation preview
LINE Bot(Messaging API)
최성식
Messaging API?
LINE 에서 제공하는 Bot 개발용 API
* 기존 BOT API Trial Account 서비스는 2016 년 11 월 16 일부로 종료
Messaging API 구조
Messaging API 는 LINE Server 를 통해 데이터를 ( 봇 ) 서버와 LINE 앱 사이에 릴레이하는 방식으로 작동하며 요청은 JSON 형식의 API 를 통해 전송됩니다 .
Messaging API 플랜
Messaging API SDK
+ Node.js : line-messaging(unofficial)
Messaging API 설정 및 시작하기
https://developers.line.me/messaging-api/getting-started
Messaging API 기능• Webhooks• Push Message API• Reply Message API• Get Contents API• Get Profile API• Leave API
Messaging API 기능• Webhooks
봇 서버가 사용자의 이벤트를 수신• Push Message API• Reply Message API• Get Contents API• Get Profile API• Leave API
Webhooks① 봇이 존재하는 채팅방에서 이벤트가 발생한다 .
② Webhooks 을 통해 Webhooks URL 로 등록된 봇 서버로 이벤트를 HTTPS POST request 방식으로 수신한다 .
③ 수신된 이벤트를 봇 서버에서 처리한다 .
④ 처리된 결과물을 이벤트가 발생된 채팅방으로 전송한다 .
LINE 서버로부터 봇 서버로 전달되는 이벤트 (JSON)
① “replyToken” 사용자가 봇에게 메세지를 보내고 , 봇이 그에 응답할 때 필요한 토큰
② “type” event 타입
③ “timestamp”④ “source”
a. “type” 사용자가 봇에게 메세지를 보내는 채팅방의 유형
b. “xxxxID” 채팅방의 식별자
⑤ “message” (message event)a. “id”
메세지 식별자b. ”type”
메세지 종류c. “text”
메세지 내용
① “replyToken” 사용자가 봇에게 메세지를 보내고 , 봇이 그에 응답할 때 필요한 토큰
② “type” event 타입
③ “timestamp”④ “source”
a. “type” 사용자가 봇에게 메세지를 보내는 채팅방의 유형
b. “xxxxID” 채팅방의 식별자
⑤ “message” (message event)a. “id”
메세지 식별자b. ”type”
메세지 종류c. “text”
메세지 내용
+Beacon event
① “replyToken” 사용자가 봇에게 메세지를 보내고 , 봇이 그에 응답할 때 필요한 토큰
② “type” event 타입 message, follow, unfollow, join, leave, post-
back
③ “timestamp”④ “source”
a. “type” 사용자가 봇에게 메세지를 보내는 채팅방의 유형
b. “xxxxID” 채팅방의 식별자
⑤ “message” (message event)a. “id”
메세지 식별자b. ”type”
메세지 종류c. “text”
메세지 내용LINE 서버로부터 봇 서버로 전달되는 이벤트 (JSON)
① “replyToken” 사용자가 봇에게 메세지를 보내고 , 봇이 그에 응답할 때 필요한 토큰
② “type” event 타입 message, follow, unfollow, join, leave, post-
back
③ “timestamp”④ “source”
a. “type” 사용자가 봇에게 메세지를 보내는 채팅방의 유형
b. “xxxxID” 채팅방의 식별자
⑤ “message” (message event)a. “id”
메세지 식별자b. ”type”
메세지 종류c. “text”
메세지 내용
Group
User
Room
① “user”봇과 사용자간의 1:1 대화“type” : “user”
”userId” : “xxxxxxxxx”
② ”group”그룹내에서 그룹원과 봇과의 대화“type” : “group”
“groupID” : “xxxxxxxxx“
③ “room”룸안에서 룸 구성원과 봇과의 대화“type” : “room”
“roomID” : “xxxxxxx”
userID 의 경우 user 의 식별자 그룹과 룸내의 구성원 개인 userID 는 알 수 없음
Messaging API 기능• Webhooks• Push Message API
봇이 사용자에게 보내는 이벤트• Reply Message API
사용자와 봇이 서로 소통하는 기능• Get Contents API• Get Profile API• Leave API
① “replyToken” 사용자가 봇에게 메세지를 보내고 , 봇이 그에 응답할 때 필요한 토큰
② “type” event 타입 message, follow, unfollow, join, leave, post-
back
③ “timestamp”④ “source”
a. “type” 사용자가 봇에게 메세지를 보내는 채팅방의 유형
b. “xxxxID” 채팅방의 식별자
⑤ “message” (message event)a. “id”
메세지 식별자b. ”type”
메세지 종류c. “text”
메세지 내용LINE 서버로부터 봇 서버로 전달되는 이벤트 (JSON)
Send message object• Text : 최대 2000 자까지• Image : 최대 1024x1024, 1MB (JPEG)• Video : 최대 1 분이하 , 10MB (mp4)• Audio : 최대 1 분이하 , 10MB (m4a)• Location : 위도와 경도 + title, address 최대 100 자까지• Sticker : sticker list - https://devdocs.line.me/files/sticker_list.pdf• Imagemap• template
URL 링크는 최대 1000 자까지
Send message object
Imagemap
Send message object
template
Messaging API 기능• Webhooks• Push Message API• Reply Message API• Get Contents API
사용자로부터 전송된 image, video, and audio 컨텐츠를 검색하는 API• Get Profile API• Leave API
Messaging API 기능• Webhooks• Push Message API• Reply Message API• Get Contents API• Get Profile API
사용자의 Profile 을 가져오는 API• Leave API
Get Profile API
Messaging API 기능• Webhooks• Push Message API• Reply Message API• Get Contents API• Get Profile API• Leave API
• 봇이 그룹이나 룸을 떠나게 하는 API
Messaging API 기능• Webhooks• Push Message API• Reply Message API• Get Contents API• Get Profile API• Leave API
+LINE Beacon
LINE Beacon• LINE 사용자가 LINE Beacon 에 접근하여 LINE bot 이 Web-
hooks 을 통해 알림을 받았을 때 특정 서비스를 제공하도록 하는 기능• 2016 년 9 월 이후 특정 회사나 개인사업자에게만 출시된 상태이며 , 추후에 보편화할 계획• 하나의 계정은 하나의 비콘에만 연결 될 수있음
Reference• Messaging API intro
https://business.line.me/ko/companies/1236120/services/bot• Messaging API documents
https://developers.line.me/messaging-api/overview• Messaging API Reference
https://devdocs.line.me/en/?java#messaging-api• Line-messaging(Node.js)
https://www.npmjs.com/package/line-messaging• Imagemap 그림 참고
http://www.slideshare.net/flashscope/line-bot-api-trial
Q & A