Hi everyone,
I’m currently working on building an AI-powered agent within n8n to manage Todoist tasks based on natural language input. The goal is to have a seamless integration where a user can make requests (e.g., “Create a task ‘Review report’ in project ‘Client Work’, section ‘Pending Review’ with the label ‘urgent’”), and the agent handles the task creation/update in Todoist.
My Workflow Setup:
- User input (e.g., chat message) triggers the workflow.
- An OpenAI Chat Model node (using function calling, within a Langchain agent structure) processes the request to extract key information like task content, target project name, target section name, and label names.
- Subsequent n8n nodes are supposed to process this information and interact with the Todoist API.
I’m facing difficulties specifically when trying to create or update tasks that require specifying a Project ID and a Section ID.
- The AI model correctly identifies the names of the project and section based on the user’s request.
- However, the Todoist nodes (like “Create Task”) require the numerical Project ID and Section ID for these operations.
- My attempts to dynamically look up these IDs based on the names provided by the AI often fail, leading to errors like “400 Bad Request - Invalid argument value”.
Specific Problem Area:
I’m struggling to find a robust way to:
- Reliably fetch the correct Project ID using the project name provided by the AI (using “Todoist - Get Many Projects” with filters).
- Crucially, fetch the correct Section ID using the section name provided by the AI, ensuring it belongs to the specific Project ID found in the previous step (using “Todoist - Get Many Sections” with filters for both Project ID and Section Name).
- Handle potential errors gracefully (e.g., project/section name not found, or multiple matches).
I suspect my current method of filtering and mapping the results might be incorrect, especially in reliably passing the correct IDs to the final Todoist “Create Task” node.
My Question:
Could anyone share best practices, node configurations, or example workflow snippets for reliably mapping project/section names (identified by an AI) to their corresponding IDs in Todoist within an n8n workflow? How do you handle the dependency between finding the Project ID first and then finding the Section ID within that specific project?
I’m happy to provide a link to my current workflow template for context.
Thanks so much in advance for any guidance or suggestions!
Here’s the JSON code