Part 2: AI Automation
Add Groq AI to transform student requests into professional emails automatically.
4. Part Two: Add AI
In Part 1, we created a basic automation where a student submits a form and n8n sends the information through Gmail.
Now we are going to make the workflow smarter by adding Artificial Intelligence.
Instead of simply sending the student's original message, AI will understand the student's request and turn it into a clear, polite, and professional email.
Student writes normally → AI understands the request → AI creates a professional email → Gmail sends it automatically.
5. Change the Form for AI Automation
Our original form only collected basic information. For AI automation, we need a little more information so that the AI can understand who the student is and what they are asking for.
Updated Form
| Field | Type | Example |
|---|---|---|
| Student Name | Text | Hari Bahadur |
| Faculty Email | student@gmail.com | |
| Department | Dropdown | SSD |
| Subject | Text | Leave Request |
| What do you need? | Textarea | I am feeling sick today and I cannot attend class. I would like to request leave for today. |
Example Student Input
Student Name: Hari Bahadur
Student Email: student@gmail.com
Department: SSD
Subject: Leave Request
What do you need?
I am feeling sick today and I cannot attend class. I would like to request leave for today.
6. Add the Basic LLM Chain
The next step is to add an AI node to our n8n workflow.
n8n provides a node called Basic LLM Chain which allows us to tell an AI model what we want it to do.
Add the Node
- Open your n8n workflow.
- Click the + button.
- Search for Basic LLM Chain.
- Add the node to your workflow.
Connect the Form
Connect the output of your student form to the Basic LLM Chain.
Add the Groq Chat Model
The Basic LLM Chain needs a language model to generate the response.
For this workshop, we will use Groq.
- Open the Basic LLM Chain node.
- Find the model input.
- Select Groq Chat Model.
- Connect the Groq Chat Model to the model input.
Groq Console
Open the Groq Console:
Create a Groq API Key
- Sign in to your Groq account.
- Open the API Keys section.
- Create a new API key.
- Give the key a name such as n8n-workshop.
- Copy the generated API key.
Important Security Rule
Never share your API key.
- Do not post it on GitHub.
- Do not send it to other people.
- Do not include it in public screenshots.
- Do not hard-code it inside public code.
Configure Groq in n8n
- Open the Groq Chat Model node.
- Create a new Groq credential.
- Paste your Groq API key.
- Save the credential.
- Select an available chat model from the model dropdown.
Understand the Two Nodes
Basic LLM Chain
The Basic LLM Chain controls what we want the AI to do.
Groq Chat Model
The Groq Chat Model provides the language model that generates the response.
7. AI Prompt
The prompt is one of the most important parts of the AI automation.
It tells the AI what role it has, what information it receives, and exactly how it should respond.
Copy this prompt into the Basic LLM Chain
You are an AI email assistant for college students. Your job is to
take a student's request, question, complaint, or concern and turn it
into a clear, polite, and professional email that can be sent to the
college department or faculty selected by the student.
Student Information:
Name:
{{ $json['Student Name'] }}
Email:
{{ $json['Faculty Email'] }}
Department / Faculty:
{{ $json['Department'] }}
Subject:
{{ $json['Subject'] }}
Student's Request:
{{ $json['What do you need?'] }}
Instructions:
1. Carefully understand what the student is trying to communicate.
2. Rewrite the student's request into a clear, polite, and
professional email suitable for communication with a college
department or faculty.
3. Keep the student's original meaning and intention.
Do not change what the student is asking for.
4. The request may involve any normal college-related matter,
including leave requests, academic questions, examination issues,
document requests, technical problems, fee-related questions,
complaints, or general concerns.
5. Address the selected department or faculty appropriately.
6. Use a respectful, friendly, and professional tone.
7. Make the request clear and easy for the recipient to understand.
8. Do not invent information, policies, dates, decisions, excuses,
or other details that the student did not provide.
9. Do not promise that the request will be approved or accepted.
The selected department or faculty will make the final decision.
10. If the student's request is unclear, do not invent missing
details. Keep the wording general and politely ask the department
or faculty for clarification if necessary.
11. Keep the email reasonably concise.
Do not make it unnecessarily long.
12. End the email politely with the student's name.
13. Return only the email body.
14. Do not include the subject line, explanation, analysis,
or any additional commentary.
The final output should be a natural, respectful email that is
ready to be sent to the selected college department or faculty.
8. Test the AI
Now let's test whether the AI can understand the student's request and generate a professional email.
Test Data
Name: Hari Bahadur
Email: student@gmail.com
Department: SSD
Subject: Leave Request
Request:
I am feeling sick today and I cannot attend class. I would like to request leave for today.
Expected AI Output
Dear SSD,
I am feeling unwell today and will not be able to attend my classes. I would therefore like to request leave for today.
I would be grateful if you could kindly consider my request.
Thank you for your understanding.
Kind regards,
Hari Bahadur
What Just Happened?
The student did not have to write a perfectly formatted email.
They simply explained what they needed in normal language.
The AI understood the request and converted it into professional communication.
9. Connect AI to Gmail
Once the AI generates the professional email, we can send its output through Gmail.
Gmail Node
Add or use the Gmail node from Part 1.
Subject
Use the subject submitted by the student.
{{ Subject }}
Body
Instead of using the student's original message, use the output generated by the Basic LLM Chain.
Recipient
The selected department or faculty should determine where the email is sent.
| Department | Workshop Demo Email |
|---|---|
| DSSD | yourmail@gmail.com (use your second gmail) |
| RTE | yourmail@gmail.com (use your second gmail) |
| Student Service | yourmail@gmail.com (use your second gmail) |
| Business Department | yourmail@gmail.com (use your second gmail) |
10. Live Demonstration
Now let's run the complete automation.
Step 1
Open the form.
Step 2
Enter required information.
Step 3
Submit the form.
Step 4
n8n receives the form data.
Step 5
The Basic LLM Chain sends the information to the Groq Chat Model.
Step 6
The AI generates a professional email.
Step 7
Gmail sends the generated email.
11. Final AI Automation
At this point, our workflow should look like this:
What Happens Automatically?
- A student submits a request.
- n8n receives the information.
- The AI understands the request.
- The AI creates a professional email.
- Gmail sends the email.
The student only needs to explain what they need.
The automation handles the rest.
12. The Important Difference
| Basic Automation | AI Automation |
|---|---|
| Sends the student's original message | Understands and rewrites the message |
| Fixed message | AI-generated message |
| Limited language understanding | Natural language understanding |
| Mainly follows predefined instructions | Can interpret different student requests |
| No AI model | Uses a language model |
The Main Idea
Traditional automation follows predefined rules.
AI automation allows the workflow to understand natural language and generate useful responses.
13. What We Have Built
We have now upgraded our original n8n workflow into an AI-powered automation system.
The Complete Process
n8n
Connects all the different services and controls the workflow.
Groq AI
Understands the student's request and generates the professional email.
Gmail
Sends the final email automatically.
Student Form
Collects the information required by the workflow.
Core Concept
Automation tells the system what to do.
AI allows the system to understand and generate information.
n8n connects everything together.
Ready for Part 3?
In the next part, we will extend this automation by connecting it to Discord.