> ## 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 工具

## 代码

```python cookbook/tools/todoist_tools.py theme={null}
"""
展示如何使用 Todoist 工具的 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")
```

## 用法

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="设置您的 API 令牌">
    ```bash theme={null}
    export TODOIST_API_TOKEN=xxx
    export OPENAI_API_KEY=xxx
    ```
  </Step>

  <Step title="安装库">
    ```bash theme={null}
    pip install -U todoist-api-python openai agno
    ```
  </Step>

  <Step title="运行 Agent">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/tools/todoist_tools.py
      ```

      ```bash Windows theme={null}
      python cookbook/tools/todoist_tools.py
      ```
    </CodeGroup>
  </Step>
</Steps>
