8.1개요
작동방식
고객이 "LINE 공식 계정"을 친구로 등록 후 메시지를 보냅니다.
LINE 플랫폼은 "JEDAI 상담톡 발신/수신 서버(이하 JEDAI 상담톡 서버)"의 "Webhook URL"로 "Webhook Event"를 보냅니다.
"Webhook Event"에 따라 "JEDAI 상담톡 서버"는 "JEDAI 서버"와 "상담원" 간의 절차를 진행 후 받은 메시지를 LINE 플랫폼을 통해 고객에게 응답합니다.
1:1 채팅을 위한 이벤트
Message 수신
고객이 메시지를 보내는 이벤트가 발생하면 "LINE 플랫폼"은 "Webhook URL(JEDAI 상담톡 서버)"에 HTTPS POST 요청을 보냅니다.
"JEDAI 상담톡 서버"는 수신받은 메시지를 "JEDAI 서버"로 POST 요청을 보냅니다.
Postback 수신
고객이 수신받은 메시지의 버튼이나 이미지를 탭하는 등의 이벤트가 발생하면 "LINE 플랫폼"은 "Webhook URL(JEDAI 상담톡 서버)"에 HTTPS POST 요청을 보냅니다.
"JEDAI 상담톡 서버"는 수신받은 메시지를 "JEDAI 서버"로 POST 요청을 보냅니다.
수신 도메인에 prefix (line)를 추가 해야합니다. (ex : https://tkakao.uconnect.co.kr/line )
8.1.1시퀀스 다이어그램 (Sequence Diagram)
그림 8-1Line Sequence Diagram
8.2수신 이벤트
8.2.1메시지 수신
"is_message_attachment" 값이 true 일 경우
"Line biz 상담톡 API" 항목 중 "장문 메시지 가져오기"를 사용하여 전체 내용의 메시지를 요청하여 받을 수 있습니다.
수신한 메시지 타입이 이미지, 비디오, 오디오 및 파일 일 경우
"Line biz 상담톡 API" 항목 중 "첨부파일 다운로드"를 사용하여 메시지 수신 시 첨부된 파일을 다운로드 할 수 있습니다.
path : /message
method : POST
header
Content-type: application/json
request body에 Json 형태의 데이터 전달
키 | 타입 | 설명 |
---|---|---|
chat_type | text | LINE |
serial_number | text | 메시지 고유 ID |
sender_key | text | LINE Channel ID |
user_key | text | 사용자 ID (source 내 userId 값) |
event_type | text | "message" or "postback" |
time | number | 메시지 전달 상담톡 서버 시각 (실제 유저가 입력한 시각은 아님) |
mode | text | Channel state. 다음 값 중 하나가 반환됩니다.
|
source | json | 수신 메시지의 user 정보입니다.
|
content | json | 1. event_type 이 "message" 일 경우 사용자 전송 메시지 데이터
2. event_type 이 "postback" 일 경우 사용자가 postback과 관련된 action을 수행할 때의 이벤트 개체
Postback 관련 참고내용
|
is_message_attachment | bool | 문자 메시지 수신 시 (event_type: "message", type: "text") 장문의 텍스트일 경우 메시지의 일부분만 내려주고, 전체 내용의 메시지 데이터는 별도로 저장되어 API로 내려받을 수 있습니다.
|
e164 | text | user_key 로 찾은 전화번호 |
user_name | text | user_key 로 찾은 사용자 이름 |
agree_type | int | 동의유형(0:기본, 1:1회성 동의) |
- [Parameter] - content (event_type이 "message"이고 text message 일 경우)
https://developers.line.biz/en/reference/messaging-api/#wh-text
키 | - | 타입 | 필수 | 설명 |
---|---|---|---|---|
content | - | - | - | |
id | text | Y | Message ID | |
type | text | Y | "text" | |
text | text | Y | 메시지 텍스트 |
{ "chat_type": "LINE", "serial_number": "Uae87c693e28-0001-6156B47C", "sender_key": "1656168303", "user_key": "Uae87c693e2897ccc4c7654acd04f9259", "event_type": "message", "time": 1633072251715, "mode": "active", "source": { "type": "user", "userId": "Uae87c693e2897ccc4c7654acd04f9259" }, "content": { "id": "14839219569333", "type": "text", "text": "text" }, "is_message_attachment": false, "e164": "01012349876", "user_name": "홍길동", "agree_type": 0 }
- [Parameter] - content (event_type이 "message"이고 image message 일 경우)
https://developers.line.biz/en/reference/messaging-api/#wh-image
키 | - | 타입 | 필수 | 설명 |
---|---|---|---|---|
content | - | - | - | |
id | text | Y | Message ID | |
type | text | Y | "image" | |
contentProvider.type | text | Y | Provider of the image file. |
{ "chat_type": "LINE", "serial_number": "Uae87c693e28-0002-6156B53F", "sender_key": "1656168303", "user_key": "Uae87c693e2897ccc4c7654acd04f9259", "event_type": "message", "time": 1633072447412, "mode": "active", "source": { "type": "user", "userId": "Uae87c693e2897ccc4c7654acd04f9259" }, "content": { "id": "14839235992328", "type": "image", "contentProvider": { "type": "line" } }, "is_message_attachment": false, "e164": "01012349876", "user_name": "홍길동", "agree_type": 0 }
- [Parameter] - content (event_type이 "message"이고 video message 일 경우)
https://developers.line.biz/en/reference/messaging-api/#wh-video
키 | - | 타입 | 필수 | 설명 |
---|---|---|---|---|
content | - | - | - | |
id | text | Y | Message ID | |
type | text | Y | "video" | |
duration | int | Y | Length of video file (milliseconds) | |
contentProvider.type | text | Y | Provider of the video file. |
{ "chat_type": "LINE", "serial_number": "Uae87c693e28-0003-6156B5AA", "sender_key": "1656168303", "user_key": "Uae87c693e2897ccc4c7654acd04f9259", "event_type": "message", "time": 1633072553316, "mode": "active", "source": { "type": "user", "userId": "Uae87c693e2897ccc4c7654acd04f9259" }, "content": { "id": "14839244559249", "type": "video", "duration": 4906, "contentProvider": { "type": "line" } }, "is_message_attachment": false, "e164": "01012349876", "user_name": "홍길동", "agree_type": 0 }
- [Parameter] - content (event_type이 "message"이고 audio message 일 경우)
https://developers.line.biz/en/reference/messaging-api/#wh-audio
키 | - | 타입 | 필수 | 설명 |
---|---|---|---|---|
content | - | - | - | |
id | text | Y | Message ID | |
type | text | Y | "audio" | |
duration | int | Y | Length of audio file (milliseconds) | |
contentProvider.type | text | Y | Provider of the audio file. |
{ "chat_type": "LINE", "serial_number": "Uae87c693e28-0004-6156B635", "sender_key": "1656168303", "user_key": "Uae87c693e2897ccc4c7654acd04f9259", "event_type": "message", "time": 1633072692876, "mode": "active", "source": { "type": "user", "userId": "Uae87c693e2897ccc4c7654acd04f9259" }, "content": { "id": "14839256211698", "type": "audio", "duration": 6449, "contentProvider": { "type": "line" } }, "is_message_attachment": false, "e164": "01012349876", "user_name": "홍길동", "agree_type": 0 }
- [Parameter] - content (event_type이 "message"이고 file message 일 경우)
https://developers.line.biz/en/reference/messaging-api/#wh-file
키 | - | 타입 | 필수 | 설명 |
---|---|---|---|---|
content | - | - | - | |
id | text | Y | Message ID | |
type | text | Y | "audio" | |
fileName | text | Y | File name | |
fileSize | int | Y | File size in bytes |
{ "chat_type": "LINE", "serial_number": "Uae87c693e28-0009-6156C26B", "sender_key": "1656168303", "user_key": "Uae87c693e2897ccc4c7654acd04f9259", "event_type": "message", "time": 1633075818781, "mode": "active", "source": { "type": "user", "userId": "Uae87c693e2897ccc4c7654acd04f9259" }, "content": { "id": "14839507936147", "type": "file", "fileName": "고해상도7.zip", "fileSize": 15280848, "contentProvider": { "type": "line" } }, "is_message_attachment": false, "e164": "01012349876", "user_name": "홍길동", "agree_type": 0 }
- [Parameter] - content (event_type이 "postback"이고 postback action 일 경우)
{ "chat_type": "LINE", "serial_number": "Uae87c693e28-0057-61513008", "sender_key": "1656168303", "user_key": "Uae87c693e2897ccc4c7654acd04f9259", "event_type": "postback", "time": 1632710664187, "mode": "active", "source": { "type": "user", "userId": "Uae87c693e2897ccc4c7654acd04f9259" }, "content": { "data": "action=buy&itemid=123" }, "is_message_attachment": false, "e164": "01012349876", "user_name": "홍길동", "agree_type": 0 }
- [Parameter] - content (event_type이 "postback"이고 datetimepicker action 일 경우)
{ "chat_type": "LINE", "serial_number": "Uae87c693e28-0059-615144A3", "sender_key": "1656168303", "user_key": "Uae87c693e2897ccc4c7654acd04f9259", "event_type": "postback", "time": 1632715938453, "mode": "active", "source": { "type": "user", "userId": "Uae87c693e2897ccc4c7654acd04f9259" }, "content": { "data": "storeId=12345", "params": { "datetime": "2021-09-27T13:11" } }, "is_message_attachment": false, "e164": "01012349876", "user_name": "홍길동", "agree_type": 0 }