> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Todoist

**TodoistTools** 使代理能够与 [Todoist](https://www.todoist.com/) 进行交互。

## 先决条件

以下示例需要 `todoist-api-python` 库以及可以在 [Todoist 开发者门户](https://app.todoist.com/app/settings/integrations/developer) 获取的 Todoist API 令牌。

```shell theme={null}
pip install todoist-api-python
```

```shell theme={null}
export TODOIST_API_TOKEN=***
```

## 示例

以下代理将创建一个新的 Todoist 任务。

```python cookbook/tools/todoist.py theme={null}
"""
示例展示了如何将 Todoist Tools 与 Agno 一起使用

要求：
- 注册/登录 Todoist 并获取 Todoist API 令牌（从 https://app.todoist.com/app/settings/integrations/developer 获取）
- pip install todoist-api-python

用法：
- 设置以下环境变量：
    export TODOIST_API_TOKEN="your_api_token"

- 或者在创建 TodoistTools 实例时提供它们
"""

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.todoist import TodoistTools

todoist_agent = Agent(
    name="Todoist Agent",
    role="Manage your todoist tasks",
    instructions=[
        "When given a task, create a todoist task for it.",
        "When given a list of tasks, create a todoist task for each one.",
        "When given a task to update, update the todoist task.",
        "When given a task to delete, delete the todoist task.",
        "When given a task to get, get the todoist task.",
    ],
    agent_id="todoist-agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[TodoistTools()],
    markdown=True,
    debug_mode=True,
    show_tool_calls=True,
)

# 示例 1：创建任务
print("\n=== Create a task ===")
todoist_agent.print_response("Create a todoist task to buy groceries tomorrow at 10am")


# 示例 2：删除任务
print("\n=== Delete a task ===")
todoist_agent.print_response(
    "Delete the todoist task to buy groceries tomorrow at 10am"
)


# 示例 3：获取所有任务
print("\n=== Get all tasks ===")
todoist_agent.print_response("Get all the todoist tasks")
```

## Toolkit 参数

| 参数          | 类型    | 默认值    | 描述                            |
| ----------- | ----- | ------ | ----------------------------- |
| `api_token` | `str` | `None` | 如果您想手动提供 TODOIST\_API\_TOKEN。 |

## Toolkit 函数

| 函数                 | 描述                                        |
| ------------------ | ----------------------------------------- |
| `create_task`      | 在 Todoist 中创建一个新任务，可选择分配项目、设置截止日期、优先级和标签。 |
| `get_task`         | 获取特定任务。                                   |
| `update_task`      | 使用内容、截止日期、优先级等新属性更新现有任务。                  |
| `close_task`       | 将任务标记为已完成。                                |
| `delete_task`      | 从 Todoist 中删除特定任务。                        |
| `get_active_tasks` | 检索所有活动的（未完成的）任务。                          |
| `get_projects`     | 检索 Todoist 中的所有项目。                        |

## 开发者资源

* 查看 [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/todoist.py)
* 查看 [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/tools/todoist_tool.py)
