Introduction
In this task, you will develop an automated monitoring system for industrial temperature sensors using n8n (a workflow automation tool) and API integration. You will create a workflow that continuously monitors two temperature sensors and sends alerts to Telegram when anomalies are detected. This simulates real-world industrial monitoring scenarios where engineers need to track sensor data and receive immediate notifications when equipment operates outside safe parameters.
The temperature sensors should operate between -100°C and +100°C. Values outside this range indicate potential equipment failure or dangerous conditions requiring immediate attention.
Part A: System Analysis and Setup (LO1)
Learning Outcome 1: Analyse an engineering application to facilitate the development of a software solution using rapid application development (RAD) techniques.
In this section, you will analyze the industrial monitoring requirements, understand the API structure, and plan your n8n workflow architecture. This analysis phase is crucial for identifying system requirements, data flow patterns, and potential failure points before implementation.
Step 1: Install and Setup n8n
First, install n8n on your system. n8n is a powerful workflow automation tool that allows you to connect different services and APIs without extensive coding.
# Install n8n globally using npm
npm install n8n -g
# Start n8n (this will open the interface in your browser)
n8n
Step 2: Analyze the Temperature Sensor API
Test the provided API endpoint to understand its structure and response format. The API simulates two industrial temperature sensors.
API Endpoint: https://fakerapi.it/api/v2/custom?_quantity=1&sensor_voltage=longitude&sensor_current=longitude
Note: The API returns "sensor_voltage" and "sensor_current" but we'll treat these as temperature readings from sensor_1 and sensor_2 respectively. The values represent temperature in Celsius and should be between -100 and +100 for normal operation.
Step 3: Setup Telegram Bot
Create a Telegram bot that will receive alert notifications when temperature anomalies are detected.
- Open Telegram and search for "@BotFather"
- Send
/newbotto create a new bot - Follow the prompts to name your bot (e.g., "TempMonitorBot")
- Save the Bot Token provided by BotFather
- Start a conversation with your bot and send any message
- Get your Chat ID by visiting:
https://api.telegram.org/bot[YOUR_BOT_TOKEN]/getUpdates
Part B: Workflow Development (LO2)
Learning Outcome 2: Develop a software solution for an engineering application using RAD techniques.
You will now implement the monitoring workflow using n8n's visual workflow builder. This demonstrates RAD principles by using pre-built components and visual programming to rapidly create a functional monitoring system.
Step 4: Create the n8n Workflow
Access n8n interface (usually at http://localhost:5678) and create a new workflow with the following components:
4.1: Add Schedule Trigger
Add a Schedule Trigger node to call the API every 5 seconds:
- Search for "Schedule Trigger" in the node panel
- Set Trigger Interval to "Seconds"
- Set Seconds Between Triggers to 5
4.2: Add HTTP Request Node
Add an HTTP Request node to fetch temperature data:
- Set Method to GET
- Set URL to:
https://fakerapi.it/api/v2/custom?_quantity=1&sensor_voltage=longitude&sensor_current=longitude - Set Response Format to JSON
4.3: Add Code Node for Temperature Analysis
Add a Code node to analyze temperature readings and detect anomalies:
// Temperature analysis code for n8n Code node
const inputData = $input.all();
for (const item of inputData) {
const sensorData = item.json.data[0];
const sensor1_temp = sensorData.sensor_voltage;
const sensor2_temp = sensorData.sensor_current;
// Check if temperatures are within safe range (-100 to +100)
const sensor1_alert = sensor1_temp < -100 || sensor1_temp > 100;
const sensor2_alert = sensor2_temp < -100 || sensor2_temp > 100;
// Prepare output data
const outputItem = {
timestamp: new Date().toISOString(),
sensor1_temperature: sensor1_temp,
sensor2_temperature: sensor2_temp,
sensor1_status: sensor1_alert ? 'ALERT' : 'NORMAL',
sensor2_status: sensor2_alert ? 'ALERT' : 'NORMAL',
alert_required: sensor1_alert || sensor2_alert,
alert_message: ''
};
// Generate alert message if needed
if (outputItem.alert_required) {
let alertMsg = '🚨 TEMPERATURE ALERT 🚨\n';
if (sensor1_alert) {
alertMsg += `Sensor 1: ${sensor1_temp.toFixed(2)}°C (OUT OF RANGE)\n`;
}
if (sensor2_alert) {
alertMsg += `Sensor 2: ${sensor2_temp.toFixed(2)}°C (OUT OF RANGE)\n`;
}
alertMsg += `Safe Range: -100°C to +100°C\nTime: ${outputItem.timestamp}`;
outputItem.alert_message = alertMsg;
}
$return.push({json: outputItem});
}
4.4: Add IF Node for Conditional Logic
Add an IF node to check if an alert is required:
- Set Condition to "Boolean"
- Set Value 1 to
{{$json.alert_required}} - Set Operation to "Equal"
- Set Value 2 to
true
4.5: Add Telegram Node
Add a Telegram node connected to the "True" output of the IF node:
- Set Resource to "Message"
- Set Operation to "Send Text Message"
- Set Bot Token to your bot token from Step 3
- Set Chat ID to your chat ID from Step 3
- Set Text to
{{$json.alert_message}}
Step 5: Test and Deploy the Workflow
Test your workflow by manually executing it and then activate it for continuous monitoring:
- Click "Execute Workflow" to test manually
- Verify that data flows through all nodes correctly
- Check that you receive test messages in Telegram when alerts occur
- Click "Active" toggle to enable automatic execution
Testing Tip: Since the API generates random values, you may need to run the workflow multiple times to see alert conditions. You can temporarily modify the temperature thresholds in the code node for testing purposes.
Part C: Performance Evaluation (LO3)
Learning Outcome 3: Evaluate the performance of a RAD software solution to an engineering application.
In this section, you will critically evaluate your n8n workflow solution, identify its strengths and limitations, and propose improvements. This evaluation helps you understand the practical considerations of deploying RAD solutions in real industrial environments.
Step 6: System Evaluation and Analysis
Create a file called evaluation_report.md and provide detailed answers to the following questions based on your workflow implementation and testing:
Questions for Evaluation:
- Appraise Performance and Deficiencies: Technically evaluate the performance of your n8n workflow solution. Explain what happens when the external API is slow, returns errors, or becomes unavailable?
- Informed Judgement on Failure Points: Consider the broader system reliability from an engineering perspective. What would happen if the n8n service crashes, the server loses internet connectivity, or Telegram's API becomes unavailable? How would changes in the sensor API format (e.g., different field names or additional sensors) affect your workflow?
- Identify Areas for Improvement: Based on your evaluation, propose specific improvements to enhance the monitoring system.
Step 7: Document Your Workflow
Take screenshots of your complete n8n workflow showing:
- The complete workflow with all connected nodes
- Execution history showing successful runs
- Sample Telegram notifications received
- Configuration of at least two critical nodes (HTTP Request and Code nodes)
Submission
To complete this lab, please submit the following items:
- Your n8n workflow export file:
temperature_monitoring_workflow.json(Export from n8n: Settings > Export) - Screenshots of your workflow and execution results:
workflow_screenshots.pdf - Your evaluation and reflection report:
evaluation_report.md - A configuration file containing your setup details:
setup_config.txt(include API endpoint, bot token info - masked for security, and any special configuration notes)
Security Note: When submitting your work, ensure you mask or remove actual bot tokens and sensitive credentials. Include only the configuration structure and setup steps.