Step 1: Define Workflow Trigger and Input Data. Start with a trigger node (e.g., 'Webhook' for external requests, 'Manual' for testing, or 'Read File' for existing content). Use a 'Set' node to define the initial input, such as a blog post topic or an article URL for summarization.
Step 2: Prepare the Prompt for the LLM. Use a 'Set' node to construct your prompt dynamically. Combine static instructions with dynamic input data using expressions. For generation, instruct the LLM on content type, tone, length, and key points. For summarization, specify the desired summary length and focus.
Step 3: Integrate the LLM Node. Add an 'OpenAI' or 'Google Gemini' node. Select the appropriate model (e.g., 'gpt-4o', 'gemini-pro'). Input your prepared prompt into the 'Text' or 'Prompt' field. Configure parameters like 'Temperature' (creativity) and 'Max Tokens' (response length) based on your needs.
Step 4: Parse and Process LLM Output. The LLM node will return a JSON object containing the generated or summarized text. Use a 'Set' node with expressions (e.g., {{ $json.choices[0].message.content }} for OpenAI) to extract the relevant text. You might need 'Code' nodes for more complex parsing or data cleaning.
Step 5: Refine and Enhance (Optional). For complex content generation, you might chain multiple LLM calls. For example, first generate an outline, then iterate through outline points to generate sections. Use 'Split In Batches' and 'Merge' nodes for this iterative process.
Step 6: Conditional Content Generation (Optional). Implement 'If' nodes to create branches based on LLM output or initial input. For instance, if sentiment is negative, generate a different response. Use 'Switch' nodes for multiple content variations.
Step 7: Store or Publish the Output. Use an appropriate integration node to utilize the generated text. Examples include an 'HTTP Request' node to post to a CMS, a 'Google Sheets' node to save data, an 'Email' node to send content, or a 'File' node to save locally.
Step 8: Error Handling and Monitoring. Add 'Error Workflow' nodes to catch and handle potential LLM API errors or unexpected outputs. Monitor workflow executions in n8n for debugging and performance optimization.