Save HTML body as Markdown in Google Drive
@febryan
code:
data:privatelast updated:4 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 1,000,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
nodejs
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
}
18
const fs = require('fs')
const JSDOM = require('jsdom').JSDOM
const Turndown = require('turndown')
const { Readability } = require('@mozilla/readability')
const doc = new JSDOM(event.body.data, { url: event.body.url })
const reader = new Readability(doc.window.document)
const readerDoc = reader.parse()
const turndownService = new Turndown({ emDelimiter: '*' })
const title = event.body.title
let body = `*[View Original](${event.body.url})*\n\n` + turndownService.turndown(readerDoc.content)
if (event.body.tags) {
  const tagsList = event.body.tags.split(',')
  const hashtags = tagsList.map((a) => `#${a}`)
  body = hashtags.join(' ') + '\n\n' + body
}
fs.writeFileSync(`/tmp/${title}.md`, body)
steps.
upload_file_to_folder_by_file_path
Allows you to upload a file previously-saved to the /tmp directory, by passing in the path to that file
auth
(auths.google_drive)
params
Filename
{{event.body.title}}.md
string ·params.filename
Parent Folders

A list of parent folder IDs, entered manually or retrieved from a previous file list operation

[0]:
 
array ·params.parents
Filetype
text/markdown
string ·params.filetype
File path

The path to the file, e.g. /tmp/myFile.csv .

/tmp/{{event.body.title}}.md
string ·params.pathToFile
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
}
22
const fs = require("fs")
const {google} = require('googleapis')

const driveAuth = new google.auth.OAuth2()
driveAuth.setCredentials({ access_token: auths.google_drive.oauth_access_token })
const drive = await google.drive({ version: 'v3', auth: driveAuth });

this.uploadResponse = (await drive.files.create({
  resource: {
    name: params.filename,
    originalFilename: params.filename,
    parents: params.parents,
  },
  media: {
    mimeType: params.filetype,
    uploadType: "media",
    body: fs.createReadStream(params.pathToFile)
  },
  fields: '*'
})).data
steps.
email_me
Customize and send an email to the email address you registered with Pipedream. The email will be sent by notifications@pipedream.com.
params
Subject
Pipedrive event - Markdown Save
string ·params.subject
Text
FYI: Just saved the following link to the markdown folder

Title: {{event.body.title}}
Link: {{event.body.url}}

Thanks and have a nice day!
string ·params.text
Optional
code
async params => {
1
2
3
4
5
6
7
8
9
10
11
12
}
13
const options = {
  subject: params.subject,
  text: params.text,
}
if (params.html) {
  options.html = params.html
}
if (params.include_collaborators) {
  options.include_collaborators = params.include_collaborators
}
$send.email(options)