Literal AI icon

Literal AI

Use the Literal AI API

Overview

This node integrates with the Literal AI API to manage user data. Specifically, for the "User" resource and the "Get or Create" operation, it attempts to retrieve a user by a given identifier; if the user does not exist, it creates a new one with the provided identifier and optional metadata.

Common scenarios where this node is beneficial include:

  • Ensuring a user exists in the system before performing further operations.
  • Automatically creating users on-the-fly when they are referenced but not yet registered.
  • Synchronizing user data from external systems into Literal AI.

Practical example:

  • When processing an event with a user identifier, use this node to get the existing user or create a new user record with additional metadata such as preferences or profile details.

Properties

Name Meaning
Identifier The unique string identifier of the user to get or create.
Metadata A JSON object containing additional metadata related to the user (e.g., profile info).

Output

The node outputs a JSON object under the content field containing the user data returned by the Literal AI API after the get-or-create operation. This typically includes user details such as their ID, identifier, metadata, and any other relevant user attributes managed by the API.

No binary data output is produced by this operation.

Example output structure (simplified):

{
  "content": {
    "id": "user-id-string",
    "identifier": "user-identifier",
    "metadata": {
      "key1": "value1",
      "key2": "value2"
    },
    ...
  }
}

Dependencies

  • Requires an API key credential for the Literal AI API to authenticate requests.
  • The node uses the official Literal AI client library (@literalai/client) to interact with the API.
  • Proper configuration of the API key credential within n8n is necessary.

Troubleshooting

  • Invalid or missing API key: The node will fail if the API key credential is not set or invalid. Ensure the API key is correctly configured in n8n credentials.
  • Malformed JSON in Metadata: If the metadata property contains invalid JSON, parsing will fail. Make sure the metadata input is valid JSON.
  • User identifier missing or empty: Since the identifier is required, leaving it empty will cause errors. Always provide a valid identifier string.
  • API connectivity issues: Network problems or API downtime can cause request failures. Check network connectivity and Literal AI service status.
  • Error messages from API: The node surfaces error messages from the Literal AI API. Review these messages for specific causes like permission issues or invalid parameters.

To resolve errors:

  • Verify all required inputs are provided and correctly formatted.
  • Confirm API key validity and permissions.
  • Validate JSON syntax for metadata.
  • Retry after network or service interruptions.

Links and References

Discussion