Skip to main content

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.

  1. Connection Id: kakao_default
  2. Connection Type: kakao (or generic)
  3. Login: Kakao Developers REST API Key (Client ID)
  4. Password: Kakao Refresh Token
  5. 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์„ ์ƒ์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  1. Connection Id: kakao_default
  2. Connection Type: kakao (๋˜๋Š” generic)
  3. Login: ์นด์นด์˜ค ๋””๋ฒจ๋กœํผ์Šค REST API ํ‚ค (Client ID)
  4. Password: ์นด์นด์˜ค Refresh Token
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airflow_provider_kakao-0.0.1.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

airflow_provider_kakao-0.0.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file airflow_provider_kakao-0.0.1.tar.gz.

File metadata

  • Download URL: airflow_provider_kakao-0.0.1.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for airflow_provider_kakao-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c6a84e526287c82ddada5b903c16658d8ac0fdfe5aaa5d6d0aec8c7c58bbc340
MD5 a23483c4d9c5b2354f99e970cc1f77c3
BLAKE2b-256 73da17af36e44e9f2ceb955d84a192c513ab92d8667bcb16f6d70ebc5828115c

See more details on using hashes here.

File details

Details for the file airflow_provider_kakao-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for airflow_provider_kakao-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 02a5b46e54a86f014849ae8a557417991c907c6ce5570845eb0f621bdacaabb7
MD5 fe002d381ea06260d80b2bcfdb622e8d
BLAKE2b-256 c7a0be742916640320fc5b3da1077a4c98daeb00f966087f82de25b310ddf69d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page