This document describes how to integrate Kakao Talk Message APIs into your service with the Kakao SDK for Android ("Android SDK").
The Kakao Talk Message API only supports sending messages between users within the same service, and the Kakao Talk Social API permission is required to provide the message sending feature to friends. For more details, see Message sending features and How to use.
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.
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.
Note that for Kakao Talk Message, the APIs used are distinguished according to the message targets.
Target | Description |
---|---|
Send to me | Sends 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 friends | Sends 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. |
If you want to send messages to friends, you must request permission. See Usage policy.
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.
Reference | App setting |
---|---|
[SDK, RxSDK] sendDefaultMemo() [SDK] DefaultTemplate [SDK] MessageSendResult [SDK] MessageFailureInfo |
Install Initialize Set Custom URL Scheme |
Permission | Prerequisite | Kakao Login | User consent |
---|---|---|---|
- | Register platforms Activate Kakao Login Manage consent items |
Required | Required: Send message in Kakao Talk (talk_message) |
This is an API that sends a message to me by defining components as objects according to predefined template formats. For detailed message configuration methods, see Default 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.
FeedTemplate
ListTemplate
LocationTemplate
CommerceTemplate
TextTemplate
CalendarTemplate
When calling sendDefaultMemo()
, pass the template object as the template
parameter.
When message transmission fails, it returns a response code. See Error code to identify the cause of failure with code
and msg
.
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.")
}
}
var disposables = CompositeDisposable()
TalkApiClient.rx.sendDefaultMemo(defaultFeed)
.retryWhen(
// Retry the request to send a message after requesting additional consent to resolve the InsufficientScope error.
RxAuthOperations.instance.incrementalAuthorizationRequired(context)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
Log.i(TAG, "Succeeded in sending me a message.")
}, { error ->
Log.e(TAG, "Failed to send me a message.", error)
})
.addTo(disposables)
Reference | App setting |
---|---|
[SDK, RxSDK] sendCustomMemo() [SDK] MessageSendResult [SDK] MessageFailureInfo |
Install Initialize Set Custom URL Scheme |
Permission | Prerequisite | Kakao Login | User consent |
---|---|---|---|
- | Register platforms Activate Kakao Login Manage consent items Message template |
Required | Required: Send message in Kakao Talk (talk_message) |
This is an API that sends messages using custom templates directly configured in [Tools] > [Message Template]. For message configuration methods, see Custom template.
When calling sendCustomMemo()
, you must pass the template ID confirmed in the message template tool as the templateId
parameter.
To include variable information in messages, add user arguments to the corresponding custom template, then pass keys and values as the templateArgs
parameter. If you do not use this parameter even though the custom template includes user arguments, the part specified as user arguments will be exposed in the message as ${KEY}
format.
When message transmission fails, it returns a response code. See Error code to identify the cause of failure with code
and msg
.
// Template ID of the custom template.
// * Refer to the guide: https://developers.kakao.com/docs/latest/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.")
}
}
var disposables = CompositeDisposable()
// Template ID of the custom template registered in [Tools] > [Message Template Builder].
// * Refer to the guide: https://developers.kakao.com/docs/latest/en/message-template/custom
val templateId = templateIds["customMessage"] as Long
TalkApiClient.rx.sendCustomMemo(templateId)
.retryWhen(
// Retry the request to send me a message after requesting additional consent to resolve the InsufficientScope error.
RxAuthOperations.instance.incrementalAuthorizationRequired(context)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
Log.i(TAG, "Succeeded in sending me a message.")
}, { error ->
Log.e(TAG, "Failed to send me a message.", error)
})
.addTo(disposables)
Reference | App setting |
---|---|
[SDK, RxSDK] sendScrapMemo() [SDK] DefaultTemplate [SDK] MessageSendResult [SDK] MessageFailureInfo |
Install Initialize Set Custom URL Scheme |
Permission | Prerequisite | Kakao Login | User consent |
---|---|---|---|
- | Register platforms Activate Kakao Login Manage consent items |
Required | Required: Send message in Kakao Talk (talk_message) |
This API configures a scrape message with information scraped from a specified web page and sends a message to the currently logged-in user's Kakao Talk.
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] > [General] > [Platform] > [Web] 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 messages, use user arguments. In this case, you must pass keys and values as the templateArgs
parameter. For detailed usage, see User arguments.
When message transmission fails, it returns a response code. See Error code to identify the cause of failure with code
and msg
.
// Web page URL to be shared.
// * Caution: The domain of the URL to be shared must be registered in [My Appliction] > [Platform] > [Web] 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.")
}
}
var disposables = CompositeDisposable()
// Web page URL to be shared.
// * Caution: The domain of the URL to be shared must be registered in [My Appliction] > [Platform] > [Web] in Kakao Developers.
val url = "https://developers.kakao.com"
TalkApiClient.rx.sendScrapMemo(url)
.retryWhen(
// Retry the request to send me a message after requesting additional consent to resolve the InsufficientScope error.
RxAuthOperations.instance.incrementalAuthorizationRequired(context)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
Log.i(TAG, "Succeeded in sending me a message.")
}, { error ->
Log.e(TAG, "Failed to send me a message.", error)
})
.addTo(disposables)
// Web page URL to be shared.
// * Caution: The domain of the URL to be shared must be registered in [My Appliction] > [Platform] > [Web] in Kakao Developers.
val url = "https://developers.kakao.com"
// Template ID of the custom template.
// * Refer to the guide: https://developers.kakao.com/docs/latest/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.")
}
}
var disposables = CompositeDisposable()
// Web page URL to be shared.
// * Caution: The domain of the URL to be shared must be registered in [My Appliction] > [Platform] > [Web] in Kakao Developers.
val url = "https://developers.kakao.com"
// Template ID of the custom template.
// * Refer to the guide: https://developers.kakao.com/docs/latest/en/message-template/custom
val templateId = templateIds["customMessage"] as Long
TalkApiClient.rx.sendScrapMemo(url, templateId)
.retryWhen(
// Retry the request to send me a message after requesting additional consent to resolve the InsufficientScope error.
RxAuthOperations.instance.incrementalAuthorizationRequired(context)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
Log.i(TAG, "Succeeded in sending me a message.")
}, { error ->
Log.e(TAG, "Failed to send me a message.", error)
})
.addTo(disposables)
Reference | App setting |
---|---|
[SDK, RxSDK] sendDefaultMessage() [SDK] DefaultTemplate [SDK] MessageSendResult [SDK] MessageFailureInfo |
Install Initialize Set Custom URL Scheme |
Permission | Prerequisite | Kakao Login | User consent |
---|---|---|---|
Required: Permission |
Register platforms Activate Kakao Login Manage consent items |
Required | Required: Send message in Kakao Talk (talk_message) |
This API sends a message to the currently logged-in user's Kakao Talk using default templates.
DefaultTemplate
interface, then use one of the following classes according to the desired template type to configure template objects.FeedTemplate
ListTemplate
LocationTemplate
CommerceTemplate
TextTemplate
CalendarTemplate
uuid
information of friends to send messages to.sendDefaultMessage()
, pass the previously configured template object as the template
parameter, and pass the list of uuid
s of friends selected by the user as the receiverUuids
parameter. You can send messages to up to 5 friends at once.The message transmission result is returned as a MessageSendResult
object. When message transmission succeeds, successfulReceiverUuids
contains a list of uuid
s 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
.
// 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}")
}
}
}
}
}
}
}
var disposables = CompositeDisposable()
// Retrieve a list of friends.
TalkApiClient.rx.friends()
// 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.
.flatMap { friends ->
FriendsActivity.startForResult(
context,
friends.elements.map { PickerItem(it.uuid, it.profileNickname, it.profileThumbnailImage) }
)
}
.observeOn(Schedulers.io())
.flatMap { selectedItems ->
// List of UUIDs of recipients to send a message.
val receiverUuids = selectedItems
// Feed message
val template = defaultFeed
TalkApiClient.rx.sendDefaultMessage(receiverUuids, template)
}
.retryWhen(
// Retry the request to send a message after requesting additional consent to resolve the InsufficientScope error.
RxAuthOperations.instance.incrementalAuthorizationRequired(context)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ result ->
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}")
}
}, { error ->
Log.e(TAG, "Failed to send a message.", error)
})
.addTo(disposables)
Reference | App setting |
---|---|
[SDK, RxSDK] sendCustomMessage() [SDK] MessageSendResult [SDK] MessageFailureInfo |
Install Initialize Set Custom URL Scheme |
Permission | Prerequisite | Kakao Login | User consent |
---|---|---|---|
Required: Permission |
Register platforms Activate Kakao Login Manage consent items Message template |
Required | Required: Send message in Kakao Talk (talk_message) |
This is an API that sends messages using custom templates directly configured in [Tools] > [Message Template]. For message configuration methods, see Custom template.
uuid
information of friends to send messages to. Pass the list of uuid
s of friends selected by the user as the receiverUuids
parameter. You can send messages to up to 5 friends at once.sendCustomMessage()
, you must pass the template ID confirmed in the message template tool as the templateId
parameter.templateArgs
parameter. If you do not use this parameter even though the custom template includes user arguments, the part specified as user arguments will be exposed in the message as ${KEY}
format.The message transmission result is returned as a MessageSendResult
object. When message transmission succeeds, successfulReceiverUuids
contains a list of uuid
s 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
.
// 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/latest/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}")
}
}
}
}
}
}
}
var disposables = CompositeDisposable()
// Retrieve a list of friends.
TalkApiClient.rx.friends()
// Retrieve UUIDs of the friends to send a message according to your service's environment.
.observeOn(Schedulers.io())
.flatMap { selectedItems ->
// 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/latest/en/message-template/custom
val templateId = templateIds["customMessage"] as Long
TalkApiClient.rx.sendCustomMessage(receiverUuids, templateId)
}
.retryWhen(
// Retry the request to send a message after requesting additional consent to resolve the InsufficientScope error.
RxAuthOperations.instance.incrementalAuthorizationRequired(context)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ result ->
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}")
}
}, { error ->
Log.e(TAG, "Failed to send a message.", error)
})
.addTo(disposables)
Reference | App setting |
---|---|
[SDK, RxSDK] sendScrapMessage() [SDK] DefaultTemplate [SDK] MessageSendResult [SDK] MessageFailureInfo |
Install Initialize Set Custom URL Scheme |
Permission | Prerequisite | Kakao Login | User consent |
---|---|---|---|
Required: Permission |
Register platforms Activate Kakao Login Manage consent items |
Required | Required: Send message in Kakao Talk (talk_message) |
This API configures a scrape message with information scraped from a specified web page and sends a message to the currently logged-in user's Kakao Talk.
uuid
information of friends to send messages to.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] > [General] > [Platform] > [Web] on the app management page.templateId
parameter. For template configuration methods, see Custom template. To include variable information in messages, use user arguments. In this case, you must pass keys and values as the templateArgs
parameter.The message transmission result is returned as a MessageSendResult
object. When message transmission succeeds, successfulReceiverUuids
contains a list of uuid
s 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
.
// 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 [My Appliction] > [Platform] > [Web] 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}")
}
}
}
}
}
}
}
var disposables = CompositeDisposable()
// Retrieve a list of friends.
TalkApiClient.rx.friends()
// 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.
.flatMap { friends ->
FriendsActivity.startForResult(
context,
friends.elements.map { PickerItem(it.uuid, it.profileNickname, it.profileThumbnailImage) }
)
}
.observeOn(Schedulers.io())
.flatMap { selectedItems ->
// 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 [My Appliction] > [Platform] > [Web] in Kakao Developers.
val url = "https://developers.kakao.com"
TalkApiClient.rx.sendScrapMessage(receiverUuids, url)
}
.retryWhen(
// Retry the request to send a message after requesting additional consent to resolve the InsufficientScope error.
RxAuthOperations.instance.incrementalAuthorizationRequired(context)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ result ->
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}")
}
}, { error ->
Log.e(TAG, "Failed to send a message.", error)
})
.addTo(disposables)
// 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 [My Appliction] > [Platform] > [Web] in Kakao Developers.
val url = "https://developers.kakao.com"
// Template ID of the custom template.
// * Refer to the guide: https://developers.kakao.com/docs/latest/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}")
}
}
}
}
}
}
}
var disposables = CompositeDisposable()
// Retrieve a list of friends.
TalkApiClient.rx.friends()
// 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.
.flatMap { friends ->
FriendsActivity.startForResult(
context,
friends.elements.map { PickerItem(it.uuid, it.profileNickname, it.profileThumbnailImage) }
)
}
.observeOn(Schedulers.io())
.flatMap { selectedItems ->
// 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 [My Appliction] > [Platform] > [Web] in Kakao Developers.
val url = "https://developers.kakao.com"
// Template ID of the custom template.
// * Refer to the guide: https://developers.kakao.com/docs/latest/en/message-template/custom
val templateId = templateIds["customMessage"] as Long
TalkApiClient.rx.sendScrapMessage(receiverUuids, url, templateId)
}
.retryWhen(
// Retry the request to send a message after requesting additional consent to resolve the InsufficientScope error.
RxAuthOperations.instance.incrementalAuthorizationRequired(context)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ result ->
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}")
}
}, { error ->
Log.e(TAG, "Failed to send a message.", error)
})
.addTo(disposables)
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.