페이지 이동경로
  • Docs>
  • Kakao Talk Channel>
  • JavaScript

Kakao Talk Channel

JavaScript

This document describes how to integrate Kakao Talk Channel APIs into your service with the Kakao SDK for JavaScript (hereinafter referred to as 'JavaScript SDK').

You can test the features described in this document in [Tools] > [JS SDK demo] menu.

IMPORTANT

To use the JavaScript SDK, you must register the Web platform in advance. Go to [My Application] > [Platform] and register your site domains.

How to add a button of Kakao Talk Channel

When using the JavaScript SDK, you can use the button images and codes provided in [Tools] > [Social Plugin] menu to implement the features of Kakao Talk Channel. You can implement the Add Channel or Start a chat buttons and codes on your website.

Tag used in this document

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 a specific scope required for the corresponding API.
In addition, a user must also consent to the scope. Otherwise, an error occurs or empty value is returned. To check which scopes a user has consented to, you can call the Retrieving consent details API.

Add Kakao Talk Channel

This API provides a bridge page to allow a user to go to a Kakao Talk Channel and add the channel as a friend.

To use this feature, users must be in a logged-in state. If users click [Add Channel] in a logged-out state, direct them to the login page to log in.

You can use this feature by using either the createAddChannelButton() or addChannel() function. When you want to add the [Add Channel] button and apply this feature to the button, use createAddChannelButton(). If you want to apply this feature to a component on a web page, use addChannel().

Parameter
Name Type Description Required
container String ID of the element where the [Add Channel] button will be added. O
channelPublicId String Kakao Talk Channel ID. O
Sample: createAddChannelButton()
Kakao.Channel.createAddChannelButton({
  container: '#kakao-add-channel-button',
  channelPublicId: '_ZeUTxl' // Use the ID included in the home URL of Kakao Talk Channel.
});
Sample: addChannel()
Kakao.Channel.addChannel({
  channelPublicId: '_ZeUTxl' // Use the ID included in the home URL of Kakao Talk Channel.
});

This API does not inform you whether a user has added the Kakao Talk Channel. To check the added status, use the Check Kakao Talk Channel relationship API that shows the relationship between a user and a Kakao Talk Channel.

Kakao Talk Channel chat

You can implement a feature to allow users to start a Kakao Talk chat by using either the createChatButton() or chat() function:

  • createChatButton: You can add the [Chat] button provided by the JavaScript SDK.
  • chat: You can dynamically create your own button and add the feature to start a chat to the button.

To use this feature, users must be in a logged-in state. If users click [Chat] in a logged-out state, direct them to the login page to log in.

Parameter
Name Type Description Required
container String ID of the element where the [Add Channel] button will be added. O
channelPublicId String Kakao Talk Channel ID. O
Sample: createChatButton()
Kakao.Channel.createChatButton({
  container: '#kakao-talk-channel-chat-button',
  channelPublicId: '_ZeUTxl' // Use the ID included in the home URL of Kakao Talk Channel.
});
Sample: chat()
Kakao.Channel.chat({
  channelPublicId: '_ZeUTxl' // Use the ID included in the home URL of Kakao Talk Channel.
});

This API does not inform you whether the user has successfully started the chat.

Check Kakao Talk Channel relationship Login required Consent required

This API enables you to check if a specific user has added or blocked your Kakao Talk Channel connected to your service app. Make sure that this API only informs the relationship between the user and the Kakao Talk Channel connected to the app that made a request. Thus, you cannot get all Kakao Talk Channels' information that the user has added but the channels related to your service only.

To use this API,

Call the Kakao.API.request() function, and set url to /v1/api/talk/channels. If the request is successful, the added or blocked status returns in JSON format. To see more about the response, refer to REST API.

Parameter
Name Type Description Required
url String Fixed as '/v1/api/talk/channels'. O
success Function(Object) Callback function that gets invoked when the API request is successful. X
fail Function(Object) Callback function that gets invoked if the API request is failed. X
always Function(Object) Callback function that gets invoked regardless of the API request results. X
Sample
Kakao.API.request({
  url: '/v1/api/talk/channels',
  success: function(response) {
    console.log(response);
  },
  fail: function(error) {
    console.log(error);
  }
});
IMPORTANT

To get a notification when a user adds or blocks one of your Kakao Talk Channels linked to you service, use the Kakao Talk Channel callback function.

See more