{
  "id": "SXeEmagCT3KDLCII",
  "name": "Quotation Generator PDF",
  "tags": [],
  "nodes": [
    {
      "id": "form-trigger",
      "name": "Quotation Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        304
      ],
      "parameters": {
        "options": {},
        "formTitle": "Quotation Request",
        "formFields": {
          "values": [
            {
              "fieldType": "string",
              "fieldLabel": "Client Name",
              "placeholder": "John Smith",
              "requiredField": true
            },
            {
              "fieldType": "string",
              "fieldLabel": "Client Email",
              "placeholder": "user@example.com",
              "requiredField": true
            },
            {
              "fieldType": "string",
              "fieldLabel": "Company Name",
              "placeholder": "Acme Corp",
              "requiredField": true
            },
            {
              "fieldType": "string",
              "fieldLabel": "Service",
              "placeholder": "e.g. CRM Automation, Lead Pipeline, AI Chatbot",
              "requiredField": true
            },
            {
              "fieldLabel": "Service Description",
              "placeholder": "Describe the scope of work and deliverables",
              "requiredField": true
            },
            {
              "fieldType": "string",
              "fieldLabel": "Price",
              "placeholder": "e.g. $2,500",
              "requiredField": true
            },
            {
              "fieldType": "string",
              "fieldLabel": "Valid Until",
              "placeholder": "e.g. April 30, 2026",
              "requiredField": true
            },
            {
              "fieldLabel": "Notes",
              "placeholder": "Any additional terms or notes"
            }
          ]
        },
        "responseMode": "lastNode",
        "formDescription": "Fill in the details below to generate a personalized quotation."
      },
      "typeVersion": 2.2
    },
    {
      "id": "openai-personalize",
      "name": "OpenAI Personalize",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        240,
        304
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {
          "temperature": 0.7
        },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a professional business proposal writer for Baraco AI, an automation agency specializing in n8n workflows and AI integration."
            },
            {
              "content": "=Write a personalized quotation introduction paragraph and a brief scope of work summary for this client.\n\nClient: {{ $json['Client Name'] }}\nCompany: {{ $json['Company Name'] }}\nService: {{ $json['Service'] }}\nDescription: {{ $json['Service Description'] }}\nNotes: {{ $json['Notes'] }}\n\nRespond ONLY with valid JSON:\n{\"intro\": \"<2-3 sentence personalized intro addressing the client by name, referencing their company and needs>\", \"scope_summary\": \"<3-5 bullet points summarizing deliverables, each on a new line starting with a dash>\"}"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "copy-template",
      "name": "Copy Template",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        576,
        304
      ],
      "parameters": {
        "name": "=Quotation - {{ $('Quotation Form').item.json['Company Name'] }} - {{ $('Quotation Form').item.json['Service'] }}",
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "REPLACE_WITH_TEMPLATE_DOC_ID"
        },
        "options": {},
        "operation": "copy"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "replace-variables",
      "name": "Replace Variables",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        816,
        304
      ],
      "parameters": {
        "actionsUi": {
          "actionFields": [
            {
              "text": "{{client_name}}",
              "action": "replaceAll",
              "replaceText": "={{ $('Quotation Form').item.json['Client Name'] }}"
            },
            {
              "text": "{{company_name}}",
              "action": "replaceAll",
              "replaceText": "={{ $('Quotation Form').item.json['Company Name'] }}"
            },
            {
              "text": "{{client_email}}",
              "action": "replaceAll",
              "replaceText": "={{ $('Quotation Form').item.json['Client Email'] }}"
            },
            {
              "text": "{{service}}",
              "action": "replaceAll",
              "replaceText": "={{ $('Quotation Form').item.json['Service'] }}"
            },
            {
              "text": "{{price}}",
              "action": "replaceAll",
              "replaceText": "={{ $('Quotation Form').item.json['Price'] }}"
            },
            {
              "text": "{{valid_until}}",
              "action": "replaceAll",
              "replaceText": "={{ $('Quotation Form').item.json['Valid Until'] }}"
            },
            {
              "text": "{{notes}}",
              "action": "replaceAll",
              "replaceText": "={{ $('Quotation Form').item.json['Notes'] }}"
            },
            {
              "text": "{{intro}}",
              "action": "replaceAll",
              "replaceText": "={{ $('OpenAI Personalize').item.json.message.content.intro }}"
            },
            {
              "text": "{{scope_summary}}",
              "action": "replaceAll",
              "replaceText": "={{ $('OpenAI Personalize').item.json.message.content.scope_summary }}"
            }
          ]
        },
        "operation": "update"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "export-pdf",
      "name": "Export as PDF",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1072,
        304
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Copy Template').item.json.id }}"
        },
        "options": {
          "googleFileConversion": {
            "conversion": {
              "docsToFormat": "application/pdf"
            }
          }
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "send-email",
      "name": "Send Quotation Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1328,
        304
      ],
      "parameters": {
        "sendTo": "={{ $('Quotation Form').item.json['Client Email'] }}",
        "message": "=Hi {{ $('Quotation Form').item.json['Client Name'] }},\n\n{{ $('OpenAI Personalize').item.json.message.content.intro }}\n\nPlease find the attached quotation for your review.\n\nScope of Work:\n{{ $('OpenAI Personalize').item.json.message.content.scope_summary }}\n\nTotal: {{ $('Quotation Form').item.json['Price'] }}\nValid Until: {{ $('Quotation Form').item.json['Valid Until'] }}\n\nLooking forward to working with you.\n\nBest regards,\nBaraco AI",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {}
            ]
          }
        },
        "subject": "=Quotation from Baraco AI - {{ $('Quotation Form').item.json['Service'] }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "sticky-overview",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        -96
      ],
      "parameters": {
        "color": 4,
        "width": 560,
        "height": 744,
        "content": "## Quotation Generator PDF\n\nGenerates personalized quotations from a form submission, creates a branded PDF, and emails it to the client.\n\n### Flow\nForm > OpenAI Personalize > Copy Template > Replace Variables > Export PDF > Send Email\n\n### How It Works\n1. Client fills out the quotation form (name, email, company, service, price, etc.)\n2. OpenAI generates a personalized intro paragraph and scope summary\n3. Copies the Google Docs template to a new document\n4. Replaces all {{variables}} in the copied doc with form data + AI content\n5. Exports the document as PDF\n6. Sends the PDF as an email attachment via Gmail\n\n### Setup Required\n1. Create a Google Docs template with these variables:\n   {{client_name}}, {{company_name}}, {{client_email}}, {{service}}, {{price}}, {{valid_until}}, {{notes}}, {{intro}}, {{scope_summary}}\n2. Copy the template Document ID and paste it in the Copy Template node\n3. Configure Google Docs OAuth credential in Replace Variables node\n4. Configure Gmail OAuth credential in Send Quotation Email node\n\n### Credentials Required\n- OpenAI API key\n- Google Drive OAuth\n- Google Docs OAuth\n- Gmail OAuth"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "1b84c542-71c8-485e-8c6b-00d845a7207a",
  "connections": {
    "Copy Template": {
      "main": [
        [
          {
            "node": "Replace Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Export as PDF": {
      "main": [
        [
          {
            "node": "Send Quotation Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Quotation Form": {
      "main": [
        [
          {
            "node": "OpenAI Personalize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replace Variables": {
      "main": [
        [
          {
            "node": "Export as PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Personalize": {
      "main": [
        [
          {
            "node": "Copy Template",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}