13.WeChat biz 상담톡 API WeChat biz 상담톡 API

Edit

13.1개요

13.2용어 정의

13.2.1공중 계정(Sender Key)

13.2.2상담 세션(Session)

13.2.3사용자 키 (User Key)

13.2.4상담원의 정의

13.2.5상담 메시지

13.3선결 조건

메시지 API를 사용하여 메시지 전송을 대행하기 위해 아래의 조건이 선결되어야 한다.

13.4API 스펙

13.4.1[서버] sip 서버

13.4.2메시지 발신

[Request]
POST /chat/write
[Parameter]

타입

필수

설명

user_key

text(100)

Y

사용자 키

sender_key

text(40)

Y

발신 프로필 키

message_type

text(10)

N

메시지 타입

(text : 텍스트,

image: 이미지, 

video: 비디오파일,

voice: 음성파일,

music : 음악URL,

news: 뉴스정보,

mpnews: 미디어뉴스,

msgmenu: 메뉴,

wxcard: 쿠폰,

BS:봇정보)

message

json or text

Y/N

사용자에게 전달할 메시지

message_type이 text 인 경우는 text 로 입력한다.

ex) "message" : "안녕하세요."

message_type이 text 가 아닌 경우는 json Object 로 입력한다.

ex) "message" : { "media_id":"MEDIA_ID" }

상세 설명은 아래 [Parameter] - message 를 참조

bot_id

text(128)

N

넥서스 시나리오 봇 아이디(콜아이디)

bot_name

text(100)

N

넥서스 시나리오 봇 이름

bot_status

text(10)

N

START: 시작 메시지, ING: 채팅중 , CLOSE:종료,

TIMEOUT: 고객 응답 없음, CONNECT: 상담원 연결, BUSY:대기 상담원 없음.

EXPIRE: 고객상담종료

[Parameter > Message]

-

타입

필수

설명

message

-

json

-

json Object


media_id

text

Y

미디어 ID (파일 업로드시 반환 되는 값)

예시
{
  "media_id": "MEDIA_ID"
}

-

타입

필수

설명

message

-

json

-

json Object


media_id

text

Y

미디어 ID (파일 업로드시 반환 되는 값)

예시
{
  "media_id": "MEDIA_ID"
}

-

타입

필수

설명

message

-

json

-

json Object


media_id

text

Y

미디어 ID (파일 업로드시 반환 되는 값)


thumb_media_id

text




title

text




description

text



예시
{
  "media_id": "MEDIA_ID",
  "thumb_media_id": "MEDIA_ID",
  "title": "TITLE",
  "description": "DESCRIPTION"
}

-

타입

필수

설명

message

-

json

-

json Object


title

text


타이틀


description

text


상세 설명


musicurl

text


음악 URL


hqmusicurl

text


HQ 음악 URL


thumb_media_id

text


Thumb 이미지 미디어 ID

예시
{
  "title": "MUSIC_TITLE",
  "description": "MUSIC_DESCRIPTION",
  "musicurl": "MUSIC_URL",
  "hqmusicurl": "HQ_MUSIC_URL",
  "thumb_media_id": "THUMB_MEDIA_ID"
}

-


타입

필수

설명

message

-


json

-

json Object


articles


array





title

text


타이틀



description

text


상세 설명



url

text


NEWS URL



picurl

text


NEWS 이미지 URL

예시
{
  "articles": [
    {
      "title": "Happy Day",
      "description": "Is Really A Happy Day",
      "url": "URL",
      "picurl": "PIC_URL"
    }
  ]
}

-

타입

필수

설명

message

-

json

-

json Object


media_id

text

Y

미디어 ID (Article 업로드시 반환 되는 값)

예시
{
  "media_id": "MEDIA_ID"
}

-


타입

필수

설명

message

-


json

-

json Object


head_content


text

Y

타이틀


list


array

Y

버튼 배열



id

text

Y

버튼 ID



cotent

text

Y

버튼 이름


tail_content


text


하단 타이틀

예시
{
  "head_content": "Are you satisfied with the service? ",
  "list": [
    {
      "id": "101",
      "content": "Satisfied"
    },
    {
      "id": "102",
      "content": "Dissatisfied"
    }
  ],
  "tail_content": "Looking forward to your visit again"
}

버튼을 사용자가 클릭하게 될 경우 메시지가 수신된다.

자세한 내용은 메시지 수신 API 을 참조 .

[Response]

타입

필수

설명

code

integer

Y

처리 결과 코드

(200은 정상 / 나머지는 오류)

message

text

N

성공일 경우 "OK"

실패일 경우는 각각의 메시지

13.4.3상담톡 발신 메시지 타입

13.4.3.1텍스트 타입

13.4.3.2미디어 임시 업로드

[Request]
POST /media/upload
[Header]

Content-type: multipart/form-data

[Parameter]

타입

필수

설명

sender_key

text

Y

발신프로필 키

media

binary

Y

업로드할 미디어 파일

type

text

N

image : 이미지

voice : 음성

videos : 비디오

thumb : thumbnail 이미지

미디어 타입
[Response]

타입

필수

설명

type

text

Y

업로드 type

media_id

text

Y

media ID

created_da

timestamp

Y

업로드 timestamp

13.4.3.3이미지 업로드(Article 용)

[Request]
POST /material/upload/img
[Header]

Content-type: multipart/form-data

[Parameter]

타입

필수

설명

sender_key

text

Y

발신프로필 키

media

binary

Y

업로드할 파일

[Response]

타입

설명

url

text

업로드된 이미지 URL

13.4.3.4미디어 업로드

지원 이미지 및 용량
[Request]
POST /media/upload
[Header]

Content-type: multipart/form-data

[Parameter]

타입

필수

설명

sender_key

