{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "65d335f8-a299-4dda-878e-523d5db7f3a5",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {},
        "formTitle": "GST Insight ",
        "formFields": {
          "values": [
            {
              "fieldLabel": "GST/PAN No",
              "requiredField": true
            }
          ]
        },
        "formDescription": "GST Insight"
      },
      "typeVersion": 2.2
    },
    {
      "id": "0cdb7cf1-7871-47fa-9992-526fd53ac990",
      "name": "Google Docs",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        760,
        0
      ],
      "parameters": {
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{ $json.docContent }}",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "documentURL": "",
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "5a8d9986-1029-4592-9170-745e767ad0a9",
      "name": "Reformat",
      "type": "n8n-nodes-base.code",
      "position": [
        460,
        0
      ],
      "parameters": {
        "jsCode": "// Data from input (assuming it's in $input.first().json)\nconst data = $input.first().json;\n\n// Prepare the data to populate the Word document\nconst companyDetails = [\n  { label: \"Company Name\", value: data.company_name },\n  { label: \"GST Number\", value: data.gst_number },\n  { label: \"State\", value: data.state },\n  { label: \"GST Code\", value: data.gst_details.stjCd },\n  { label: \"GST Type\", value: data.gst_details.dty },\n  { label: \"GST Location\", value: data.gst_details.stj },\n  { label: \"GSTIN\", value: data.gst_details.gstin },\n  { label: \"Status\", value: data.sts },\n  { label: \"Trade Name\", value: data.tradeNam },\n  { label: \"Supplier Address\", value: `${data.gst_details.adadr[0].addr.bnm}, ${data.gst_details.adadr[0].addr.loc}, ${data.gst_details.adadr[0].addr.st}, ${data.gst_details.adadr[0].addr.pncd}` },\n  { label: \"Private Address\", value: `${data.gst_details.pradr.addr.bnm}, ${data.gst_details.pradr.addr.loc}, ${data.gst_details.pradr.addr.st}, ${data.gst_details.pradr.addr.pncd}` },\n  { label: \"GST Update Date\", value: data.gst_details.lstupdt },\n  { label: \"Company Type\", value: data.gst_details.ctb },\n  { label: \"GST Registration Date\", value: data.gst_details.rgdt },\n  { label: \"E-invoice Status\", value: data.gst_details.einvoiceStatus }\n];\n\n// Create plain text formatted content\nlet docContent = `Company GST Details\\n\\n`;\n\n// Add each detail as plain text\ncompanyDetails.forEach(detail => {\n  docContent += `${detail.label}: ${detail.value}\\n`;\n});\n\n// Return content to output\nreturn [\n  {\n    json: {\n      docContent: docContent\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "b40b3b18-b6c4-4a62-83bc-7235326a2fcb",
      "name": "GST Insights",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        220,
        0
      ],
      "parameters": {
        "url": "https://gst-insights.p.rapidapi.com/index.php",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "pan",
              "value": "={{ $json[\"GST/PAN No\"] }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "gst-insights.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "your key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "bb87bba0-52bc-4f5e-83d4-ef5bd0be6eac",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -780,
        -300
      ],
      "parameters": {
        "width": 540,
        "height": 740,
        "content": "## Flow Overview: **GST Data Integration and Document Update**\n\n### This flow automates the process of submitting a GST/PAN form, fetching GST details, reformatting the data, and updating a Google Document with the relevant GST information.\n\n---\n\n### **Node 1: On form submission (FormTrigger)**  \n- **Explanation**: Triggers the workflow when a GST/PAN form is submitted with required details.\n\n### **Node 2: GST Insights (API Request)**  \n- **Explanation**: Sends the GST/PAN number to an external API and retrieves detailed GST data.\n\n### **Node 3: Reformat (Code Node)**  \n- **Explanation**: Formats the fetched GST data into a readable plain-text format for document insertion.\n\n### **Node 4: Google Docs (Update Document)**  \n- **Explanation**: Updates a specific Google Document with the formatted GST details for record-keeping.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "45989229-75e9-4868-87d1-d1f3ff7b2d80",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -100,
        -180
      ],
      "parameters": {
        "height": 340,
        "content": "This node triggers the workflow when the user submits the GST/PAN form.  \n- It collects the required \"GST/PAN No\" and starts the automation process."
      },
      "typeVersion": 1
    },
    {
      "id": "5d290097-7b44-4caf-a9e9-b1d2ccb95e4a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -180
      ],
      "parameters": {
        "height": 340,
        "content": "Sends a POST request to the GST Insights API to retrieve GST details based on the submitted PAN.  \n- The API response includes company details such as GST number, registration date, and e-invoice status."
      },
      "typeVersion": 1
    },
    {
      "id": "9887c8a9-5b14-4868-bd68-a3d0748814a0",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        -180
      ],
      "parameters": {
        "height": 340,
        "content": "Reformats the data fetched from the API into a plain-text format for document insertion.  \n- The node extracts and structures key company information like GST number, company name, and trade name."
      },
      "typeVersion": 1
    },
    {
      "id": "4cc29dcf-a0bc-47d8-89bd-638d1ac39a41",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        -180
      ],
      "parameters": {
        "height": 340,
        "content": "Reformats the data fetched from the API into a plain-text format for document insertion.  \n- The node extracts and structures key company information like GST number, company name, and trade name."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Reformat": {
      "main": [
        [
          {
            "node": "Google Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GST Insights": {
      "main": [
        [
          {
            "node": "Reformat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "GST Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}