본문 바로가기메인 메뉴 바로가기사이드 메뉴 바로가기

kakao developers

Related sites
  • Docs
  • Kakao Talk Message
  • Android

사이드 메뉴

Kakao Map

Search

Kakao Talk Message

Android

This document describes how to integrate Kakao Talk Message APIs into your service with the Kakao SDK for Android ("Android SDK").

Guide to Kakao Talk message sending feature

  • The Kakao Talk Message API supports sending messages only between users within the same service.
  • You must have permission to use the Kakao Talk Social API to use the feature to send messages to friends.
  • For details, see Message sending features and How to use.

Before you begin

Choose implementation method

1. Select message sending feature

Kakao Developers provides two types of message sending features: Kakao Talk Share and Kakao Talk Message. Refer to Message sending features to select the feature to use. If you want to use Kakao Talk Message, perform the following steps.

2. Select message type and configuration method

Refer to Template types to decide which message template to use.

Refer to Configuration method comparison to decide how to configure messages. You can use default templates based on predefined templates in object form, or custom templates configured directly for your service.

3. Select message target

Note that for Kakao Talk Message, the APIs used are distinguished according to the message targets.

TargetDescription
Send to meSends a message to the "Me" chat in Kakao Talk of the currently logged-in user. This feature cannot send messages to other users and can only send messages to the logged-in user themselves.
Send to friendsSends a message to friends in Kakao Talk of the currently logged-in user.
Important: Additional feature request is required.
You must implement a process to receive recipient information through Retrieve friends through picker API or Retrieve friends through picker API. You can send messages to up to 5 friends at once. Daily and monthly quotas are set, so refer to Quota.
Permission required to send messages to friends

If you want to send messages to friends, Request permission is required. See Usage Policy as well.

Set Custom URL Scheme

Kakao Talk messages include links that execute specified web pages or apps. Buttons in messages execute apps using Custom URL Scheme (Custom URL Scheme) composed of URI schemes and parameters.

To allow users to execute your app using buttons in Kakao Talk messages, you must configure custom URL scheme settings in the AndroidManifest.xml file. For detailed setup instructions, see Custom URL scheme configuration.

Send me message with default template

Basic information
ReferenceApp setting
[SDK, RxSDK] sendDefaultMemo()
[SDK] DefaultTemplate
[SDK] MessageSendResult
[SDK] MessageFailureInfo
Install
Initialize
Set Custom URL Scheme
PermissionPrerequisiteKakao LoginUser consent
-Native app key
Product Link
Activate Kakao Login
Manage consent items
RequiredRequired:
Send message in Kakao Talk (talk_message)

Sends a message to the user's My Chatroom using the predefined default template in JSON format.

Request

To create a message, implement the DefaultTemplate interface, then use one of the following classes according to the desired template type to configure template objects.

When calling sendDefaultMemo(), pass the template object as the template parameter.

Response

When message transmission fails, it returns a response code. See Error code to identify the cause of failure with code and msg.

Example

TalkApiClient.instance.sendDefaultMemo(defaultFeed) { error ->
if (error != null) {
Log.e(TAG, "Failed to send me a message.", error)
} else {
Log.i(TAG, "Succeeded in sending me a message.")
}
}

Send me message with custom template

Basic information
ReferenceApp setting
[SDK, RxSDK] sendCustomMemo()
[SDK] MessageSendResult
[SDK] MessageFailureInfo
Install
Initialize
Set Custom URL Scheme

Sends a message to the user's My Chatroom using a custom template configured in [Tools] > [Message Template].

Request

When calling sendCustomMemo(), you must pass the template ID confirmed in the message template tool as the templateId parameter. For how to configure a template, see Custom Template.

To include variable information in a message, add user arguments to the custom template, then pass key-value pairs to the templateArgs parameter. For detailed usage and precautions, see Directly inputting user arguments.

Response

When message transmission fails, it returns a response code. See Error code to identify the cause of failure with code and msg.

Example

// Template ID of the custom template.
// * Refer to the guide: https://developers.kakao.com/docs/en/message-template/custom
val templateId = templateIds["customMessage"] as Long
TalkApiClient.instance.sendCustomMemo(templateId) { error ->
if (error != null) {
Log.e(TAG, "Failed to send me a message.", error)
} else {
Log.i(TAG, "Succeeded in sending me a message.")
}
}

