8.Line biz 수신 API

Edit

8.1개요

8.1.1시퀀스 다이어그램 (Sequence Diagram)

그림 8-1Line Sequence Diagram

8.2수신 이벤트

8.2.1메시지 수신

"is_message_attachment" 값이 true 일 경우

"Line biz 상담톡 API" 항목 중 "장문 메시지 가져오기"를 사용하여 전체 내용의 메시지를 요청하여 받을 수 있습니다.

수신한 메시지 타입이 이미지, 비디오, 오디오 및 파일 일 경우

"Line biz 상담톡 API" 항목 중 "첨부파일 다운로드"를 사용하여 메시지 수신 시 첨부된 파일을 다운로드 할 수 있습니다.

타입

설명

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. 다음 값 중 하나가 반환됩니다.

  • "active"

    • 채널이 활성 상태입니다. 이 경우 "reply message" 또는 "push message"를 보낼 수 있습니다.

  • "standby"

    • 채널이 대기 중입니다. 이 경우에는 메시지를 보내지 않아야 합니다.

source

json

수신 메시지의 user 정보입니다.

  • json data로 전달됩니다.

    • {"type": "user","userId": "U4af..."}

content

json

1. event_type 이 "message" 일 경우

사용자 전송 메시지 데이터

  • json data로 전달됩니다.

    • "type" 항목으로 메시지 종류를 확인할 수 있으며 다음 값 중 하나가 반환됩니다.

      • "text", "image", "video", "audio", "file", "location", "sticker"

    • 각 메시지 type별 상세한 내용은 아래 페이지를 참고하시기 바립니다.

      • https://developers.line.biz/en/reference/messaging-api/#message-event


2. event_type 이 "postback" 일 경우

사용자가 postback과 관련된 action을 수행할 때의 이벤트 개체

  • json data로 전달됩니다.

    • postback.data

      • 메시지의 postback action에서 지정된 data

      • https://developers.line.biz/en/reference/messaging-api/#postback-action

    • postback.params - 아래 개체 중 하나입니다.

      • Datetime picker action

      • Rich menu switch action

  • Postback Event의 상세한 내용은 아래 페이지를 참고하시기 바립니다.

    • https://developers.line.biz/en/reference/messaging-api/#postback-event


Postback 관련 참고내용

  • Postback Event 를 발생시키는 action

    • Postback action

      • "type":"postback" 으로 지정된 action

      • https://developers.line.biz/en/reference/messaging-api/#postback-action

    • Datetime picker action

      • "type":"datetimepicker"으로 지정된 action

      • https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action

    • Rich menu switch action

      • "type":"richmenuswitch"으로 지정된 action

is_message_attachment

bool

문자 메시지 수신 시 (event_type: "message", type: "text")

장문의 텍스트일 경우 메시지의 일부분만 내려주고, 전체 내용의 메시지 데이터는 별도로 저장되어 API로 내려받을 수 있습니다.

  • true

    • 저장된 전체 내용 메시지 존재

  • false

    • 저장된 전체 내용 메시지 없음

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
}