Skip to content

Commit 5b9602e

Browse files
feat(kakao): Add new BMS message examples for various types
- Introduced multiple new example files for sending Kakao BMS messages, including: - `send_bms_free_carousel_commerce.js`: Example for CAROUSEL_COMMERCE type messages. - `send_bms_free_carousel_feed.js`: Example for CAROUSEL_FEED type messages. - `send_bms_free_commerce.js`: Example for COMMERCE type messages. - `send_bms_free_image_with_buttons.js`: Example for IMAGE type messages with buttons. - `send_bms_free_image.js`: Example for basic IMAGE type messages. - `send_bms_free_premium_video.js`: Example for PREMIUM_VIDEO type messages. - `send_bms_free_text_with_buttons.js`: Example for TEXT type messages with buttons. - `send_bms_free_text.js`: Example for basic TEXT type messages. - `send_bms_free_wide_item_list.js`: Example for WIDE_ITEM_LIST type messages. - `send_bms_free_wide.js`: Example for WIDE type messages. These additions enhance the documentation and provide clear usage examples for developers integrating with the Kakao BMS service.
1 parent 09e2fb6 commit 5b9602e

11 files changed

Lines changed: 1238 additions & 2 deletions

examples/javascript/common/src/kakao/send/send_bms.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
/**
2-
* 카카오 브랜드 메시지 발송 예제
3-
* 현재 targeting 타입 중 M, N의 경우는 카카오 측에서 인허가된 채널만 사용하실 수 있습니다.
2+
* 카카오 브랜드 메시지(템플릿 기반) 발송 예제
3+
* 이 파일은 templateId를 사용한 템플릿 기반 BMS 발송 예제입니다.
4+
*
5+
* BMS 자유형(템플릿 없이 직접 메시지 구성) 예제는 아래 파일들을 참고하세요:
6+
* - send_bms_free_text.js: TEXT 타입 (텍스트 전용)
7+
* - send_bms_free_text_with_buttons.js: TEXT 타입 + 버튼
8+
* - send_bms_free_image.js: IMAGE 타입 (이미지 포함)
9+
* - send_bms_free_image_with_buttons.js: IMAGE 타입 + 버튼
10+
* - send_bms_free_wide.js: WIDE 타입 (와이드 이미지)
11+
* - send_bms_free_wide_item_list.js: WIDE_ITEM_LIST 타입 (와이드 아이템 리스트)
12+
* - send_bms_free_commerce.js: COMMERCE 타입 (상품 메시지)
13+
* - send_bms_free_carousel_feed.js: CAROUSEL_FEED 타입 (캐러셀 피드)
14+
* - send_bms_free_carousel_commerce.js: CAROUSEL_COMMERCE 타입 (캐러셀 커머스)
15+
* - send_bms_free_premium_video.js: PREMIUM_VIDEO 타입 (프리미엄 비디오)
16+
*
17+
* targeting 타입 중 M, N의 경우는 카카오 측에서 인허가된 채널만 사용하실 수 있습니다.
418
* 그 외의 모든 채널은 I 타입만 사용 가능합니다.
519
*/
620
const {SolapiMessageService} = require('solapi');
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/**
2+
* 카카오 BMS 자유형 CAROUSEL_COMMERCE 타입 발송 예제
3+
* 캐러셀 커머스 형식으로, 여러 상품을 슬라이드로 보여주는 구조입니다.
4+
* head + list(상품카드들) + tail 구조입니다.
5+
* targeting 타입 중 M, N의 경우는 카카오 측에서 인허가된 채널만 사용하실 수 있습니다.
6+
* 그 외의 모든 채널은 I 타입만 사용 가능합니다.
7+
* 발신번호, 수신번호에 반드시 -, * 등 특수문자를 제거하여 기입하시기 바랍니다. 예) 01012345678
8+
*/
9+
const {SolapiMessageService} = require('solapi');
10+
const messageService = new SolapiMessageService(
11+
'ENTER_YOUR_API_KEY',
12+
'ENTER_YOUR_API_SECRET',
13+
);
14+
15+
// 단일 발송 예제
16+
// imageId는 미리 업로드한 이미지 ID를 사용합니다.
17+
// 이미지 업로드: messageService.uploadFile(filePath, 'KAKAO').then(res => res.fileId)
18+
messageService
19+
.sendOne({
20+
to: '수신번호',
21+
from: '계정에서 등록한 발신번호 입력',
22+
type: 'BMS_FREE',
23+
kakaoOptions: {
24+
pfId: '연동한 비즈니스 채널의 pfId',
25+
bms: {
26+
targeting: 'I', // I: 전체, M/N: 인허가 채널만
27+
chatBubbleType: 'CAROUSEL_COMMERCE',
28+
carousel: {
29+
// head: 캐러셀 상단 대표 이미지 및 설명 (선택)
30+
head: {
31+
header: '이번 주 베스트 상품',
32+
content: '인기 상품을 만나보세요!',
33+
imageId: '업로드한 헤드 이미지 ID',
34+
linkMobile: 'https://m.example.com/best',
35+
linkPc: 'https://example.com/best', // 선택
36+
},
37+
// list: 상품 카드 목록 (head 있으면 1-5개, 없으면 2-6개)
38+
list: [
39+
{
40+
additionalContent: '무료배송', // 부가정보 (선택)
41+
imageId: '업로드한 상품 이미지 ID',
42+
coupon: {
43+
title: '10% 할인 쿠폰',
44+
description: '신규 회원 전용',
45+
linkMobile: 'https://m.example.com/coupon1',
46+
},
47+
commerce: {
48+
title: '상품명 1',
49+
regularPrice: '30000',
50+
discountPrice: '25000',
51+
discountRate: '17',
52+
},
53+
buttons: [
54+
{
55+
linkType: 'WL',
56+
name: '구매하기',
57+
linkMobile: 'https://m.example.com/product1',
58+
},
59+
],
60+
},
61+
{
62+
additionalContent: '오늘 출발',
63+
imageId: '업로드한 상품 이미지 ID',
64+
commerce: {
65+
title: '상품명 2',
66+
regularPrice: '50000',
67+
discountPrice: '40000',
68+
discountRate: '20',
69+
},
70+
buttons: [
71+
{
72+
linkType: 'WL',
73+
name: '구매하기',
74+
linkMobile: 'https://m.example.com/product2',
75+
},
76+
],
77+
},
78+
{
79+
imageId: '업로드한 상품 이미지 ID',
80+
commerce: {
81+
title: '상품명 3',
82+
regularPrice: '15000',
83+
},
84+
buttons: [
85+
{
86+
linkType: 'WL',
87+
name: '구매하기',
88+
linkMobile: 'https://m.example.com/product3',
89+
},
90+
],
91+
},
92+
],
93+
// tail: 캐러셀 하단에 "더보기" 링크 (선택)
94+
tail: {
95+
linkMobile: 'https://m.example.com/all-products',
96+
linkPc: 'https://example.com/all-products', // 선택
97+
},
98+
},
99+
},
100+
},
101+
})
102+
.then(res => console.log(res));
103+
104+
// head 없이 상품만 발송하는 예제
105+
messageService
106+
.sendOne({
107+
to: '수신번호',
108+
from: '계정에서 등록한 발신번호 입력',
109+
type: 'BMS_FREE',
110+
kakaoOptions: {
111+
pfId: '연동한 비즈니스 채널의 pfId',
112+
bms: {
113+
targeting: 'I',
114+
chatBubbleType: 'CAROUSEL_COMMERCE',
115+
carousel: {
116+
list: [
117+
{
118+
imageId: '업로드한 상품 이미지 ID',
119+
commerce: {
120+
title: '한정 특가 상품 A',
121+
regularPrice: '100000',
122+
discountPrice: '70000',
123+
discountRate: '30',
124+
},
125+
buttons: [
126+
{
127+
linkType: 'WL',
128+
name: '바로 구매',
129+
linkMobile: 'https://m.example.com/productA',
130+
},
131+
],
132+
},
133+
{
134+
imageId: '업로드한 상품 이미지 ID',
135+
commerce: {
136+
title: '한정 특가 상품 B',
137+
regularPrice: '80000',
138+
discountPrice: '60000',
139+
discountRate: '25',
140+
},
141+
buttons: [
142+
{
143+
linkType: 'WL',
144+
name: '바로 구매',
145+
linkMobile: 'https://m.example.com/productB',
146+
},
147+
],
148+
},
149+
],
150+
tail: {
151+
linkMobile: 'https://m.example.com/sale',
152+
},
153+
},
154+
},
155+
},
156+
})
157+
.then(res => console.log(res));
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/**
2+
* 카카오 BMS 자유형 CAROUSEL_FEED 타입 발송 예제
3+
* 캐러셀 피드 형식으로, 여러 카드를 좌우로 슬라이드하는 구조입니다.
4+
* 각 카드: header, content, imageId, imageLink, coupon, buttons
5+
* head 없이 2-6개 아이템, head 포함 시 1-5개 아이템 가능합니다.
6+
* targeting 타입 중 M, N의 경우는 카카오 측에서 인허가된 채널만 사용하실 수 있습니다.
7+
* 그 외의 모든 채널은 I 타입만 사용 가능합니다.
8+
* 발신번호, 수신번호에 반드시 -, * 등 특수문자를 제거하여 기입하시기 바랍니다. 예) 01012345678
9+
*/
10+
const {SolapiMessageService} = require('solapi');
11+
const messageService = new SolapiMessageService(
12+
'ENTER_YOUR_API_KEY',
13+
'ENTER_YOUR_API_SECRET',
14+
);
15+
16+
// 단일 발송 예제
17+
// imageId는 미리 업로드한 이미지 ID를 사용합니다.
18+
// 이미지 업로드: messageService.uploadFile(filePath, 'KAKAO').then(res => res.fileId)
19+
messageService
20+
.sendOne({
21+
to: '수신번호',
22+
from: '계정에서 등록한 발신번호 입력',
23+
type: 'BMS_FREE',
24+
kakaoOptions: {
25+
pfId: '연동한 비즈니스 채널의 pfId',
26+
bms: {
27+
targeting: 'I', // I: 전체, M/N: 인허가 채널만
28+
chatBubbleType: 'CAROUSEL_FEED',
29+
carousel: {
30+
// head 없이 list만 있는 경우 2-6개 아이템
31+
list: [
32+
{
33+
header: '첫 번째 카드 헤더',
34+
content: '첫 번째 카드 내용입니다.',
35+
imageId: '업로드한 이미지 ID',
36+
imageLink: 'https://example.com/image1', // 이미지 클릭 시 이동 URL (선택)
37+
coupon: {
38+
title: '10% 할인 쿠폰',
39+
description: '첫 구매 고객 전용',
40+
linkMobile: 'https://m.example.com/coupon1',
41+
},
42+
buttons: [
43+
{
44+
linkType: 'WL', // 캐러셀 피드는 WL, AL 버튼만 지원
45+
name: '자세히 보기',
46+
linkMobile: 'https://m.example.com/detail1',
47+
},
48+
],
49+
},
50+
{
51+
header: '두 번째 카드 헤더',
52+
content: '두 번째 카드 내용입니다.',
53+
imageId: '업로드한 이미지 ID',
54+
coupon: {
55+
title: '5000원 할인 쿠폰',
56+
description: '주말 특가 할인',
57+
linkMobile: 'https://m.example.com/coupon2',
58+
},
59+
buttons: [
60+
{
61+
linkType: 'WL',
62+
name: '자세히 보기',
63+
linkMobile: 'https://m.example.com/detail2',
64+
},
65+
],
66+
},
67+
{
68+
header: '세 번째 카드 헤더',
69+
content: '세 번째 카드 내용입니다.',
70+
imageId: '업로드한 이미지 ID',
71+
buttons: [
72+
{
73+
linkType: 'AL', // 앱링크 버튼
74+
name: '앱에서 보기',
75+
linkAndroid: 'examplescheme://detail3',
76+
linkIos: 'examplescheme://detail3',
77+
},
78+
],
79+
},
80+
],
81+
// tail: 캐러셀 하단에 "더보기" 링크 (선택)
82+
tail: {
83+
linkMobile: 'https://m.example.com/more',
84+
linkPc: 'https://example.com/more', // 선택
85+
},
86+
},
87+
},
88+
},
89+
})
90+
.then(res => console.log(res));
91+
92+
// 여러 메시지 발송 예제
93+
messageService
94+
.send([
95+
{
96+
to: '수신번호',
97+
from: '계정에서 등록한 발신번호 입력',
98+
type: 'BMS_FREE',
99+
kakaoOptions: {
100+
pfId: '연동한 비즈니스 채널의 pfId',
101+
bms: {
102+
targeting: 'I',
103+
chatBubbleType: 'CAROUSEL_FEED',
104+
carousel: {
105+
list: [
106+
{
107+
header: '이벤트 1',
108+
content: '특별 이벤트 안내입니다.',
109+
imageId: '업로드한 이미지 ID',
110+
buttons: [
111+
{
112+
linkType: 'WL',
113+
name: '참여하기',
114+
linkMobile: 'https://m.example.com/event1',
115+
},
116+
],
117+
},
118+
{
119+
header: '이벤트 2',
120+
content: '한정 프로모션 안내입니다.',
121+
imageId: '업로드한 이미지 ID',
122+
buttons: [
123+
{
124+
linkType: 'WL',
125+
name: '참여하기',
126+
linkMobile: 'https://m.example.com/event2',
127+
},
128+
],
129+
},
130+
],
131+
},
132+
},
133+
},
134+
},
135+
])
136+
.then(res => console.log(res));

0 commit comments

Comments
 (0)