{
  "schema_version": "1.0.0",
  "id": "signed-contract-to-drive",
  "title": "File a signed DocuSign contract in Drive and the log",
  "category": "invoices-docs",
  "difficulty": "beginner",
  "featured": false,
  "description": "When an envelope is completed, save the signed PDF to a Drive folder, add a row to the contracts log, and tell the account owner.",
  "tags": [
    "contracts",
    "docusign",
    "google-drive",
    "documents"
  ],
  "apps": [
    "DocuSign",
    "Google Drive",
    "Google Sheets",
    "Slack"
  ],
  "plan": {
    "minimum": "Professional",
    "reasons": [
      "multi-step Zap: 3 steps after the trigger"
    ]
  },
  "tasks": {
    "typical": 3,
    "max": 3
  },
  "trigger": {
    "app": "DocuSign",
    "event": "Envelope Sent or Completed",
    "kind": "polling",
    "title": "Envelope completed",
    "why": "Watches for envelopes that reach Completed, meaning every signer has signed.",
    "config": {
      "Account": "YOUR_DOCUSIGN_ACCOUNT",
      "Status": "Completed"
    },
    "outputs": [
      "envelope_id",
      "subject",
      "status",
      "completed_at",
      "sender_email",
      "recipient_names",
      "recipient_emails",
      "document_url"
    ],
    "sample": "sample-trigger.json"
  },
  "steps": [
    {
      "key": "save",
      "kind": "action",
      "app": "Google Drive",
      "event": "Upload File",
      "title": "Save the signed PDF",
      "why": "Uploads the combined signed document into one contracts folder with a predictable name.",
      "fields": {
        "Drive": "My Google Drive",
        "Folder": "Contracts/Signed",
        "File": "{{trigger.document_url}}",
        "File Name": "{{trigger.completed_at}} - {{trigger.subject}}",
        "Convert To Document?": "No"
      },
      "outputs": [
        "id",
        "alternate_link"
      ]
    },
    {
      "key": "log",
      "kind": "action",
      "app": "Google Sheets",
      "event": "Create Spreadsheet Row",
      "title": "Add it to the contracts log",
      "why": "The log links the Drive copy, so the sheet is the one place to look.",
      "fields": {
        "Drive": "My Google Drive",
        "Spreadsheet": "Contracts",
        "Worksheet": "Signed",
        "Columns": {
          "completed_at": "{{trigger.completed_at}}",
          "subject": "{{trigger.subject}}",
          "signers": "{{trigger.recipient_names}}",
          "signer_emails": "{{trigger.recipient_emails}}",
          "envelope_id": "{{trigger.envelope_id}}",
          "drive_link": "{{save.alternate_link}}"
        }
      },
      "outputs": [
        "id",
        "row_number"
      ]
    },
    {
      "key": "tell",
      "kind": "action",
      "app": "Slack",
      "event": "Send Channel Message",
      "title": "Tell the team",
      "why": "Lets the account owner start onboarding without checking DocuSign.",
      "fields": {
        "Channel": "#new-clients",
        "Message Text": ":white_check_mark: Signed: {{trigger.subject}} by {{trigger.recipient_names}}. Drive: {{save.alternate_link}}",
        "Send as a bot?": "Yes",
        "Bot Name": "Zap alerts",
        "Include a link to this Zap?": "No"
      },
      "outputs": [
        "ts",
        "permalink"
      ]
    }
  ]
}
