This document describes how to integrate Kakao Talk messaging APIs into your service with the Kakao SDK for JavaScript (hereinafter JavaScript SDK).
You can test the features described in this document in [Tools] > [JS SDK demo] menu.
Tag | Description |
---|---|
Login required | The API marked with this tag requires Kakao Login. You must implement the Kakao Login function first, and then call the corresponding API by using the access token issued when a user logs in. |
Consent required | To use the API marked with this tag, you must enable the 'Send message in KakaoTalk' scope. In addition, a user must also consent to the scope. Otherwise, an error occurs. |
Import the JavaScript SDK into your web page and initialize it by referring to Getting Started > JavaScript.
To use the JavaScript SDK, you must register the Web platform in advance. Go to [My Application] > [Platform] and register your site domains.
To use the Kakao Talk messaging APIs,
According to your service's purpose and requirements, you need to decide which API to use first by considering their characteristics and difference.
Step 1. Select a type of Messaging APIThere are two types of messaging APIs: Kakao Talk sharing API and Kakao Talk messaging API. You need to understand the differences between the two messaging APIs completely by referring to Concepts, and decide which API to use to implement the function to send a message.
Decide which message template to use by referring to Message template > Types.
You can configure a message according to the default template in JSON format or create a custom template in person for your service. Refer to Message configuration method for more details.
Note that the Kakao Talk messaging APIs are categorized according to the message targets:
To send a Kakao Talk message to friends, 1. Get permission. Before permission is granted to your app, you can only retrieve the list of the team members. 2. Enable the 'Send message in KakaoTalk' scope in [My Application] > [Kakao Login] > [Consent items]. A user must also consent to the scope. To see more about the conditions for providing friend information, refer to Usage policy.
The JavaScript SDK does not provide the Kakao Talk messaging API as a built-in function. To implement the Kakao Talk messaging API on a web page, make a request in the same content as a REST API using the Kakao.API.request()
function. According to the desired message type, the required components of the message and the API to call are different. Refer to Message template components and samples.
Message type | Configuration method | Target | API to call |
---|---|---|---|
Feed, List, Location, Commerce, Text, Calendar | Default template | Me (MyChatroom) | /v2/api/talk/memo/default/send |
Feed, List, Location, Commerce, Text, Calendar | Default template | Friends | /v1/api/talk/friends/message/default/send |
Feed, List, Commerce | Custom template | Me (MyChatroom) | /v2/api/talk/memo/send |
Feed, List, Commerce | Custom template | Friends | /v1/api/talk/friends/message/send |
Scrap | Default template | Me (MyChatroom) | /v2/api/talk/memo/scrap/send |
Scrap | Default template | Friends | /v1/api/talk/friends/message/scrap/send |
Scrap | Custom template | Me (MyChatroom) | /v2/api/talk/memo/scrap/send |
Scrap | Custom template | Friends | /v1/api/talk/friends/message/scrap/send |
Messages sent through Kakao Talk sharing include a link to open the specified web page or app. The buttons in the message launch the app through a Custom URL Scheme consisting of a URI scheme and parameters. Refer to Kakao Talk Sharing: JavaScript > Set Custom URL Scheme for more details.
This API enables you to configure a message as an object type according to the default template type to use. Pass the configured template_object
through the data
parameter.
To send a message to friends, obtain the receiving users' uuid
s through the Friends picker or the Retrieving list of friends API, and then pass the uuid
s as the receiver_uuids
parameter. You can send a message to up to five friends at once.
Kakao.API.request()
returns Promise
. For the detailed response fields returned if the promise is fulfilled, refer to REST API > Send message with default template.
Call the Kakao.API.request()
function, and set url
to /v2/api/talk/memo/default/send
.
Name | Type | Description | Required |
---|---|---|---|
url | String |
Fixed as /v2/api/talk/memo/default/send . |
O |
data | Object |
Object containing parameters to be passed through API. | O |
Name | Type | Description | Required |
---|---|---|---|
template_object | DefaultFeedSettings DefaultListSettings DefaultLocationSettings DefaultCommerceSettings DefaultTextSettings DefaultCalendarSettings |
Object containing the message components. | O |
Kakao.API.request({
url: '/v2/api/talk/memo/default/send',
data: {
template_object: {
object_type: 'feed',
content: {
title: 'Strawberry cheese cake',
description: '#cake #strawberry #cafe #atmosphere #blinddate',
image_url:
'https://mud-kage.kakao.com/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png',
link: {
web_url: 'https://developers.kakao.com',
mobile_web_url: 'https://developers.kakao.com',
},
},
item_content:{
profile_text: 'Kakao',
profile_image_url: 'http://k.kakaocdn.net/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png',
title_image_url: 'http://k.kakaocdn.net/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png',
title_image_text: 'Cheese cake',
title_image_category: 'Cake',
items: [
{
item: 'Cake1',
item_op: '1000 won',
},
{
item: 'Cake2',
item_op: '2000 won',
},
{
item: 'Cake3',
item_op: '3000 won',
},
{
item: 'Cake4',
item_op: '4000 won',
},
{
item: 'Cake5',
item_op: '5000 won',
},
],
sum: 'Total',
sum_op: '15000 won',
},
social: {
like_count: 100,
comment_count: 200,
},
buttons: [
{
title: 'View on Web',
link: {
mobile_web_url: 'https://developers.kakao.com',
web_url: 'https://developers.kakao.com',
},
},
{
title: 'View on App',
link: {
mobile_web_url: 'https://developers.kakao.com',
web_url: 'https://developers.kakao.com',
},
},
],
},
},
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
Call the Kakao.API.request()
function, and set url
to v1/api/talk/friends/message/default/send
.
Name | Type | Description | Required |
---|---|---|---|
url | String |
Fixed as v1/api/talk/friends/message/default/send . |
O |
data | Object |
Object containing parameters to be passed through API. | O |
Name | Type | Description | Required |
---|---|---|---|
receiver_uuids | String[] |
uuid obtained through the Friends picker or the Retrieving list of friends API.Up to five uuids are allowed. |
O |
template_object | DefaultFeedSettings DefaultListSettings DefaultLocationSettings DefaultCommerceSettings DefaultTextSettings DefaultCalendarSettings |
Object containing the message components. | O |
Kakao.API.request({
url: '/v1/api/talk/friends/message/default/send',
data: {
receiver_uuids: ['${RECEIVER_UUID}'],
template_object: {
object_type: 'feed',
content: {
title: 'Strawberry cheese cake',
description: '#cake #strawberry #cafe #atmosphere #blinddate',
image_url:
'https://mud-kage.kakao.com/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png',
link: {
web_url: 'https://developers.kakao.com',
mobile_web_url: 'https://developers.kakao.com',
},
},
item_content:{
profile_text: 'Kakao',
profile_image_url: 'http://k.kakaocdn.net/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png',
title_image_url: 'http://k.kakaocdn.net/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png',
title_image_text: 'Cheese cake',
title_image_category: 'Cake',
items: [
{
item: 'Cake1',
item_op: '1000 won',
},
{
item: 'Cake2',
item_op: '2000 won',
},
{
item: 'Cake3',
item_op: '3000 won',
},
{
item: 'Cake4',
item_op: '4000 won',
},
{
item: 'Cake5',
item_op: '5000 won',
},
],
sum: 'Total',
sum_op: '15000 won',
},
social: {
like_count: 100,
comment_count: 200,
},
buttons: [
{
title: 'View on Web',
link: {
mobile_web_url: 'https://developers.kakao.com',
web_url: 'https://developers.kakao.com',
},
},
{
title: 'View on App',
link: {
mobile_web_url: 'https://developers.kakao.com',
web_url: 'https://developers.kakao.com',
},
},
],
},
},
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
Unlike the Sending message with default template, you can customize a template in [Tools] > [Message Template Builder] to send a message.
Set template_id
to the template ID of the custom template registered in [Message Template Builder]. If you use user arguments for some components when you configure a custom message to input variable information, you must also pass key and value pairs as the value of template_args
. Otherwise, the defined argument is displayed to users as raw data, such as ${key}
.
To send a message to friends, obtain the receiving users' uuid
s through the Friends picker or the Retrieving list of friends API, and then pass the uuid
s as the receiver_uuids
parameter. You can send a message to up to five friends at once.
Kakao.API.request()
returns Promise
. For the detailed response fields returned if the promise is fulfilled, refer to REST API > Send message with custom template.
Call the Kakao.API.request()
function, and set url
to /v2/api/talk/memo/send
.
Name | Type | Description | Required |
---|---|---|---|
url | String |
Fixed as /v2/api/talk/memo/send . |
O |
data | Object |
Object containing parameters to be passed through API. | O |
Name | Type | Description | Required |
---|---|---|---|
template_id | Number |
Template ID of the custom message registered in [Tools] > [Message Template Builder]. | O |
template_args | Object |
If the specified template contains a user argument, use this parameter to pass key-value pairs. You cannot overwrite the scrap result. |
X |
Kakao.API.request({
url: '/v2/api/talk/memo/send',
data: {
template_id: ${YOUR_TEMPLATE_ID},
},
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
Call the Kakao.API.request()
function, and set url
to /v1/api/talk/friends/message/send
.
Name | Type | Description | Required |
---|---|---|---|
url | String |
Fixed as /v1/api/talk/friends/message/send . |
O |
data | Object |
Object containing parameters to be passed through API. | O |
Name | Type | Description | Required |
---|---|---|---|
receiver_uuids | String[] |
uuid obtained through the Friends picker or the Retrieving list of friends API.Up to five uuids are allowed. |
O |
template_id | Number |
Template ID of the custom message registered in [Tools] > [Message Template Builder]. | O |
template_args | Object |
If the specified template contains a user argument, use this parameter to pass key-value pairs. You cannot overwrite the scrap result. |
X |
Kakao.API.request({
url: '/v1/api/talk/friends/message/send',
data: {
receiver_uuids: ['${RECEIVER_UUID}'],
template_id: ${YOUR_TEMPLATE_ID},
},
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
This API scraps a web page, and then configures a message based on the scraped web page information to send a message.
When you request to send a scrap message, you must pass request_url
, a web page to be scraped. Make sure that you have registered the domain of the web page to be scraped as a site domain in [My Application] > [Platform] > [Web] in advance.
To send a message to friends, obtain the receiving users' uuid
s through the Friends picker or the Retrieving list of friends API, and then pass the uuid
s as the receiver_uuids
parameter. You can send a message to up to five friends at once.
Kakao.API.request()
returns Promise
. For the detailed response fields returned if the promise is fulfilled, refer to REST API > Send scrap message with default template.
Call the Kakao.API.request()
function, and set url
to /v2/api/talk/memo/scrap/send
.
Name | Type | Description | Required |
---|---|---|---|
url | String |
Fixed as /v2/api/talk/memo/scrap/send . |
O |
data | Object |
Object containing parameters to be passed through API. | O |
Name | Type | Description | Required |
---|---|---|---|
request_url | String |
Web page URL to be scraped. Its domain must match the domain registered on the Kakao Developers. Refer to Scrap message. |
O |
Kakao.API.request({
url: '/v2/api/talk/memo/scrap/send',
data: {
request_url: 'https://developers.kakao.com',
},
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
Call the Kakao.API.request()
function, and set url
to /v1/api/talk/friends/message/scrap/send
.
Name | Type | Description | Required |
---|---|---|---|
url | String |
Fixed as /v1/api/talk/friends/message/scrap/send . |
O |
data | Object |
Object containing parameters to be passed through API. | O |
Name | Type | Description | Required |
---|---|---|---|
receiver_uuids | String[] |
uuid obtained through the Friends picker or the Retrieving list of friends API.Up to five uuids are allowed. |
O |
request_url | String |
Web page URL to be scraped. Its domain must match the domain registered on the Kakao Developers. Refer to Scrap message. |
O |
Kakao.API.request({
url: '/v1/api/talk/friends/message/scrap/send',
data: {
receiver_uuids: ['${RECEIVER_UUID}'],
request_url: 'https://developers.kakao.com',
},
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
This API scraps a web page, and then configures a message based on the scraped web page information to send a message. Unlike the Sending scrap message with default template, you can use a custom template registered in [Tools] > [Message Template Builder] when requesting to send a scrap message.
When you request to send a scrap message, you must pass request_url
, a web page to be scraped. Make sure that you have registered the domain of the web page to be scraped as a site domain in [My Application] > [Platform] > [Web] in advance.
Set template_id
to the template ID of the custom template registered in [Message Template Builder]. If you use user arguments for some components when you configure a custom message to input variable information, you must also pass key and value pairs as the value of template_args
. Otherwise, the defined argument is displayed to users as raw data, such as ${key}
.
To send a message to friends, obtain the receiving users' uuid
s through the Friends picker or the Retrieving list of friends API, and then pass the uuid
s as the receiver_uuids
parameter. You can send a message to up to five friends at once.
Kakao.API.request()
returns Promise
. For the detailed response fields returned if the promise is fulfilled, refer to REST API > Send scrap message with custom template.
Call the Kakao.API.request()
function, and set url
to /v2/api/talk/memo/scrap/send
.
Name | Type | Description | Required |
---|---|---|---|
url | String |
Fixed as /v2/api/talk/memo/scrap/send . |
O |
data | Object |
Object containing parameters to be passed through API. | O |
Name | Type | Description | Required |
---|---|---|---|
request_url | String |
Web page URL to be scraped. Its domain must match the domain registered on the Kakao Developers. |
O |
template_id | Number |
Used when you want to send a scrap message with the template registered in [Tools] > [Message Template Builder]. Specify the ID of the template to apply. When you use this parameter, the scraped content is applied in the template with the specified template_id . |
O |
template_args | Object |
If you specify template_id and the specified template contains other user arguments besides the default argument keys, pass the user arguments using this parameter in key:value format.You cannot overwrite the scrap result. |
X |
Kakao.API.request({
url: '/v2/api/talk/memo/scrap/send',
data: {
request_url: 'https://developers.kakao.com',
template_id: ${YOUR_TEMPLATE_ID},
},
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
Call the Kakao.API.request()
function, and set url
to /v1/api/talk/friends/message/scrap/send
.
Name | Type | Description | Required |
---|---|---|---|
url | String |
Fixed as /v1/api/talk/friends/message/scrap/send . |
O |
data | Object |
Object containing parameters to be passed through API. | O |
Name | Type | Description | Required |
---|---|---|---|
receiver_uuids | String[] |
uuid obtained through the Friends picker or the Retrieving list of friends API.Up to five uuids are allowed. |
O |
request_url | String |
Web page URL to be scraped. Its domain must match the domain registered on the Kakao Developers. |
O |
template_id | Number |
Used when you want to send a scrap message with the template registered in [Tools] > [Message Template Builder]. Specify the ID of the template to apply. When you use this parameter, the scraped content is applied in the template with the specified template_id . |
O |
template_args | Object |
If you specify template_id and the specified template contains other user arguments besides the default argument keys, pass the user arguments using this parameter in key:value format.You cannot overwrite the scrap result. |
X |
Kakao.API.request({
url: '/v1/api/talk/friends/message/scrap/send',
data: {
receiver_uuids: ['${RECEIVER_UUID}'],
request_url: 'https://developers.kakao.com',
template_id: ${YOUR_TEMPLATE_ID},
},
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
You can attach images to a message by passing an image URL when configuring a message template or by uploading images in the Message template builder in advance. Refer to Kakao Talk Sharing: JavaScript > Upload image.
It is highly recommended to upgrade to the new version of JavaScript SDK as soon as possible because the Legacy SDK may not be supported anymore.