Tag: Groq

  • Website AI Customer Support Chatbot with Google Sheets Knowledge Base


    This workflow creates an AI-powered customer support chatbot with a Google Sheets knowledge base. Here’s a breakdown of how it works and how you can use it to handle customer requests:

    How the Workflow Functions

    1. Customer Interaction Entry Point: When a customer sends a message through your website chat interface, the “When chat message received” node captures this input.
    2. Context Management: The “Chat History” node maintains a record of the last 10 conversation exchanges, providing context for the AI to understand the ongoing conversation.
    3. AI Processing: The “AI Agent” node acts as the brain of the system, programmed to function as a support assistant. It’s configured to use the Google Sheets tool to retrieve relevant data based on customer requests.
    4. Language Model: The “Groq Chat Model” powers the AI’s language understanding and response generation capabilities.
    5. Knowledge Base Access: The “Google Sheets” node connects to your Google Sheets database, allowing the AI to look up specific information to answer customer queries.

    How to Use It for Customer Support

    1. Set Up Your Knowledge Base: Organize your support information in a Google Sheet with clear headers and structured data. For example:
    • Common questions and answers
    • Product specifications
    • Troubleshooting guides
    • Pricing information
    • Return policies
    1. Configure the Google Sheets Node: Connect it to your specific Google Sheet document and worksheet that contains your knowledge base.
    2. Deploy the Chatbot: Make the chat public and embed it on your website using the chat integration options.
    3. Customer Interaction Flow:
    • A customer sends a question through the chat
    • The AI agent processes the request
    • It searches the Google Sheets knowledge base for relevant information
    • It formulates a helpful response based on the retrieved data
    • The customer receives a contextually appropriate answer
    1. Monitor and Refine: Review chat logs periodically to identify common questions or knowledge gaps, then update your Google Sheets database accordingly.

    Template for website embedding: View on Codepen

    This workflow is particularly effective for handling routine inquiries that have standard responses stored in your knowledge base, freeing up your human support team to focus on more complex or unique customer issues.

  • How to build an AI-powered Email Responder (Gmail) – n8n Workflow Template


    This documentation outlines an enhanced n8n workflow designed to send emails with dynamic content. The workflow includes four key nodes: Start, Set, Send Email, and Sticky Note. By following the steps in this guide, you’ll set up an automated process that prepares an email with dynamic content and sends it using your preferred email provider.

    Prerequisites

    Before getting started, ensure you have the following:

    • An active n8n instance to import and modify workflows.
    • A valid email provider account. The current workflow is based on the built-in Email node, but adjustments can be made for providers like Gmail.
    • A basic understanding of n8n concepts, such as nodes, workflows, and expressions.

    Workflow Overview

    The workflow consists of four nodes:

    Start Node

    • This node triggers the workflow’s execution.
    • No configuration is required for this node.

    Set Node (“Set Email Content”)

    • This node creates a data property called content that stores the email body text.
    • The value in this node is passed on to the next node, which handles sending the email.

    Send Email Node

    • This node sends the email using the configured parameters.
    • The email body is retrieved using the expression {{$json["content"]}} from the previous node.
    • You need to configure the email parameters, such as sender email, recipient email, and subject.

    Sticky Note Node

    • This node serves as an internal note for documenting the workflow.
    • It does not affect workflow execution but can be updated with relevant information.

    How to Use the Workflow

    Import the Workflow into n8n

    1. Open your n8n editor.
    2. Import the workflow by pasting the provided JSON code.
    3. Save the workflow with a meaningful name (e.g., “Dynamic Email Sending Workflow”).

    Configure the Workflow Nodes

    1. Set Node:
      • Edit the content value with the desired email message.
    2. Send Email Node:
      • Update the sender’s email address (your-email@example.com).
      • Change the recipient’s email address (recipient@example.com).
      • Modify the subject line as needed.
      • If you’re using a different email provider, update the node’s configuration accordingly.

    Activate and Test the Workflow

    1. Activate the workflow to enable automatic triggers.
    2. Run a test and check the execution logs to ensure the email is sent correctly.
    3. Confirm that the email body matches the content set in the Set node.

    Next Steps and References

    Customize for Other Email Providers

    • If using Gmail or a different provider, replace the Email node with the corresponding service node (e.g., Gmail node).
    • Update the authentication and configuration settings to match your provider.

    Expand the Workflow Functionality

    • Add additional nodes, such as Conditional or Function nodes, to process data before sending the email.
    • Integrate with other services or APIs to enhance the workflow’s capabilities.

    Learn More About n8n

    • Visit the n8n documentation for detailed guides and examples.
    • Explore additional workflow examples and discussions in the n8n community forums.

    By following these instructions, you’ll have a dynamic email-sending workflow set up in n8n, ready to be customized and expanded to meet your specific needs.

  • How to build an AI Chatbot – n8n Workflow Template

    Below is a step-by-step guide on how to build an AI Chatbot in n8n using the workflow template shown in your image. This example uses the Groq Chat Model node (though you could also use other LLMs or AI model nodes) and demonstrates storing conversation history in a MySQL database. You can adapt these steps to any other SQL or NoSQL database you prefer.


    Overview of the Workflow

    1. Trigger: “When chat message is received”
      • This node will listen for incoming messages (e.g., from a chatbot interface on your website).
    2. Groq Chat Model
      • The AI model node that generates a response based on the user’s message (and optionally prior context).
    3. Chat History
      • Manages the memory of the conversation (how many tokens or messages you keep in context).
    4. AI Agent
      • A logic or “router” node that determines how to handle the AI’s response (for instance, storing it, sending it back, etc.).
    5. MySQL
      • Stores the conversation data, user info, or any other information you’d like to keep for future reference.
    6. MySQL Schema & MySQL Definition
      • These nodes define or reference the structure of your MySQL database tables and fields.
    7. Response to the User
      • Typically, you’ll have a final step (e.g., an HTTP Response node) that sends the AI’s reply back to the user’s chat interface.

    Prerequisites

    • n8n installed and running (locally or on a server).
    • Groq Chat Model (or another AI model node) credentials set up in n8n.
    • MySQL database running and accessible to n8n (or a different database if you prefer).
    • Credentials for your database configured in n8n.

    Step 1: Set Up Your Trigger

    1. Add a Trigger Node
      • In your n8n canvas, add a node that triggers when a new chat message is received.
      • If you’re embedding this on a website, you might use an HTTP Request node or Webhook node that captures the user’s message.
    2. Configure the Trigger
      • Specify the endpoint or connection details so that whenever a user sends a message in your chat interface, it arrives here.
      • Test by sending a sample request/message to ensure n8n is receiving it.

    Step 2: Connect to the Groq Chat Model (or Your Preferred AI Model)

    1. Add the Groq Chat Model Node
      • In the Groq Chat Model node, set your model credentials and configuration.
      • Configure concurrency if you expect multiple simultaneous users.
    2. Passing the Prompt
      • Map the user’s message from the trigger node into the Groq Chat Model node’s “prompt” or “input” field.
      • Optionally, you can include system instructions (like the chatbot’s persona or guidelines) in the node configuration.
    3. Tokens and Concurrency
      • Adjust the maximum tokens setting if your conversation or responses tend to be long.
      • Increase concurrency to handle multiple requests in parallel if needed.

    Step 3: Add a Chat History Node

    1. Insert Chat History Node
      • Connect the output of the Groq Chat Model to the Chat History node.
      • This node manages how much of the conversation is remembered.
    2. Configure the Chat History
      • Decide whether you want to pass the entire conversation or only the last message to the next node.
      • Set how many tokens (or messages) you want to store, so the model can keep context of previous user queries and AI responses.
    3. Pass the Updated History
      • The Chat History node will output the user’s current message plus the conversation context. This can be fed back into the Groq Chat Model on subsequent turns, ensuring context is maintained.

    Step 4: AI Agent Node

    1. Add the AI Agent Node
      • This node is optional if you want to incorporate additional logic or branching after the model generates a response.
      • It can serve as a router to decide whether to store data, perform certain actions, or modify the response before sending it back.
    2. Configure AI Agent Logic
      • For instance, you might have conditions such as “If the user asks about X, fetch data from the database first.”
      • Or “If the user wants to store new info, call the MySQL node to insert data.”

    Step 5: Connect to MySQL (or Your Preferred Database)

    1. Add the MySQL Node
      • Provide your MySQL credentials and server details in the node’s credentials.
    2. Define Your Schema
      • The MySQL Schema and MySQL Definition nodes help structure how data is stored (e.g., user ID, message content, timestamp).
      • Example fields:
        • id (primary key)
        • user_id
        • user_message
        • ai_response
        • timestamp
    3. Insert or Select Data
      • In the MySQL node, set the Operation to Insert if you want to store new chat messages.
      • Use Select if you need to retrieve stored data to provide context to the AI model (e.g., user’s preferences).
    4. Map Data
      • Map the user’s message and AI response into the appropriate fields.
      • For example, you might pass {{$json["message"]}} to the user_message column, and {{$json["response"]}} to the ai_response column.

    Step 6: Return the AI’s Response to the User

    1. Add a Response Node
      • Typically, you’d add an HTTP Response node or use a final step in your messaging platform node to send the AI’s response back.
      • Map the AI response from either the Groq Chat Model node or the AI Agent node into the response field.
    2. Testing
      • Send a test message from your chat interface or via a tool like cURL or Postman.
      • Confirm that the AI’s response is returned successfully and that data is inserted into your MySQL table.

    Step 7: Embed the Chatbot in Your Website (Optional)

    1. Create a Front-End Interface
      • You can build a simple chat box on your site using HTML/JavaScript or a framework like React/Vue.
      • The chat box should send messages to your n8n Webhook (the same one used in the trigger node).
    2. Make the Workflow Public
      • If you want external access, ensure your n8n instance is publicly accessible.
      • You can secure it with an API key or other authentication methods.
    3. Test in Production
      • Send messages from your website’s chat box.
      • Check logs in n8n to ensure messages are flowing through the workflow and responses are coming back.

    Tips and Best Practices

    • Security: Always secure your n8n endpoints. Use environment variables or n8n’s credential manager to store API keys and database credentials.
    • Conversation Length: Keep an eye on token usage to avoid hitting API or model limits. Adjust the chat history to store fewer messages if needed.
    • Database Maintenance: If you store all conversations, consider a cleanup mechanism or an archive strategy.
    • Scaling: If you expect high traffic, ensure concurrency settings and server resources are sufficient. You may also want to add caching layers or handle concurrency in your database.
    • Customization: You can integrate other nodes in n8n to perform tasks (e.g., sending emails, retrieving data from external APIs) based on the user’s query.

    Conclusion

    By following these steps, you’ll have a functional AI Chatbot workflow in n8n that:

    1. Receives a message from a user.
    2. Passes it to the Groq Chat Model (or your AI model of choice).
    3. Maintains conversation context with the Chat History node.
    4. Optionally routes through an AI Agent for further logic.
    5. Stores or retrieves data in MySQL.
    6. Sends the AI’s response back to the user.

    This setup gives you a powerful and flexible platform to customize your chatbot’s behavior, maintain user context, and integrate with any data source you need. Feel free to add more logic nodes or custom scripts to further enhance your chatbot’s capabilities.