{
    "name": "Specialty Chemicals Compliance & Risk Engine",
    "flow": [
        {
            "id": 1,
            "module": "builtin:BasicRouter",
            "version": 1,
            "mapper": null,
            "metadata": {
                "designer": {
                    "x": 0,
                    "y": 150
                }
            },
            "routes": [
                {
                    "flow": [
                        {
                            "id": 10,
                            "module": "google-sheets:makeAPICall",
                            "version": 2,
                            "parameters": {
                                "__IMTCONN__": 9571104
                            },
                            "mapper": {
                                "url": "/spreadsheets/1CiJvOVHl9tSriHe5NbEek8MP25THsqigTv0AmjjuHHM/values/Certifications!A2:F50",
                                "method": "GET"
                            },
                            "metadata": {
                                "designer": {
                                    "x": 300,
                                    "y": 0
                                }
                            }
                        },
                        {
                            "id": 11,
                            "module": "ai-tools:Ask",
                            "version": 2,
                            "parameters": {
                                "model": "small",
                                "makeConnectionId": 9570524
                            },
                            "mapper": {
                                "input": "Today's exact date is {{formatDate(now; \"YYYY-MM-DD\")}}.\n\nBelow is a raw Google Sheets API response. Its \"values\" field is an array of arrays — there is NO header row, every element is one real certification record. Columns by position: 0=Certification Name, 1=Product/Entity, 2=Region, 3=Expiry Date (YYYY-MM-DD), 4=Owner, 5=Status.\n\nRaw data:\n{{10.body}}\n\nGo through every single row without exception. Compute Days Left = days between today and the row's Expiry Date. A row qualifies if Days Left is between 0 and 60 inclusive AND Status is not 'Renewed'.\n\nIf ZERO rows qualify, respond with exactly this plain text and nothing else: No certifications require action at this time.\n\nIf ONE OR MORE rows qualify, respond with ONLY an HTML fragment (no markdown, no code fences, no <html>/<body> tags, inline CSS only), built in this exact order:\n1. First, silently build the list of HTML cards, one per qualifying row (see card format below).\n2. Then count how many cards you actually built.\n3. Then write your summary sentence using that exact count: '<p><b>N certification(s)</b> require renewal action in the next 60 days.</p>' where N is the number of cards from step 2 — this number MUST equal the number of cards that follow it. Recount before finalizing.\n4. Then output all the cards after the summary sentence.\n\nCard format (one div per qualifying row): <div style=\"border:1px solid #ddd;border-radius:6px;padding:12px;margin-bottom:12px\"> containing an h3 with the certification name, a badge span with inline style (background:#c62828 if daysLeft<15, #ef6c00 if 15-30, #f9a825 if 31-60; color:white; border-radius:4px; padding:2px 8px; font-size:12px) showing 'X days left', then a small text line with Product/Entity, Region, Expiry Date, Owner (real values only), then bold text 'Renewal Checklist' followed by an ordered list with 2-3 concrete numbered steps specific to that certification type.\n\nUse only real values from the rows — never brackets or placeholders. Never skip a qualifying row. Before sending your final answer, verify: does the number in your summary sentence exactly equal the number of card divs you wrote? If not, fix it."
                            },
                            "metadata": {
                                "designer": {
                                    "x": 600,
                                    "y": 0
                                }
                            }
                        },
                        {
                            "id": 12,
                            "module": "google-sheets:addRow",
                            "version": 2,
                            "parameters": {
                                "mode": "map",
                                "__IMTCONN__": 9571104,
                                "tableFirstRow": "A1:Z1",
                                "insertDataOption": "INSERT_ROWS",
                                "valueInputOption": "USER_ENTERED",
                                "insertUnformatted": false
                            },
                            "mapper": {
                                "values": {
                                    "0": "{{formatDate(now; \"YYYY-MM-DD\")}}",
                                    "1": "{{11.answer}}"
                                },
                                "sheetId": "Compliance Alerts",
                                "spreadsheetId": "1CiJvOVHl9tSriHe5NbEek8MP25THsqigTv0AmjjuHHM"
                            },
                            "metadata": {
                                "designer": {
                                    "x": 900,
                                    "y": 0
                                }
                            }
                        },
                        {
                            "id": 13,
                            "module": "google-email:sendAnEmail",
                            "version": 4,
                            "parameters": {
                                "to": [
                                    "prateek.kabra2027@mastersunion.org"
                                ],
                                "__IMTCONN__": 9571473
                            },
                            "mapper": {
                                "content": "<div style=\"font-family:Arial,sans-serif;max-width:640px;margin:auto\"><h2 style=\"color:#b71c1c;border-bottom:2px solid #b71c1c;padding-bottom:6px\">⚠️ Certification Renewal Alert</h2>{{11.answer}}<p style=\"font-size:12px;color:#888;margin-top:20px\">Automated daily briefing — Specialty Chemicals Compliance & Risk Engine</p></div>",
                                "subject": "⚠️ Compliance Alert: Certification Renewal Status",
                                "bodyType": "rawHtml"
                            },
                            "metadata": {
                                "designer": {
                                    "x": 1200,
                                    "y": 0
                                }
                            }
                        }
                    ]
                },
                {
                    "flow": [
                        {
                            "id": 21,
                            "module": "google-sheets:makeAPICall",
                            "version": 2,
                            "parameters": {
                                "__IMTCONN__": 9571104
                            },
                            "mapper": {
                                "url": "/spreadsheets/1CiJvOVHl9tSriHe5NbEek8MP25THsqigTv0AmjjuHHM/values/Products!A1:C50",
                                "method": "GET"
                            },
                            "metadata": {
                                "designer": {
                                    "x": 300,
                                    "y": 300
                                }
                            }
                        },
                        {
                            "id": 20,
                            "module": "rss:ActionReadArticles",
                            "version": 4,
                            "parameters": {},
                            "mapper": {
                                "url": "https://news.google.com/rss/search?q=EPA+OR+REACH+chemical+regulation+restricted+substance&hl=en-US&gl=US&ceid=US:en",
                                "gzip": true,
                                "maxResults": 3
                            },
                            "metadata": {
                                "designer": {
                                    "x": 600,
                                    "y": 300
                                }
                            }
                        },
                        {
                            "id": 25,
                            "module": "builtin:BasicAggregator",
                            "version": 1,
                            "parameters": {
                                "feeder": 20
                            },
                            "mapper": {
                                "array": {
                                    "url": "{{20.url}}",
                                    "title": "{{20.title}}",
                                    "description": "{{20.description}}"
                                }
                            },
                            "metadata": {
                                "designer": {
                                    "x": 900,
                                    "y": 300
                                }
                            }
                        },
                        {
                            "id": 22,
                            "module": "ai-tools:Ask",
                            "version": 2,
                            "parameters": {
                                "model": "small",
                                "makeConnectionId": 9570524
                            },
                            "mapper": {
                                "input": "You are a specialty chemicals regulatory affairs analyst writing a short internal HTML briefing email.\n\nOur internal product/CAS inventory (raw JSON, \"values\" array, first row is header: Product Name, CAS Numbers, Category):\n{{21.body}}\n\nHere are today's regulatory/industry news items (array of {title, url, description}):\n{{25.array}}\n\nTask: Write ONE combined HTML briefing (just the inner content, no <html>/<body>/<head> tags) covering ALL the articles above. Use inline CSS only (no <style> blocks, no external classes). Structure:\n1. A top summary line as a full sentence stating how many articles were reviewed and a one-sentence overall trend read (e.g. rising/steady/declining regulatory scrutiny), with a small inline-styled horizontal bar (a <div> with background color and width percentage reflecting overall risk level: red/high >66%, orange/medium 33-66%, green/low <33%).\n2. One card per article: the title as a clickable link (use the real url), a colored pill/badge span for Risk Level (High=red background, Medium=orange, Low=green, all with white text, small border-radius), a short Key Insight (1-2 sentences, real substantive analysis — always non-generic, always find something genuinely useful even if there is no direct product match), Matched Products if any relate to our real inventory above (or 'No direct match'), and a Recommended Action line.\n3. Keep total output concise — this is an executive briefing, not a report. Use divs with margin-bottom for spacing between cards, light border and padding on each card (border:1px solid #ddd; border-radius:6px; padding:12px).\nNever use placeholder text — use the real article titles, urls, and real product names from the inventory. Output ONLY the HTML fragment, no markdown, no commentary, no code fences."
                            },
                            "metadata": {
                                "designer": {
                                    "x": 1200,
                                    "y": 300
                                }
                            }
                        },
                        {
                            "id": 23,
                            "module": "google-sheets:addRow",
                            "version": 2,
                            "parameters": {
                                "mode": "map",
                                "__IMTCONN__": 9571104,
                                "tableFirstRow": "A1:Z1",
                                "insertDataOption": "INSERT_ROWS",
                                "valueInputOption": "USER_ENTERED",
                                "insertUnformatted": false
                            },
                            "mapper": {
                                "values": {
                                    "0": "{{formatDate(now; \"YYYY-MM-DD\")}}",
                                    "1": "Daily Regulatory Digest ({{length(25.array)}} articles)",
                                    "2": "See email digest",
                                    "3": "{{22.answer}}"
                                },
                                "sheetId": "Regulatory Alerts",
                                "spreadsheetId": "1CiJvOVHl9tSriHe5NbEek8MP25THsqigTv0AmjjuHHM"
                            },
                            "metadata": {
                                "designer": {
                                    "x": 1500,
                                    "y": 300
                                }
                            }
                        },
                        {
                            "id": 24,
                            "module": "google-email:sendAnEmail",
                            "version": 4,
                            "parameters": {
                                "to": [
                                    "prateek.kabra2027@mastersunion.org"
                                ],
                                "__IMTCONN__": 9571473
                            },
                            "mapper": {
                                "content": "<div style=\"font-family:Arial,sans-serif;max-width:640px;margin:auto\"><h2 style=\"color:#1565c0;border-bottom:2px solid #1565c0;padding-bottom:6px\">📰 Specialty Chemicals Regulatory Digest</h2>{{22.answer}}<p style=\"font-size:12px;color:#888;margin-top:20px\">Automated daily briefing — Specialty Chemicals Compliance & Risk Engine</p></div>",
                                "subject": "📰 Regulatory Digest: {{length(25.array)}} updates today",
                                "bodyType": "rawHtml"
                            },
                            "metadata": {
                                "designer": {
                                    "x": 1800,
                                    "y": 300
                                }
                            }
                        }
                    ]
                }
            ]
        }
    ],
    "metadata": {
        "instant": false,
        "version": 1,
        "scenario": {
            "roundtrips": 1,
            "maxErrors": 3,
            "autoCommit": true,
            "autoCommitTriggerLast": true,
            "sequential": false,
            "slots": null,
            "confidential": false,
            "dataloss": false,
            "dlq": false,
            "freshVariables": false
        },
        "designer": {
            "orphans": []
        },
        "zone": "eu1.make.com",
        "notes": []
    }
}