text

Y

발신프로필 키

media

binary

Y

업로드할 미디어 파일

type

text

N

image : 이미지

voice : 음성

videos : 비디오

thumb : thumbnail 이미지

[Response]

타입

필수

설명

type

text

Y

업로드 type

media_id

text

Y

media ID

created_da

timestamp

Y

업로드 timestamp

13.4.4블랙리스트

13.4.4.1조회

[Request]
GET
[Parameter]

타입

필수

설명

begin_openid

text

Y

시작 사용자 키

Default : ""

예시
{
  "begin_openid": "OPENID1"
}
[Response]


타입

설명

total


integer

총 블랙리스트 수

count


integer

가져온 블랙리스트 수

data


json Object



openid

array


next_openid


text

다음 조회시 사용하는 사용자 ID

예시
{
 "total":23000,
 "count":10000,
 "data":{"
    openid":[
       "OPENID1",
       "OPENID2",
       ...,
       "OPENID10000"
    ]
  },
  "next_openid":"OPENID10000"
}

13.4.4.2등록

[Request]
POST
[Parameter]

타입

필수

설명

openid_list

array

Y

사용자 키 배열

예시
{
  "openid_list": [
    "OPENID1",
    "OPENID2"
  ]
}
[Response]

타입

필수

설명

code

integer

Y

처리 결과 코드

(0은 정상 / 나머지는 오류)

message

text

N

오류 메시지

(오류시 존재하는 값)

13.4.4.3삭제

[Request]
POST
[Parameter]

타입

필수

설명

openid_list

array

Y

사용자 키 배열

예시
{
  "openid_list": [
    "OPENID1",
    "OPENID2"
  ]
}
[Response]

타입

필수

설명

code

integer

Y

처리 결과 코드

(0은 정상 / 나머지는 오류)

message

text

N

오류 메시지

(오류시 존재하는 값)

13.4.5사용자 정보

13.4.5.1사용자 정보 조회

[Request]
GET /user/info
[Parameter]

타입

필수

설명

sender_key

text(40)

Y

발신 프로필 키

user_key

text(20)

Y

사용자 키

[Response]

타입

필수

설명

code

text

Y

처리 결과 코드

(200은 정상 / 나머지는 오류)

message

text

N

처리 메시지

sender_key

text

N

발신 프로필 키

user_key

text

N

사용자 키

tel_number

text(20)

N

사용자 전화번호

user_name

text(100)

N

사용자 이름

user_id

text(100)

N

사용자 ID

agree_type

int

N

사용자 인증 구분

0: 지속인증(기본값), 1: 1회성 인증

agree_date

text

N

동의일자: "2019-10-23 17:03:35"

[Example]
http://127.0.0.1:8080/user/info?sender_key=da2b0c0d28805157d5355b60beb9493a9b3e5b15&user_key=d14zPgU4yqoO&
{
  "code": "200",
  "message": "OK",
  "user_key": "d14zPgU4yqoO",
  "sender_key": "da2b0c0d28805157d5355b60beb9493a9b3e5b150",
  "user_id": "",
  "user_name": "",
  "tel_number": "1112323",
  "agree_type": 0, 
  "agree_date": "2022-05-11 15:40:04"
}

13.4.5.2사용자 정보 인증

[Request]
POST /user/auth
[Parameter]

타입

필수

설명

sender_key

text

Y

발신 프로필 키

user_key

text

Y

사용자 키

tel_number

text(20)

Y

사용자 전화번호

user_name

text(100)

N

사용자 이름

user_id

text(100)

N

사용자 ID

agree_type

int

N

사용자 인증 구분

0: 지속인증(기본값), 1: 1회성 인증

[Response]

타입

필수

설명

code

text

Y

처리 결과 코드

(200은 정상 / 나머지는 오류)

message

text

N

응답 메시지

[Example]
curl -X POST -H "Content-type: application/json" \
  -d '{"user_key":"d74zPgU4yqoO","sender_key":"da2b0c0d28805157d5355b60beb9493a9b3e5b15","app_user_id":null,"user_name":"장형길","user_id":"kenneth","tel_number":"01029113333" }'  \
  http://127.0.0.1:8080/user/auth
{ 
    "code": "200", 
    "message": "OK" 
}

13.4.5.3사용자 정보 인증 철회

[Request]
post /user/auth/delete
[Parameter]

타입

필수

설명

sender_key

text

Y

발신 프로필 키

user_key

text

Y

사용자 키

[Response]

타입

필수

설명

code

text

Y

처리 결과 코드

(200은 정상 / 나머지는 오류)

message

text

N

응답 메시지

[Example]
curl -X POST -H "Content-type: application/json" \
  -d '{"user_key":"d74zPgU4yqoO","sender_key":"da2b0c0d28805157d5355b60beb9493a9b3e5b15" }'  \
  http://127.0.0.1:8080/user/auth/delete
{ 
    "code": "200", 
    "message": "OK" 
}

13.4.6메지시 첨부파일 가져오기

13.4.6.1첨부파일 가져오기

[Request]
GET /message/attachment
[Parameter]

타입

필수

설명

attachment_url

text(1024)

Y

첨부파일 URL

13.4.7첨부파일 가져오기

13.4.7.1첨부파일 가져오기

[Request]
GET /message/file
[Parameter]

타입

필수

설명

file_url

text(1024)

Y

첨부파일 URL

13.5코드 정의

13.5.1오류 코드

code

message

설명

200

성공

정상코드

400

Bad Request

요청 데이터에 정상적이지 않음

403

권한없음

지원하지 않는 요청

404

Not Found

Wecha 서버쪽 요청 실패

405

파라미터 오류

필수값 없음




508

내부처리 실패

유효한 값 없음 또는 내부 오류