Step 1: Define Your Data Source and Extraction Goals. Identify the unstructured text you want to analyze (e.g., product reviews from a spreadsheet, emails from a mailbox, web-scraped data). Clearly define what specific pieces of information you need to extract (e.g., product name, sentiment, specific features mentioned, user ID) and how you want the sentiment categorized (e.g., positive, negative, neutral, mixed).
Step 2: Set Up Your n8n Trigger Node. Use an appropriate trigger node to initiate your workflow. This could be a 'Manual Trigger' for testing, a 'Webhook' for real-time data, a 'Read Binary File' node for CSV/JSON files, or an integration node (e.g., 'Google Sheets' to read reviews).
Step 3: Prepare Data for LLM Processing. Ensure your text data is in a format suitable for the LLM node. If you have multiple items (e.g., an array of reviews), you might need to use a 'Split in Batches' or 'Item Lists' node to process them individually or in manageable chunks.
Step 4: Configure the LLM Node for Data Extraction (NER/Structured Data). Add an LLM node (e.g., 'OpenAI Chat', 'Gemini', 'Claude'). In the 'Prompt' field, craft a precise instruction. For example: 'Extract the following details from the text: product name, user's main complaint, and suggested improvement. Output as a JSON object with keys: 'product', 'complaint', 'suggestion'. If a detail is not present, use null. Text: {{ $json.reviewText }}'. For NER, you might prompt: 'Identify all person names, organizations, and locations mentioned in the following text. Output as a JSON array of objects, each with 'entity_type' and 'entity_name'. Text: {{ $json.documentText }}'. Use 'JSON' as the 'Output Format'.
Step 5: Configure a Second LLM Node for Sentiment Analysis. Add another LLM node. For sentiment, a prompt could be: 'Analyze the sentiment of the following text as either 'Positive', 'Negative', 'Neutral', or 'Mixed'. Provide only the sentiment word. Text: {{ $json.reviewText }}'. Alternatively, you can ask for a sentiment score from -1 to 1. Ensure the output format is suitable for subsequent parsing.
Step 6: Parse and Structure LLM Outputs. Use a 'Code' node or 'Set' node with JSON parsing expressions if the LLM output is a stringified JSON. For simple sentiment words, direct mapping might suffice. For example, JSON.parse($json.llmOutput) in a Code node to convert the extracted structured data into a usable JSON object.
Step 7: Combine and Transform Data. Use 'Merge' or 'Set' nodes to combine the original data with the extracted details and sentiment. This creates a rich, structured dataset for each original item.
Step 8: Store or Utilize the Processed Data. Connect nodes to store your newly structured and analyzed data. Options include a 'Google Sheets' node to append rows, a 'Postgres' or 'MySQL' node to insert into a database, a 'CRM' node to update records, or a 'Slack' node to send notifications based on specific sentiments (e.g., urgent negative feedback).
Step 9: Test and Refine Your Workflow. Run the workflow with various test cases, including edge cases (e.g., very short reviews, reviews with no clear sentiment). Adjust your LLM prompts and data parsing logic until you achieve the desired accuracy and output structure.