How to develop the kakao notification talk which doesn’t need follow to channel

송지혁
4 min readMay 4, 2021

--

If we need to send a channel message to client, even though the client have not followed our channel, we can use the kakao notification talk.

You need to know the phone numbers of customer. Then you can send the message to the client even though the client have not followed your channel. Also your message template need to be confirmed by the kakao.

I will introduce the way that how to use that.

first of all ,we need to open a kakao biz channel. You can do this in this URL.

https://business.kakao.com/

Second, We need to do partnership with kakao partners that provide kakao notification talk api. The api have payment by numbers of notification talk.

The kakao partners that provide kakao alarm talk api

If you are not used to speak in korean or not easy to contact korean company, i recommend to use Naver cloud service for Alarm talk. Because the document of Naver cloud service provides English version.

First Of all, To use that you should have a kakao business channel . Also you must have a Naver Id. So register a Naver Id. and Kakao business channel.

registered kakao channel

Second, you should register the kakao Channel and template to Naver cloud platform. All the process are explained in this source. Check this source.

https://guide.ncloud-docs.com/docs/en/sens-sens-1-5

Third, you can use Naver cloud api to do alarm talk. The templates should be confirmed. How to use open api is also well explained in Naver cloud api documents. Check this source.

https://api.ncloud-docs.com/docs/en/ai-application-service-sens-alimtalkv2

All the sources are well explained and also explained in English. Just follow as explained. I hope the alarm talk work well in your project.

  1. You need authentification information in header.

you need access key and secret key. You can get these keys by your account management console. You should hash the secret key before send it on header.

import sys
import os
import hashlib
import hmac
import base64
import requests
import time

def make_signature():
timestamp = int(time.time() * 1000)
timestamp = str(timestamp)

access_key = "{accessKey}" # access key id (from portal or Sub Account)
secret_key = "{secretKey}" # secret key (from portal or Sub Account)
secret_key = bytes(secret_key, 'UTF-8')

method = "GET"
uri = "/photos/puppy.jpg?query1=&query2" // This is exampe of some api. Not a message api.

message = method + " " + uri + "\n" + timestamp + "\n"
+ access_key
message = bytes(message, 'UTF-8')
signingKey = base64.b64encode(hmac.new(secret_key, message, digestmod=hashlib.sha256).digest())
return signingKey

2. need service id in URL

/services/{serviceId}/messages

/services/ncp:kk*********:alarmtalk/messages

3. reservation time, zone should be provided.

4. Valid phone number and the country type are needed

5. Content should be the same as template you had confirmed.

6. reserve time should have 10 minute buffer. ( now : PM 10: 13 => PM 10:23 can be reserved)

Here is the body example.

{
“templateCode”: “cancel”,
“plusFriendId”: “@PLUSFRIENDID”,
“messages”: [
{
“countryCode”: “82”,
“to”: “01011111111”,
“content”: “[예약 취소 안내드립니다]안녕하세요. 고객님이 예약한 서비스가 취소되었음을 알려드립니다. 해당 클라스 비용은 환불될 예정입니다. 불편을 드려서 죄송합니다.”,
“useSmsFailover”: true,
“failoverConfig”: {
“type”: “string”,
“from”: “string”,
“subject”: “string”,
“content”: “string”
}
}
],
“scheduleCode”: “string”,
“reserveTime”: “2021–06–02 15:26”,
“reserveTimeZone”: “Asia/Seoul”
}

After that you can check that the message did success or not in your naver cloud console.

This is full python code.

import requests

import json

import sys

import os

import hashlib

import hmac

import base64

import requests

import time

uri=”https://sens.apigw.ntruss.com/alimtalk/v2/services/{serviceId}/messages"

timestamp = int(time.time() * 1000)

timestamp = str(timestamp)

to_country = “COUNTRY_CODE”

to_number = “PHONENUMBER”

message_time = “2021–06–15 14:29”

time_zone = “Asia/seoul”

def make_signature():

access_key = “ACCESSKEY” # access key id (from portal or Sub Account)

secret_key = “SECRET KEY” # secret key (from portal or Sub Account)

secret_key = bytes(secret_key, ‘UTF-8’)

method = “POST”

url = “/alimtalk/v2/services/{serviceId}/messages”

message = method + “ “ + url + “\n” + timestamp + “\n” + access_key

message = bytes(message, ‘UTF-8’)

signingKey = base64.b64encode(hmac.new(secret_key, message, digestmod=hashlib.sha256).digest())

return signingKey

signature = make_signature()

signature = str(make_signature())[2:-1]

body = {

“plusFriendId”:”@PLUSFRIENDID”,

“templateCode”:”cancel”,

“messages”:[

{

“countryCode”:to_country,

“to”:to_number,

“content”:”[예약 취소 안내드립니다]안녕하세요. 고객님이 예약한 서비스가 취소되었음을 알려드립니다. 해당 클라스 비용은 환불될 예정입니다. 불편을 드려서 죄송합니다.”

,

“useSmsFailover”: “false”,

“failoverConfig”: {

“type”: “string”,

“from”: “string”,

“subject”: “string”,

“content”: “string”

}

}

]#,

#”reserveTime”: message_time,

#”reserveTimeZone”:time_zone

}

body = json.dumps(body)

headers = {“Content-Type”: “application/json; charset=UTF-8”,

“x-ncp-apigw-timestamp”: timestamp,

“x-ncp-iam-access-key”: “ACCESS-KEY”,

“x-ncp-apigw-signature-v2”:signature

}

response = requests.post(uri, headers=headers,data=body)

print(response.json())

if response.json()[‘messages’][0][“requestStatusCode”] != “A000”:

print(“message Failed”)

else:

print(“message successed”)

https://sens.apigw.ntruss.com/apigw/swagger-ui?productId=plv61henn8&apiId=v5ct56inz5&stageId=34jilvhp11&region=KR

You can also check this api by swagger-ui. I hope you guys do well. If have problem with this. send a mail to me. songjihyeok@grey-zero.com

--

--

No responses yet