Google Drive Export

I really needed to download a Google DOC and this is not possible with the Download function from the Drive node, an “Export” function (available in the drive API) should be implemented

In this moment I’m using chained DOCs edits + lambdas nodes to make the exports I need, directly with the google drive API, which is bad to scale to more documents

There’s already a PR opened for this, were this guy apparently already solved this problem:

So maybe we just need to review and approve? :slight_smile:

Thankss!

Hi @Gustavo_Haschich

According to Ricardo’s response in this post, this implementation is close to taking place.

While we don’t have it, I solved my use case as shown in the image below.

this is my workflow

{
  "name": "Criar documento de template e enviar pdf por email",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -380,
        240
      ],
      "disabled": true
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "copy",
        "fileId": "=1805eWHwa47dTnOAycE2AuRcJuhett4SOJNCPPEubNyE",
        "options": {
          "name": "=Proposta {{$node[\"IF\"].json[\"NUMERO\"]}}",
          "parents": [
            "1-grFMHLTC6mg1CtxF0BV3QvxU9GoO6ji"
          ]
        }
      },
      "name": "Copiar template para pasta especifica",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 1,
      "position": [
        820,
        180
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "11",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "update",
        "documentURL": "={{$json[\"id\"]}}",
        "actionsUi": {
          "actionFields": [
            {
              "action": "replaceAll",
              "text": "{{number}}",
              "replaceText": "={{$node[\"IF\"].json[\"NUMERO\"]}}",
              "matchCase": true
            },
            {
              "action": "replaceAll",
              "text": "{{name}}",
              "replaceText": "={{$node[\"IF\"].json[\"NOME\"]}}",
              "matchCase": true
            },
            {
              "action": "replaceAll",
              "text": "{{service}}",
              "replaceText": "={{$node[\"IF\"].json[\"SERVICO\"]}}",
              "matchCase": true
            },
            {
              "action": "replaceAll",
              "text": "{{value}}",
              "replaceText": "={{$node[\"IF\"].json[\"VALOR\"]}}",
              "matchCase": true
            }
          ]
        }
      },
      "name": "Atualizar documento copiado",
      "type": "n8n-nodes-base.googleDocs",
      "typeVersion": 1,
      "position": [
        1060,
        180
      ],
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "12",
          "name": "Google Docs account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "share",
        "fileId": "={{$json[\"documentId\"]}}",
        "permissionsUi": {
          "permissionsValues": {
            "role": "reader",
            "type": "anyone"
          }
        },
        "options": {}
      },
      "name": "Compartilhar documento atualizado",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 1,
      "position": [
        1300,
        180
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "11",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {},
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "position": [
        -320,
        820
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "resource": "message",
        "subject": "=n8n Workflow Failure:  {{$json[\"workflow\"][\"name\"]}}",
        "message": "=Workflow: {{$json[\"workflow\"][\"name\"]}}\nErro: {{$json[\"execution\"][\"error\"][\"message\"]}}\nÚltimo nó executado: {{$json[\"execution\"][\"lastNodeExecuted\"]}}\nURL de execução: {{$json[\"execution\"][\"url\"]}}",
        "toList": [
          "[email protected]"
        ],
        "additionalFields": {}
      },
      "name": "Mensagem com erro",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -80,
        820
      ],
      "typeVersion": 1,
      "credentials": {
        "gmailOAuth2": {
          "id": "10",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "url": "=https://docs.google.com/feeds/download/documents/export/Export?id={{$node[\"Copiar template para pasta especifica\"].json[\"id\"]}}&exportFormat=pdf",
        "responseFormat": "file",
        "dataPropertyName": "=data",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1560,
        180
      ],
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "sheetId": "1mGd2bDfBHbIbB5-5dzpJvN2V4XwLsEszWpFYp_nB-FI",
        "options": {
          "valueRenderMode": "FORMATTED_VALUE"
        }
      },
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        -80,
        540
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "9",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"ENVIADO\"]}}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        200,
        540
      ]
    },
    {
      "parameters": {},
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        560,
        860
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "ENVIADO",
              "value": "Sim"
            },
            {
              "name": "NUMERO",
              "value": "={{$node[\"IF\"].json[\"NUMERO\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1060,
        540
      ]
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyHour"
            }
          ]
        }
      },
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        -320,
        540
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "update",
        "sheetId": "1mGd2bDfBHbIbB5-5dzpJvN2V4XwLsEszWpFYp_nB-FI",
        "key": "NUMERO",
        "options": {
          "valueRenderMode": "FORMATTED_VALUE"
        }
      },
      "name": "Atualizar planilha",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        1300,
        540
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "9",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "resource": "message",
        "subject": "=Proposta comercial - {{$node[\"IF\"].json[\"NUMERO\"]}}",
        "message": "=Olá {{$node[\"IF\"].json[\"NOME\"]}}\n\nSegue proposta para execução do serviço de {{$node[\"IF\"].json[\"SERVICO\"]}}\n\nAtt,\n\nClaudio da Vamos Automatizar",
        "toList": [
          "[email protected]"
        ],
        "additionalFields": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {
                "property": "=data"
              }
            ]
          }
        }
      },
      "name": "Enviar proposta",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 1,
      "position": [
        820,
        540
      ],
      "credentials": {
        "gmailOAuth2": {
          "id": "10",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "functionCode": "items[0].binary.data.fileName = $node[\"Copiar template para pasta especifica\"].json[\"name\"]+'.pdf' \nreturn items;\n"
      },
      "name": "Alterar nome do arquivo",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        560,
        540
      ]
    },
    {
      "parameters": {
        "operation": "limit"
      },
      "name": "Item Lists",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        560,
        180
      ]
    }
  ],
  "connections": {
    "Copiar template para pasta especifica": {
      "main": [
        [
          {
            "node": "Atualizar documento copiado",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Atualizar documento copiado": {
      "main": [
        [
          {
            "node": "Compartilhar documento atualizado",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Mensagem com erro",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Alterar nome do arquivo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compartilhar documento atualizado": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Item Lists",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Atualizar planilha",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar proposta": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Alterar nome do arquivo": {
      "main": [
        [
          {
            "node": "Enviar proposta",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Atualizar planilha": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists": {
      "main": [
        [
          {
            "node": "Copiar template para pasta especifica",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": 36
}
2 Likes

Thanks a lot!

1 Like

@Gustavo_Haschich @Claudio_Balbino It’s going to be added to the next release.

2 Likes