Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

🤖 AI-Powered API QA Workflow

AI-powered API testing workflow built with n8n, JavaScript, OpenAI, and Postman.

The workflow automatically executes REST API tests, validates HTTP status codes and real response time, classifies failures, and uses AI to generate QA analysis only when a test fails.


⚙️ Workflow

AI-Powered API QA Workflow

Webhook
   ↓
Start Timer
   ↓
HTTP Request
   ↓
JavaScript Validation
   ↓
IF
 ├── FAIL → OpenAI Analysis → Edit Fields
 └── PASS → Edit Fields
                     ↓
            Respond to Webhook

✨ Key Features

  • Automated REST API testing
  • Expected vs actual HTTP status validation
  • Real API response-time measurement
  • Configurable maxResponseTime
  • Automatic PASS / FAIL detection
  • Separate statusPassed and responseTimePassed checks
  • Failure classification with failureReason
  • AI analysis triggered only for failed tests
  • Structured JSON QA reports
  • Postman webhook integration

⏱️ Response Time Validation

The workflow records the request start time before the API call:

requestStartedAt: Date.now()

and calculates the actual API response time after the request:

const responseTime = Date.now() - requestStartedAt;

The test passes only when both checks succeed:

const statusPassed = actualStatus === expectedStatus;
const responseTimePassed = responseTime <= maxResponseTime;

const passed = statusPassed && responseTimePassed;

🧪 Postman Test

Example request:

{
  "testName": "API response time test",
  "url": "https://jsonplaceholder.typicode.com/posts/1",
  "method": "GET",
  "expectedStatus": 200,
  "maxResponseTime": 2000
}

PASS example

{
  "expectedStatus": 200,
  "actualStatus": 200,
  "maxResponseTime": 2000,
  "responseTime": 81,
  "statusPassed": true,
  "responseTimePassed": true,
  "result": "PASS",
  "failureReason": "NONE"
}

FAIL example

{
  "expectedStatus": 200,
  "actualStatus": 200,
  "maxResponseTime": 1,
  "responseTime": 58,
  "statusPassed": true,
  "responseTimePassed": false,
  "result": "FAIL",
  "failureReason": "RESPONSE_TIME"
}

When a test fails, it is automatically routed to OpenAI for additional QA analysis and investigation recommendations.


🚨 Failure Types

The workflow can classify failures as:

NONE
STATUS_CODE
RESPONSE_TIME
STATUS_AND_RESPONSE_TIME

🛠️ Tech Stack

  • n8n
  • JavaScript
  • OpenAI
  • Postman
  • REST API
  • Webhooks
  • JSON

🎯 Project Highlights

This project demonstrates practical experience with:

  • QA automation
  • API testing
  • workflow automation
  • response-time validation
  • JavaScript validation logic
  • conditional AI execution
  • AI-assisted failure analysis
  • structured QA reporting

📁 Repository

README.md
workflow.json
n8n-workflow-scrin.png

The exported workflow.json can be imported into another n8n instance after configuring the required credentials.


👩‍💻 Portfolio Summary

Built an AI-powered API QA workflow that automates REST API validation, measures real response time, detects functional and performance failures, and uses OpenAI to generate actionable QA analysis only when failures occur.

About

AI-powered API testing workflow built with n8n for automated validation, failure detection, and AI-generated bug analysis.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors