Customje icon

Customje

Custom operations

Overview

This node provides a custom integration to generate AI-powered responses using OpenAI models. It is designed to create conversational replies tailored for sales or customer interaction scenarios, leveraging detailed contextual inputs such as job scope, product details, and user queries.

Typical use cases include:

  • Generating persuasive sales messages based on product descriptions and sales scripts.
  • Creating personalized assistant replies that reflect a specific role or job scope.
  • Producing formatted conversational outputs for chatbots or customer support automation.

For example, a user selling "kek batik" (a type of cake) can input product details, a closing sales script, and a user query, and the node will return a structured response with multiple message types (text, images) suitable for engaging customers.

Properties

Name Meaning
API Token OpenAI API Token used for authenticating requests to the OpenAI service.
Model The OpenAI model to use for generating responses. Options: gpt-4.1, gpt-4.1-mini, gpt-4o, gpt-4o-mini, O3, o3-mini, o3-pro.
Name Name assigned to the AI assistant, used in the system prompt to personalize responses.
Job Scope Description of the job scope or role of the AI assistant, providing context for generating relevant replies.
Current Date Current date and time string, used to provide temporal context in the prompt. Defaults to the current timestamp formatted as DD/MM/YYYY hh:mm A.
Reply Format Desired format or style for the AI's reply, e.g., persuasive, concise, or friendly tone.
Product & Services Details Detailed description of products and services offered, used to inform the AI's generated content.
Close Sales Script Optional script text intended to close sales, which the AI can incorporate into its responses.
User The user's input or request that the AI should respond to.
Previous Response ID Optional ID of a previous response to maintain context or continuity in multi-turn conversations.

Output

The node outputs a JSON array where each item corresponds to the AI-generated response for an input item. The main output structure includes:

  • allmessage: An array of message objects, each containing:
    • chat_number: The sequence number of the message in the conversation.
    • message: The textual content of the message.
    • type: The type of message, e.g., "text" or "image".
    • urlMedia: URL of media if the message type is an image; empty string otherwise.

This structure allows the node to deliver rich, multi-part responses including both text and media elements.

If binary data were involved, it would typically represent media content linked in the messages, but this node returns media URLs rather than raw binary data.

Dependencies

  • Requires an active OpenAI API token for authentication.
  • Makes HTTP POST requests to the OpenAI endpoint at https://api.openai.com/v1/responses with a special header indicating beta usage of the "responses" feature.
  • No additional external dependencies beyond standard HTTP request capabilities provided by n8n.

Troubleshooting

  • Common issues:

    • Invalid or missing API token will cause authentication failures.
    • Incorrect model selection may lead to unexpected results or errors.
    • Malformed or incomplete input properties (e.g., missing required fields like name or user) can cause the API to reject the request.
    • Network connectivity problems can prevent successful API calls.
  • Error messages:

    • Errors returned from the OpenAI API are parsed and rethrown with details including status code, error message, type, and code.
    • Example: Error 401: Unauthorized - invalid_api_key - 1234
  • Resolution tips:

    • Verify the API token is correct and has necessary permissions.
    • Ensure all required input fields are filled properly.
    • Check network access and firewall settings.
    • Review the OpenAI API documentation for model-specific constraints.

Links and References

Discussion