Skip to content

Instantly share code, notes, and snippets.

@nizhunt
Created May 7, 2025 16:57
Show Gist options
  • Save nizhunt/833931fae7f90d55e104df9e90bb059e to your computer and use it in GitHub Desktop.
Save nizhunt/833931fae7f90d55e104df9e90bb059e to your computer and use it in GitHub Desktop.
AI and the Future of Hiring - N8n Email Bot
{
"name": "AI x Hr",
"nodes": [
{
"parameters": {
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"filters": {}
},
"type": "n8n-nodes-base.gmailTrigger",
"typeVersion": 1.2,
"position": [
-200,
-120
],
"id": "9c9ae0d8-73a0-495b-a91c-639913778a11",
"name": "Gmail Trigger",
"credentials": {
"gmailOAuth2": {
"id": "ruE1R6KYihXPTq8K",
"name": "Gmail account 2"
}
}
},
{
"parameters": {
"operation": "get",
"messageId": "={{ $json.id }}"
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
-40,
-120
],
"id": "48eec427-de5b-468f-9704-8357b462cfb4",
"name": "Gmail",
"webhookId": "37f2bca5-fda6-40e2-86b8-36f356de957f",
"credentials": {
"gmailOAuth2": {
"id": "ruE1R6KYihXPTq8K",
"name": "Gmail account 2"
}
}
},
{
"parameters": {
"promptType": "define",
"text": "=From: {{ $json.From }} | Subject: {{ $json.Subject }} | Message: {{ $('Gmail Trigger').item.json.snippet }}\n",
"options": {
"systemMessage": "\nYou are an AI assistant that helps a recruiter manage their email inbox. Your task is to:\n\n1. Scan the recruiter's inbox and check each email's subject line:\n \n - If the subject contains `[Candidate]`, continue processing as described in steps 2–5 below.\n \n - If the subject does NOT contain `[Candidate]`, skip all further processing and go directly to step 5 (labeling).\n \n2. For each `[Candidate]` email, extract and analyze the content to determine the candidate’s stage. Classify the candidate into one of the following five stages:\n \n - New Application – Candidate is applying for the first time or expressing interest.\n \n - Screening – Resume review, screening calls, or assessments are in progress.\n \n - Interviewing – One or more interviews are scheduled or completed.\n \n - Offer Stage – An offer has been made, is under negotiation, or being considered.\n \n - Closed – Final outcome reached (offer accepted, declined, or candidate rejected).\n \n3. For each `[Candidate]` email, extract the following information:\n \n - Message Id – The unique identifier of the email message.\n \n - Name – Full name of the candidate.\n \n - Stage – One of the five stages listed above.\n \n - Message – A brief summary of the email content (e.g., “submitted resume”, “interview scheduled”, “rejected after final round”).\n \n4. Use the `updateSheet` tool to write this information into the Google Sheet using these columns:\n \n - `Message Id`\n \n - `Name`\n \n - `Stage`\n \n - `Message`\n\n5. Apply a Gmail label to every email using the `addLabel` tool:*\n \n - If the subject contains `[Candidate]`, apply: `{{ [\"Label_6991587419945484185\"] }}`\n \n - If the subject does **not** contain `[Candidate]`, apply: `{{ [\"Label_4428524629220688751\"] }}`\n \n"
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.7,
"position": [
120,
-120
],
"id": "06ba3937-27bb-474a-a6bb-1955305bcd09",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
100,
100
],
"id": "27d4e416-bbb1-41c3-b44f-394d8e8338bf",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "KNQgUGjt6UQGbuip",
"name": "OpenAi account 2"
}
}
},
{
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"__rl": true,
"value": "https://docs.google.com/spreadsheets/d/1LHFreaKTG3HzeAiGju-UzmgTlJDWlJ5qd-k_--XzO8M/edit?usp=sharing",
"mode": "url"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Sheet1",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1LHFreaKTG3HzeAiGju-UzmgTlJDWlJ5qd-k_--XzO8M/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Message Id": "={{ $json.threadId }}",
"Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Name', ``, 'string') }}",
"Job Role": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Job_Role', ``, 'string') }}",
"Stage ": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Stage_', ``, 'string') }}",
"Message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}"
},
"matchingColumns": [
"Message Id"
],
"schema": [
{
"id": "Message Id",
"displayName": "Message Id",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Name",
"displayName": "Name",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Job Role",
"displayName": "Job Role",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Stage ",
"displayName": "Stage ",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Message",
"displayName": "Message",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheetsTool",
"typeVersion": 4.5,
"position": [
280,
100
],
"id": "9528889c-bf18-4aad-af0d-66ec9440fb44",
"name": "updateSheet",
"credentials": {
"googleSheetsOAuth2Api": {
"id": "YYWxVLoK7TgAaEir",
"name": "Google Sheets account 2"
}
}
},
{
"parameters": {
"operation": "addLabels",
"messageId": "={{ $json.id }}",
"labelIds": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Label_Names_or_IDs', ``, 'string') }}"
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
420,
100
],
"id": "8b9fc215-c701-4f79-aeb2-060868867ae2",
"name": "addLabel",
"webhookId": "02682beb-6a8f-4ea9-b856-5269f92db57e",
"credentials": {
"gmailOAuth2": {
"id": "ruE1R6KYihXPTq8K",
"name": "Gmail account 2"
}
}
}
],
"pinData": {},
"connections": {
"Gmail Trigger": {
"main": [
[
{
"node": "Gmail",
"type": "main",
"index": 0
}
]
]
},
"Gmail": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"updateSheet": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"addLabel": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
},
"versionId": "5766584c-5296-46cf-984c-8bb8da43100b",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "b02c8f4248c85df2375624ca59459645c58460a14fdeb17d25033c7f0004c966"
},
"id": "l1opp4ENhjnbsxt7",
"tags": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment