KakaoTalk provider for Apache Airflow
Project description
Apache Airflow Provider for KakaoTalk
Apache Airflow Provider for KakaoTalk allows you to send messages via KakaoTalk API directly from your Airflow DAGs. It supports "Send to Me" (default) and "Send to Friends" features using the Kakao REST API.
๐ Features
- Send to Me: Send notifications (task success/failure alert, reports) to your own KakaoTalk.
- Send to Friends: Send messages to specific friends using their UUIDs.
- Note: The provider automatically chunks the recipient list into batches of 5 to comply with API limits.
- Flexible Message Formats: Supports simple text messages and complex JSON templates (Feed, List, Commerce, etc.).
- Token Management: Automatically refreshes the Access Token using the provided Refresh Token during task execution (Lazy Loading).
๐ฆ Installation
You can install the provider via pip:
pip install apache-airflow-providers-kakao
โ๏ธ Connection Setup
To use this provider, you must create a Connection in the Airflow UI.
- Connection Id:
kakao_default - Connection Type:
kakao(orgeneric) - Login: Kakao Developers REST API Key (Client ID)
- Password: Kakao Refresh Token
- Extra (Optional): If your app uses a Client Secret, provide it in JSON format.
{"client_secret": "YOUR_CLIENT_SECRET"}
โ ๏ธ Prerequisites:
- Your Kakao Application must have the "Send to Me" and "Send to Friends" scopes enabled.
- For "Send to Friends", the target users must be registered as team members in the Kakao Developers console (for testing/dev apps) and must have agreed to the app's permissions.
๐ป Usage
1. Using the Operator (Recommended)
The KakaoTalkOperator is the easiest way to send messages.
from airflow import DAG
from datetime import datetime
from airflow.providers.kakao.operators.kakao import KakaoTalkOperator
with DAG(
dag_id="kakao_example",
start_date=datetime(2026, 1, 1),
schedule=None,
) as dag:
# 1. Simple Text Message (Send to Me)
send_text = KakaoTalkOperator(
task_id="send_text",
text="Hello! The Airflow task has finished successfully. ๐",
kakao_conn_id="kakao_default",
)
# 2. Send to Friends (UUIDs required)
send_friend = KakaoTalkOperator(
task_id="send_friend",
text="Team Alert: Deployment Started",
receiver_uuids=["uuid_1", "uuid_2", "uuid_3"],
kakao_conn_id="kakao_default",
)
# 3. Send Custom JSON Template (Feed, Link, etc.)
# See Kakao Message API docs for template structure
template = {
"object_type": "text",
"text": "Check the detailed report",
"link": {"web_url": "https://airflow.apache.org"},
}
send_template = KakaoTalkOperator(
task_id="send_template",
kakao_kwargs={"template_object": template},
kakao_conn_id="kakao_default",
)
2. Using the Hook (Advanced)
You can use KakaoHook for custom logic or within a PythonOperator.
from airflow.providers.kakao.hooks.kakao import KakaoHook
def my_python_func():
hook = KakaoHook(kakao_conn_id="kakao_default")
# Send message via Hook
hook.send_message(
api_params={"text": "Message sent via KakaoHook."}
)
โ ๏ธ Limitations
- Token Persistence: This provider does not persist the rotated Refresh Token back to the Airflow Metadata Database. It uses the Refresh Token from the connection to get a temporary Access Token for the task.
- Token Expiry: You must manually update the Connection with a new Refresh Token before it expires (typically 2 months), or implement a separate pipeline to handle token rotation and DB updates.
Apache Airflow Provider for KakaoTalk๋ Airflow DAG์์ ์นด์นด์คํก ๋ฉ์์ง๋ฅผ ์ ์กํ ์ ์๊ฒ ํด์ฃผ๋ ์ปค๋ฎค๋ํฐ Provider์ ๋๋ค. ์นด์นด์ค REST API๋ฅผ ์ฌ์ฉํ์ฌ "๋์๊ฒ ๋ณด๋ด๊ธฐ" ๋ฐ "์น๊ตฌ์๊ฒ ๋ณด๋ด๊ธฐ" ๊ธฐ๋ฅ์ ์ง์ํฉ๋๋ค.
๐ ์ฃผ์ ๊ธฐ๋ฅ
- ๋์๊ฒ ๋ณด๋ด๊ธฐ: ์์ ์ฑ๊ณต/์คํจ ์๋ฆผ์ด๋ ๋ฆฌํฌํธ๋ฅผ ๋ด ์นด์นด์คํก์ผ๋ก ์ ์กํฉ๋๋ค.
- ์น๊ตฌ์๊ฒ ๋ณด๋ด๊ธฐ: ์ง์ ๋ ์น๊ตฌ(UUID)๋ค์๊ฒ ๋ฉ์์ง๋ฅผ ์ ์กํฉ๋๋ค.
- ์ฐธ๊ณ : API ์ ํ์ ๋ง์ถฐ ์์ ์ ๋ชฉ๋ก์ ์๋์ผ๋ก 5๋ช ์ฉ ๋๋์ด ์ ์กํฉ๋๋ค.
- ๋ค์ํ ๋ฉ์์ง ํฌ๋งท: ๋จ์ ํ ์คํธ๋ฟ๋ง ์๋๋ผ JSON ํ ํ๋ฆฟ(ํผ๋, ๋ฆฌ์คํธ, ์ปค๋จธ์ค ๋ฑ)์ ์ง์ํฉ๋๋ค.
- ํ ํฐ ๊ด๋ฆฌ: ์์ ์คํ ์ Refresh Token์ ์ฌ์ฉํ์ฌ Access Token์ ์๋์ผ๋ก ๊ฐฑ์ ํฉ๋๋ค (Lazy Loading).
๐ฆ ์ค์น ๋ฐฉ๋ฒ
pip๋ฅผ ํตํด ์ค์นํ ์ ์์ต๋๋ค.
pip install apache-airflow-providers-kakao
โ๏ธ ์ฐ๊ฒฐ ์ค์ (Connection Setup)
Airflow UI์์ Connection์ ์์ฑํด์ผ ํฉ๋๋ค.
- Connection Id:
kakao_default - Connection Type:
kakao(๋๋generic) - Login: ์นด์นด์ค ๋๋ฒจ๋กํผ์ค REST API ํค (Client ID)
- Password: ์นด์นด์ค Refresh Token
- Extra (์ ํ ์ฌํญ): Client Secret์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ JSON์ผ๋ก ์
๋ ฅ
{"client_secret": "YOUR_CLIENT_SECRET"}
โ ๏ธ ์ฌ์ ์๊ตฌ์ฌํญ:
- ์นด์นด์ค ์ ํ๋ฆฌ์ผ์ด์ ์ค์ ์์ "๋์๊ฒ ๋ณด๋ด๊ธฐ" ๋ฐ "์น๊ตฌ์๊ฒ ๋ณด๋ด๊ธฐ" ๊ถํ(Scope)์ด ํ์ฑํ๋์ด ์์ด์ผ ํฉ๋๋ค.
- "์น๊ตฌ์๊ฒ ๋ณด๋ด๊ธฐ"๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด, ์์ ์๊ฐ ์นด์นด์ค ๋๋ฒจ๋กํผ์ค ํ์์ผ๋ก ๋ฑ๋ก๋์ด ์์ด์ผ ํ๋ฉฐ(ํ ์คํธ ์ฑ์ ๊ฒฝ์ฐ), ์ฑ ๊ถํ์ ๋์ํ ์ํ์ฌ์ผ ํฉ๋๋ค.
๐ป ์ฌ์ฉ๋ฒ
1. Operator ์ฌ์ฉ (๊ถ์ฅ)
KakaoTalkOperator๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ๋จํ๊ฒ ๋ฉ์์ง๋ฅผ ๋ณด๋ผ ์ ์์ต๋๋ค.
from airflow import DAG
from datetime import datetime
from airflow.providers.kakao.operators.kakao import KakaoTalkOperator
with DAG(
dag_id="kakao_example",
start_date=datetime(2026, 1, 1),
schedule=None,
) as dag:
# 1. ๋จ์ ํ
์คํธ ๋ฉ์์ง (๋์๊ฒ ๋ณด๋ด๊ธฐ)
send_text = KakaoTalkOperator(
task_id="send_text",
text="์๋
ํ์ธ์! Airflow ์์
์ด ์ฑ๊ณต์ ์ผ๋ก ์๋ฃ๋์์ต๋๋ค. ๐",
kakao_conn_id="kakao_default",
)
# 2. ์น๊ตฌ์๊ฒ ๋ณด๋ด๊ธฐ (UUID ํ์)
send_friend = KakaoTalkOperator(
task_id="send_friend",
text="ํ์ ์๋ฆผ: ๋ฐฐํฌ๊ฐ ์์๋์์ต๋๋ค.",
receiver_uuids=["uuid_1", "uuid_2", "uuid_3"],
kakao_conn_id="kakao_default",
)
# 3. ์ปค์คํ
JSON ํ
ํ๋ฆฟ ๋ณด๋ด๊ธฐ (ํผ๋, ๋งํฌ ๋ฑ)
# ํ
ํ๋ฆฟ ๊ตฌ์กฐ๋ ์นด์นด์ค ๋ฉ์์ง API ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํ์ธ์.
template = {
"object_type": "text",
"text": "์์ธํ ๋ฆฌํฌํธ ํ์ธํ๊ธฐ",
"link": {"web_url": "https://airflow.apache.org"},
}
send_template = KakaoTalkOperator(
task_id="send_template",
kakao_kwargs={"template_object": template},
kakao_conn_id="kakao_default",
)
2. Hook ์ฌ์ฉ (๊ณ ๊ธ)
PythonOperator ๋ด๋ถ๋ ์ปค์คํ
๋ก์ง์์ KakaoHook์ ์ง์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
from airflow.providers.kakao.hooks.kakao import KakaoHook
def my_python_func():
hook = KakaoHook(kakao_conn_id="kakao_default")
# Hook์ ์ด์ฉํ ๋ฉ์์ง ์ ์ก
hook.send_message(
api_params={"text": "KakaoHook์ ํตํด ์ ์ก๋ ๋ฉ์์ง์
๋๋ค."}
)
โ ๏ธ ์ ์ฝ ์ฌํญ
- ํ ํฐ ์๊ตฌ ์ ์ฅ ๋ฏธ์ง์: ์ด Provider๋ ๊ฐฑ์ ๋ Refresh Token์ Airflow ๋ฉํ๋ฐ์ดํฐ DB์ ์ ์ฅํ์ง ์์ต๋๋ค. ์ฐ๊ฒฐ(Connection)์ ์ ์ฅ๋ Refresh Token์ ์ฌ์ฉํ์ฌ ์ผํ์ฑ Access Token์ ๋ฐ๊ธ๋ฐ๋ ๋ฐฉ์์ ๋๋ค.
- ํ ํฐ ๋ง๋ฃ ๊ด๋ฆฌ: Refresh Token์ด ๋ง๋ฃ(๋ณดํต 2๋ฌ)๋๊ธฐ ์ ์ Connection ์ ๋ณด๋ฅผ ์๋์ผ๋ก ์ ๋ฐ์ดํธํ๊ฑฐ๋, ๋ณ๋์ ํ ํฐ ๊ฐฑ์ ํ์ดํ๋ผ์ธ์ ๊ตฌ์ถํด์ผ ํฉ๋๋ค.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file airflow_provider_kakao-0.0.2.tar.gz.
File metadata
- Download URL: airflow_provider_kakao-0.0.2.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0408dd471e7700dbd912b312d3e77b7f4af900d5d19386d2d510bde12fd511c3
|
|
| MD5 |
7f6938af1fc335dbadb0e50d1daec99f
|
|
| BLAKE2b-256 |
ca753ece388156aab88f54c1c94dacdd256fa36c77b18f26feeebeacd881105f
|
File details
Details for the file airflow_provider_kakao-0.0.2-py3-none-any.whl.
File metadata
- Download URL: airflow_provider_kakao-0.0.2-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e67ade47a31f96cdc43c53a168a27886155db97678005717c8578c3f8ceeda73
|
|
| MD5 |
39974ea10f1956456465e8404204a895
|
|
| BLAKE2b-256 |
3c13f72b74614dbbf5b97521495f42a2c72b220baa2bd07757cd0765467e52eb
|