{ "name": "Outlevo: Daily credit balance to Microsoft Teams", "nodes": [ { "id": "5f10236a-2896-424c-81f1-fa67fd9da28f", "name": "How to set it up", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -40, -364 ], "parameters": { "content": "## How to set it up\n\n**Credentials** (n8n asks for each on first open):\n- **Outlevo API key**: a Header Auth credential, name `Authorization`, value `Bearer olv_live_…` (Settings → API keys in Outlevo).\n- **Microsoft Teams**: connect your Microsoft Teams account.\n\n**API key scopes**: `usage:read`.\n\n**Pick in the node**:\n- **Post to Teams**: the team and the channel\n\nThen switch the workflow to **Active**.", "height": 304, "width": 620 } }, { "id": "b67ceb24-3f68-427c-a266-f77348b133a9", "name": "Every morning", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [ 0, 0 ], "parameters": { "rule": { "interval": [ { "field": "days", "daysInterval": 1, "triggerAtHour": 8 } ] } } }, { "id": "2b4797ab-b5f1-4565-9c94-9d45cde2257b", "name": "Get the balance", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 240, 0 ], "parameters": { "method": "GET", "url": "=https://api.outlevo.com/v1/usage", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "options": {} }, "credentials": { "httpHeaderAuth": { "id": "", "name": "Outlevo API key (Authorization: Bearer olv_live_…)" } } }, { "id": "edd2a917-1d4d-4033-98f4-0c4c472a8199", "name": "Get the budget", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 480, 0 ], "parameters": { "method": "GET", "url": "=https://api.outlevo.com/v1/usage/budget", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "options": {} }, "credentials": { "httpHeaderAuth": { "id": "", "name": "Outlevo API key (Authorization: Bearer olv_live_…)" } } }, { "id": "1991e4ef-5288-42ea-8360-33d234a88f8a", "name": "Write the digest", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 720, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "const u = $('Get the balance').first().json;\nconst b = $input.first().json;\nconst m = u.monthly || {};\nconst lines = [\n `Available now: ${u.available ?? 0} credits`,\n `This month's grant: ${m.remaining ?? 0} of ${m.granted ?? 0} left`,\n `Top-ups: ${(u.topups || {}).remaining ?? 0} left`,\n `Spent today: ${b.spent_today ?? 0}${b.daily_credit_budget ? ` of a ${b.daily_credit_budget} daily budget` : ''}`,\n `Spent this month: ${b.spent_this_month ?? 0}${b.monthly_credit_budget ? ` of a ${b.monthly_credit_budget} monthly budget` : ''}`,\n];\nreturn [{ json: { text: `💳 Outlevo credits:\\n${lines.map((l) => `• ${l}`).join('\\n')}\\nhttps://app.outlevo.com/billing`, subject: `Outlevo: ${u.available ?? 0} credits available` } }];\n" } }, { "id": "4bbd101f-ff38-4821-a7c5-fdbd5748c829", "name": "Post to Teams", "type": "n8n-nodes-base.microsoftTeams", "typeVersion": 2, "position": [ 960, 0 ], "parameters": { "resource": "channelMessage", "operation": "create", "teamId": { "__rl": true, "mode": "list", "value": "" }, "channelId": { "__rl": true, "mode": "list", "value": "" }, "contentType": "html", "message": "={{ $json.text.split('&').join('&').split('<').join('<').split('>').join('>').split('\\n').join('
') }}", "options": { "includeLinkToWorkflow": false } }, "credentials": { "microsoftTeamsOAuth2Api": { "id": "", "name": "Microsoft Teams" } } } ], "connections": { "Every morning": { "main": [ [ { "node": "Get the balance", "type": "main", "index": 0 } ] ] }, "Get the balance": { "main": [ [ { "node": "Get the budget", "type": "main", "index": 0 } ] ] }, "Get the budget": { "main": [ [ { "node": "Write the digest", "type": "main", "index": 0 } ] ] }, "Write the digest": { "main": [ [ { "node": "Post to Teams", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" }, "pinData": {}, "meta": { "templateCredsSetupCompleted": false } }