_get_dingtalk_access_token
_make_dingtalk_request
- method (
Literal["GET", "POST"]
): HTTP method to use. - endpoint (str): API endpoint path. **kwargs: Additional arguments passed to requests.
- Exception: If API request fails or returns error.
_generate_signature
- secret (str): Webhook secret.
- timestamp (str): Current timestamp.
DingtalkToolkit
init
- timeout (Optional[float]): Timeout for API requests in seconds.
_initialize_token_safely
dingtalk_send_text_message
- userid (str): The user’s userid.
- content (str): Message content.
dingtalk_send_markdown_message
- userid (str): The user’s userid.
- title (str): Message title.
- markdown_content (str): Markdown formatted content.
dingtalk_get_user_info
- userid (str): The user’s userid.
dingtalk_get_department_list
- dept_id (Optional[int]): Department ID. If None, gets root departments.
dingtalk_get_department_users
- dept_id (int): Department ID.
- offset (int): Offset for pagination (default: 0). (default: 0)
- size (int): Number of users to retrieve (default: 100, max: 100). (default: 100, max: 100)
dingtalk_search_users_by_name
- name (str): User name to search for.
dingtalk_send_webhook_message
- content (str): Message content.
- msgtype (Literal): Message type (text, markdown, link, actionCard).
- title (Optional[str]): Message title (required for markdown).
- webhook_url (Optional[str]): Webhook URL. If None, uses env var.
- webhook_secret (Optional[str]): Webhook secret. If None, uses env var.
dingtalk_create_group
- name (str): Group name.
- owner (str): Group owner’s userid.
- useridlist (List[str]): List of user IDs to add to the group.
dingtalk_send_group_message
- chatid (str): Group chat ID.
- content (str): Message content.
- msgtype (
Literal["text", "markdown"]
): Message type.
dingtalk_send_link_message
- userid (str): The user’s userid.
- title (str): Link title.
- text (str): Link description text.
- message_url (str): URL to link to.
- pic_url (Optional[str]): Picture URL for the link.
dingtalk_send_action_card_message
- userid (str): The user’s userid.
- title (str): Card title.
- text (str): Card content text.
- single_title (str): Action button title.
- single_url (str): Action button URL.
dingtalk_get_user_by_mobile
- mobile (str): User’s mobile number. Should be a valid Chinese mobile number format (11 digits starting with 1).
dingtalk_get_user_by_unionid
- unionid (str): User’s unique identifier across all DingTalk organizations. This is a global identifier that remains consistent even if the user belongs to multiple DingTalk organizations, unlike userid which is organization-specific.
dingtalk_get_department_detail
- dept_id (int): Department ID.
dingtalk_send_oa_message
- userid (str): The user’s userid.
- message_url (str): URL for the message action.
- head_bgcolor (str): Header background color (hex format).
- head_text (str): Header text.
- body_title (str): Body title.
- body_content (str): Body content.
dingtalk_get_group_info
- chatid (str): Group chat ID.
dingtalk_update_group
- chatid (str): Group chat ID.
- name (Optional[str]): New group name.
- owner (Optional[str]): New group owner userid.
- add_useridlist (Optional[List[str]]): List of user IDs to add.
dingtalk_send_work_notification
- userid_list (List[str]): List of user IDs to send to.
dingtalk_get_userid_by_phone
- phone_number (str): User’s phone number.
dingtalk_get_userid_by_name
- user_name (str): User’s display name.
dingtalk_get_department_id_by_name
- department_name (str): Department name to search for.
dingtalk_get_chatid_by_group_name
- group_name (str): Group name to search for.