Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Directus (DrWade) n8n node for the resource Activity with the operation Create allows you to add a new comment to an item within a specified collection in your Directus instance. This is useful for automating workflows where you need to programmatically log activity, discussions, or notes on items (such as tasks, projects, or records) managed by Directus.

Common scenarios:

  • Automatically commenting on items when certain conditions are met in your workflow.
  • Logging system or user actions for auditing purposes.
  • Adding contextual information to items after automated processing.

Example:
When a support ticket is updated in another system, use this node to post a comment on the corresponding Directus item to keep all stakeholders informed.


Properties

Name Type Meaning
Item String Primary Key of the item to comment on. Specifies which item in the collection will receive the comment.
Comment String The content of the comment to be added. Supports Markdown formatting.
Collection Options The collection in which the target item resides.
JSON/RAW Parameters Boolean If enabled, allows setting body parameters via a raw JSON input instead of individual fields.
Body Parameters JSON (Shown if JSON/RAW Parameters is true) Raw JSON object containing the request body.
Additional Fields Collection Optional extra parameters, such as "Meta" to specify what metadata to return in the response.

Output

  • The output is a single object per execution, under the json field.
  • The structure of the output reflects the response from the Directus API for creating a comment, typically including details about the created comment (such as its ID, content, timestamps, and related item).
  • Example output:
    {
      "id": 123,
      "comment": "This is my comment",
      "collection": "projects",
      "item": "1",
      "user_created": "user_id",
      "date_created": "2024-06-01T12:34:56Z",
      ...
    }
    
  • If the API returns an error and "Continue On Fail" is enabled, the output will contain an error property with the error message.

Dependencies

  • External Service: Requires access to a Directus instance with API enabled.
  • Authentication: Needs valid Directus API credentials configured in n8n (directusApi credential).
  • n8n Configuration: No special environment variables required beyond standard credential setup.

Troubleshooting

Common issues:

  • Missing or invalid credentials: Ensure that the Directus API credentials are correctly set up in n8n.
  • Invalid item or collection: Double-check that the provided item ID and collection name exist in your Directus instance.
  • Insufficient permissions: The API user must have permission to create comments in the specified collection.
  • Malformed JSON: If using "JSON/RAW Parameters", ensure the JSON is properly formatted.

Error messages:

  • "Cannot read properties of undefined": Likely due to missing required fields (e.g., Item, Comment, or Collection).
  • "Request failed with status code 401": Authentication issue; check your credentials.
  • "Request failed with status code 403": Permission issue; verify user roles and permissions in Directus.
  • "Invalid JSON": When using raw JSON input, ensure the syntax is correct.

Links and References


Discussion