Détection automatique de factures AI pour Gmail et notification Slack
Ceci est uncontenant 12 nœuds.Utilise principalement des nœuds comme If, Gmail, Slack, Agent, ScheduleTrigger. Extraire des données de factures à partir de Gmail avec GPT-4o et envoyer des notifications Slack
- •Compte Google et informations d'identification Gmail API
- •Token Bot Slack ou URL Webhook
- •Clé API OpenAI
Catégorie
{
"name": "AI Auto-Detect Invoices from Gmail and Notify on Slack",
"nodes": [
{
"id": "df47f544-18a9-4eea-a02f-6e8618bdc903",
"name": "Déclencheur programmé",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-1488,
-16
],
"parameters": {
"rule": {
"interval": [
{
"field": "hours"
}
]
}
},
"typeVersion": 1.2
},
{
"id": "fb69e703-7747-4862-8208-0d0803f5ce8f",
"name": "Agent IA",
"type": "@n8n/n8n-nodes-langchain.agent",
"onError": "continueRegularOutput",
"position": [
-1040,
-16
],
"parameters": {
"text": "=You are an intelligent assistant that reads emails and determines whether the message is related to an invoice or a payment notification.\n\nYour tasks:\n1. Determine if the email is invoice-related.\n2. If yes, extract:\n - Due date (in YYYY-MM-DD format, or null)\n - Amount due (as a number, no currency symbols)\n\nAlways include these metadata values:\nId: {{ $json.id }}\nthreadId: {{ $json.threadId }}\nbody: {{ $json.text }}\nsubject: {{ $json.subject }}\nsender: {{ $json.from.value[0].name }}\n\nReturn only a valid JSON object in the format below:\n\n```json\n{\n \"is_invoice\": true or false,\n \"due_date\": \"YYYY-MM-DD\" or null,\n \"amount_due\": number or null,\n \"email_id\": \"string\",\n \"thread_id\": \"string\",\n \"sender\": \"string\",\n \"subject\": \"string\"\n}\n\n\n",
"options": {},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2.1
},
{
"id": "ff1adb6a-43d6-4b36-9c91-0046b0146565",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-1024,
208
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "gpt-4o"
},
"options": {}
},
"typeVersion": 1.2
},
{
"id": "acc58349-b51f-4623-9a23-f740791483fb",
"name": "Analyseur de sortie structurée",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
-896,
208
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"is_invoice\": {\n \"type\": \"boolean\"\n },\n \"due_date\": {\n \"type\": [\"string\", \"null\"],\n \"format\": \"date\"\n },\n \"amount_due\": {\n \"type\": [\"number\", \"null\"]\n },\n \"email_id\": {\n \"type\": \"string\"\n },\n \"thread_id\": {\n \"type\": \"string\"\n },\n \"sender\": {\n \"type\": \"string\"\n },\n \"subject\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"is_invoice\",\n \"due_date\",\n \"amount_due\",\n \"email_id\",\n \"thread_id\",\n \"sender\",\n \"subject\"\n ]\n}"
},
"typeVersion": 1.3
},
{
"id": "436dccba-2b62-4ee9-b2c3-0581bc836ed7",
"name": "Aucune opération, ne rien faire",
"type": "n8n-nodes-base.noOp",
"position": [
-464,
80
],
"parameters": {},
"typeVersion": 1
},
{
"id": "4c1eb726-1666-4f5c-b4e0-8f938f3ef791",
"name": "Note adhésive2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1552,
208
],
"parameters": {
"width": 304,
"height": 224,
"content": "### ⚠️ Setup Required \n- Connect your Gmail account using OAuth2 \n- Connect your Slack account using OAuth 2\n- Add your OpenAI API Key under **API Credentials** "
},
"typeVersion": 1
},
{
"id": "17c6acfe-6074-43f9-af78-8a2f7104df5b",
"name": "Obtenir les emails non lus",
"type": "n8n-nodes-base.gmail",
"position": [
-1264,
-16
],
"webhookId": "4259da3e-a2e2-41ea-aaac-50d8bf8a4bb7",
"parameters": {
"simple": false,
"filters": {
"readStatus": "unread"
},
"options": {},
"operation": "getAll"
},
"typeVersion": 2.1
},
{
"id": "51725993-99b5-4d9e-a562-4e762ca6a0a2",
"name": "Vérifier si l'email est une facture",
"type": "n8n-nodes-base.if",
"position": [
-688,
-16
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "dc8158a0-29aa-4c7f-9de3-994a5d827331",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.output.is_invoice }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "ec14d8de-cfab-4b53-a3b5-9aae1c3b808d",
"name": "Note adhésive1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1600,
-128
],
"parameters": {
"color": 5,
"width": 320,
"height": 272,
"content": "### 💡 Schedule Trigger \nThis runs every hour. \nYou can change the interval here depending on how often you want Gmail to be checked."
},
"typeVersion": 1
},
{
"id": "3f7e75ec-5a03-4664-b1ff-91f57bee2d9d",
"name": "Note adhésive",
"type": "n8n-nodes-base.stickyNote",
"position": [
-528,
-336
],
"parameters": {
"color": 5,
"width": 272,
"height": 400,
"content": "### 💡 Customize Notification Format \nYou can change the title in this node. For example: `Pay invoice from {{sender}} by {{due_date}}` \nInclude more invoice details in the notes field if needed.\n"
},
"typeVersion": 1
},
{
"id": "db70ae0c-794b-452e-b8cd-26574ff006a2",
"name": "Notifier l'utilisateur Slack",
"type": "n8n-nodes-base.slack",
"position": [
-464,
-112
],
"webhookId": "a155a0c9-d84e-4937-b215-9d2920c45616",
"parameters": {
"text": "=Invoice from {{ $json.output.sender }} – ${{ $json.output.amount_due }} due {{ $json.output.due_date }}",
"user": {
"__rl": true,
"mode": "username",
"value": ""
},
"select": "user",
"otherOptions": {},
"authentication": "oAuth2"
},
"typeVersion": 2.3
},
{
"id": "d9bc11f7-edb5-4521-9702-725c8fa736fc",
"name": "Note adhésive3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1120,
-256
],
"parameters": {
"color": 5,
"width": 400,
"height": 640,
"content": "### 🤖 AI Agent\n\n• This node uses an AI prompt to detect whether an email is invoice-related.\n• You can customize the prompt to detect other types of emails (e.g., receipts, contracts).\n"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"fb69e703-7747-4862-8208-0d0803f5ce8f": {
"main": [
[
{
"node": "51725993-99b5-4d9e-a562-4e762ca6a0a2",
"type": "main",
"index": 0
}
]
]
},
"df47f544-18a9-4eea-a02f-6e8618bdc903": {
"main": [
[
{
"node": "17c6acfe-6074-43f9-af78-8a2f7104df5b",
"type": "main",
"index": 0
}
]
]
},
"17c6acfe-6074-43f9-af78-8a2f7104df5b": {
"main": [
[
{
"node": "fb69e703-7747-4862-8208-0d0803f5ce8f",
"type": "main",
"index": 0
}
]
]
},
"ff1adb6a-43d6-4b36-9c91-0046b0146565": {
"ai_languageModel": [
[
{
"node": "fb69e703-7747-4862-8208-0d0803f5ce8f",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"acc58349-b51f-4623-9a23-f740791483fb": {
"ai_outputParser": [
[
{
"node": "fb69e703-7747-4862-8208-0d0803f5ce8f",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"51725993-99b5-4d9e-a562-4e762ca6a0a2": {
"main": [
[
{
"node": "db70ae0c-794b-452e-b8cd-26574ff006a2",
"type": "main",
"index": 0
}
],
[
{
"node": "436dccba-2b62-4ee9-b2c3-0581bc836ed7",
"type": "main",
"index": 0
}
]
]
}
}
}Comment utiliser ce workflow ?
Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.
Dans quelles scénarios ce workflow est-il adapté ?
Intermédiaire
Est-ce payant ?
Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.
Workflows recommandés
Matt Chong | n8n Creator
@mattxchongAutomation nerd fueled by good coffee, deep curiosity, and clean flows.
Partager ce workflow