Send me scrape message

Basic information
ReferenceApp setting
[SDK, RxSDK] sendScrapMemo()
[SDK] DefaultTemplate
[SDK] MessageSendResult
[SDK] MessageFailureInfo
Install
Initialize
Set Custom URL Scheme
PermissionPrerequisiteKakao LoginUser consent
-Native app key
Product Link
Activate Kakao Login
Manage consent items
RequiredRequired:
Send message in Kakao Talk
(talk_message)

Sends a scrape message to the user's My Chatroom using information extracted from the specified web page URL.

Request

You must pass the URL of the web page to be scraped as the url parameter. The domain of the web page to be scraped must be registered in [App] > [Product Link] > [Web domain] on the app management page.

If you want to send a scrape message based on a message template defined by your service, you must pass the ID of the template configured in [Tools] > [Message Template] as the templateId parameter. For template configuration methods, see Custom template.

To include variable information in a message, add user arguments to the custom template, then pass key-value pairs to the templateArgs parameter. For detailed usage and precautions, see Directly inputting user arguments.

Response

When message transmission fails, it returns a response code. See Error code to identify the cause of failure with code and msg.

Example: Using default template

// Web page URL to be shared.
// * Caution: The domain of the URL to be shared must be registered in [App] > [Product Link] > [Web domain] in Kakao Developers.
val url = "https://developers.kakao.com"
TalkApiClient.instance.sendScrapMemo(url) { error ->
if (error != null) {
Log.e(TAG, "Failed to send me a message.", error)
}
else {
Log.i(TAG, "Succeeded in sending me a message.")
}
}

Example: Using custom template

// Web page URL to be shared.
// * Caution: The domain of the URL to be shared must be registered in [App] > [Product Link] > [Web domain] in Kakao Developers.
val url = "https://developers.kakao.com"
// Template ID of the custom template.
// * Refer to the guide: https://developers.kakao.com/docs/en/message-template/custom
val templateId = templateIds["customMessage"] as Long
TalkApiClient.instance.sendScrapMemo(url, templateId) { error ->
if (error != null) {
Log.e(TAG, "Failed to send me a message.", error)
}
else {
Log.i(TAG, "Succeeded in sending me a message.")
}
}

Send message with default template

Basic information
ReferenceApp setting
[SDK, RxSDK] sendDefaultMessage()
[SDK] DefaultTemplate
[SDK] MessageSendResult
[SDK] MessageFailureInfo
Install
Initialize
Set Custom URL Scheme
PermissionPrerequisiteKakao LoginUser consent
Required:
Permission
Native app key
Product Link
Activate Kakao Login
Manage consent items
RequiredRequired:
Send message in Kakao Talk (talk_message)

Sends a message composed in JSON according to the predefined default template format.

Request

  1. Configure message template: To create a message, implement the DefaultTemplate interface, then use one of the following classes according to the desired template type to configure template objects.
  2. Retrieve message recipients: To send a message to friends, you must determine who to send the message to. First, call the Retrieve friends through picker API or Retrieve list of friends API to get the uuid information of friends to send messages to.
  3. Specify template and recipients: When calling sendDefaultMessage(), pass the previously configured template object as the template parameter, and pass the list of uuids of friends selected by the user as the receiverUuids parameter. You can send messages to up to 5 friends at once.

Response

The message transmission result is returned as a MessageSendResult object. When message transmission succeeds, successfulReceiverUuids contains a list of uuids of friends who successfully received the message. When message transmission fails for some friends, failureInfos contains failure information. See Error code to identify the cause of failure with code and msg.

Example

// Retrieve a list of friends.
TalkApiClient.instance.friends { friends, error ->
if (error != null) {
Log.e(TAG, "Failed to retrieve a list of friends.", error)
}
else {
Log.d(TAG, "Succeeded in retrieving a list of friends: \n${friends!!.elements.joinToString("\n")}")
if (friends.elements.isEmpty()) {
Log.e(TAG, "There is no friend to send a message to :(")
}
else {
// Retrieve UUIDs of the friends to send a message according to your service's environment.
// This sample displays the Friends list and collects the UUIDs of the friends selected by a user.
FriendsActivity.startForResult(
context,
friends.elements.map { PickerItem(it.uuid, it.profileNickname, it.profileThumbnailImage) }
) { selectedItems ->
if (selectedItems.isEmpty()) return@startForResult
Log.d(TAG, "Selected friends:\n${selectedItems.joinToString("\n")}")
// List of UUIDs of recipients to send a message.
val receiverUuids = selectedItems
// Feed message.
val template = defaultFeed
// Send a scrape message.
TalkApiClient.instance.sendDefaultMessage(receiverUuids, template) { result, error ->
if (error != null) {
Log.e(TAG, "Failed to send a message.", error)
}
else if (result != null) {
Log.i(TAG, "Succeeded in sending a message to ${result.successfulReceiverUuids}")
if (result.failureInfos != null) {
Log.d(TAG, "Succeed! But failed to send a message to some friends: \n${result.failureInfos}")
}
}
}
}
}
}
}

Send message with custom template

Basic information
ReferenceApp setting
[SDK, RxSDK] sendCustomMessage()
[SDK] MessageSendResult
[SDK] MessageFailureInfo
Install
Initialize
Set Custom URL Scheme

Sends a message using a custom template configured in [Tools] > [Message Template].

Request

  1. Retrieve message recipients: To send a message to friends, you must determine who to send the message to. First, call the Retrieve friends through picker API or Retrieve list of friends API to get the uuid information of friends to send messages to. Pass the list of uuids of friends selected by the user as the receiverUuids parameter. You can send messages to up to 5 friends at once.
  2. Pass template ID: When calling sendCustomMessage(), you must pass the template ID confirmed in the message template tool as the templateId parameter. For how to configure a template, see Custom Template.
  3. Pass user arguments (optional): To include variable information in a message, add user arguments to the custom template, then pass key-value pairs to the templateArgs parameter. For detailed usage and precautions, see Directly inputting user arguments.

Response

The message transmission result is returned as a MessageSendResult object. When message transmission succeeds, successfulReceiverUuids contains a list of uuids of friends who successfully received the message. When message transmission fails for some friends, failureInfos contains failure information. See Error code to identify the cause of failure with code and msg.

Example

// Retrieve a list of friends.
TalkApiClient.instance.friends { friends, error ->
if (error != null) {
Log.e(TAG, "Failed to retrieve a list of friends.", error)
}
else if (friends != null) {
Log.d(TAG, "Succeeded in retrieving a list of friends: \n${friends.elements.joinToString("\n")}")
if (friends.elements.isEmpty()) {
Log.e(TAG, "There is no friend to send a message to :")
}
else {
// Retrieve UUIDs of the friends to send a message according to your service's environment.
// List of UUIDs of recipients to send a message.
val receiverUuids = selectedItems
// Template ID of the custom template.
// * Refer to the guide: https://developers.kakao.com/docs/en/message-template/custom
val templateId = templateIds["customMessage"] as Long
// Send a scrape message.
TalkApiClient.instance.sendCustomMessage(receiverUuids, templateId) { result, error ->
if (error != null) {
Log.e(TAG, "Failed to send a message.", error)
}
else if (result != null){
Log.i(TAG, "Succeeded in sending a message to ${result.successfulReceiverUuids}")
if (result.failureInfos != null) {
Log.d(TAG, "Succeed! But failed to send a message to some friends: \n${result.failureInfos}")
}
}
}
}
}
}
}

Send scrap message

Basic information
ReferenceApp setting
[SDK, RxSDK] sendScrapMessage()
[SDK] DefaultTemplate
[SDK] MessageSendResult
[SDK] MessageFailureInfo
Install
Initialize
Set Custom URL Scheme
PermissionPrerequisiteKakao LoginUser consent
Required:
Permission
Native app key
Product Link
Activate Kakao Login
Manage consent items
RequiredRequired:
Send message in Kakao Talk
(talk_message)

Sends a scrape message using information extracted from the specified web page URL.

Request

  1. Retrieve message recipients: To send a message to friends, you must determine who to send the message to. First, call the Retrieve friends through picker API or Retrieve list of friends API to get the uuid information of friends to send messages to.
  2. Specify web page URL for scraping: When calling sendScrapMessage(), you must pass the URL of the web page to be scraped as the url parameter. The domain of the web page to be scraped must be registered in [App] > [Product Link] > [Web domain] on the app management page.
  3. Apply custom template (optional): If you want to send a message based on a message template defined by your service, you must pass the ID of the template configured in [Tools] > [Message Template] as the templateId parameter. For template configuration methods, see Custom template.
  4. Pass user arguments (optional): To include variable information in a message, add user arguments to the custom template, then pass key-value pairs to the templateArgs parameter. For detailed usage and precautions, see Directly inputting user arguments.

Response

The message transmission result is returned as a MessageSendResult object. When message transmission succeeds, successfulReceiverUuids contains a list of uuids of friends who successfully received the message. When message transmission fails for some friends, failureInfos contains failure information. See Error code to identify the cause of failure with code and msg.

Example: Using default template

// Retrieve a list of friends.
TalkApiClient.instance.friends { friends, error ->
if (error != null) {
Log.e(TAG, "Failed to retrieve a list of friends.", error)
}
else {
Log.d(TAG, "Succeeded in retrieving a list of friends: \n${friends!!.elements.joinToString("\n")}")
if (friends.elements.isEmpty()) {
Log.e(TAG, "There is no friend to send a message to :(")
} else {
// Retrieve UUIDs of the friends to send a message according to your service's environment.
// This sample displays the Friends list and collects the UUIDs of the friends selected by a user.
FriendsActivity.startForResult(
context,
friends.elements.map { PickerItem(it.uuid, it.profileNickname, it.profileThumbnailImage) }
) { selectedItems ->
if (selectedItems.isEmpty()) return@startForResult
Log.d(TAG, "Selected friends:\n${selectedItems.joinToString("\n")}")
// List of UUIDs of recipients to send a message.
val receiverUuids = selectedItems
// Web page URL to be shared.
// * Caution: The domain of the URL to be shared must be registered in [App] > [Product Link] > [Web domain] in Kakao Developers.
val url = "https://developers.kakao.com"
// Send a scrape message.
TalkApiClient.instance.sendScrapMessage(receiverUuids, url) { result, error ->
if (error != null) {
Log.e(TAG, "Failed to send a message.", error)
}
else if (result != null) {
Log.i(TAG, "Succeeded in sending a message to ${result.successfulReceiverUuids}")
if (result.failureInfos != null) {
Log.d(TAG, "Succeed! But failed to send a message to some friends: \n${result.failureInfos}")
}
}
}
}
}
}
}

Example: Using custom template

// Retrieve a list of friends.
TalkApiClient.instance.friends { friends, error ->
if (error != null) {
Log.e(TAG, "Failed to retrieve a list of friends.", error)
}
else {
Log.d(TAG, "Succeeded in retrieving a list of friends: \n${friends!!.elements.joinToString("\n")}")
if (friends.elements.isEmpty()) {
Log.e(TAG, "There is no friend to send a message to :(")
} else {
// Retrieve UUIDs of the friends to send a message according to your service's environment.
// This sample displays the Friends list and collects the UUIDs of the friends selected by a user.
FriendsActivity.startForResult(
context,
friends.elements.map { PickerItem(it.uuid, it.profileNickname, it.profileThumbnailImage) }
) { selectedItems ->
if (selectedItems.isEmpty()) return@startForResult
Log.d(TAG, "Selected friends:\n${selectedItems.joinToString("\n")}")
// List of UUIDs of recipients to send a message.
val receiverUuids = selectedItems
// Web page URL to be shared.
// * Caution: The domain of the URL to be shared must be registered in [App] > [Product Link] > [Web domain] in Kakao Developers.
val url = "https://developers.kakao.com"
// Template ID of the custom template.
// * Refer to the guide: https://developers.kakao.com/docs/en/message-template/custom
val templateId = templateIds["customMessage"] as Long
// Send a scrape message.
TalkApiClient.instance.sendScrapMessage(receiverUuids, url, templateId) { result, error ->
if (error != null) {
Log.e(TAG, "Failed to send a message.", error)
}
else if (result != null) {
Log.i(TAG, "Succeeded in sending a message to ${result.successfulReceiverUuids}")
if (result.failureInfos != null) {
Log.d(TAG, "Succeed! But failed to send a message to some friends: \n${result.failureInfos}")
}
}
}
}
}
}
}

Upload image

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 Upload image.

See more

Was this helpful?