Completed ToDos
@raymondcamden
code:
data:privatelast updated:2 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
Cron Scheduler
Deploy to configure a custom schedule
This workflow runs on Pipedream's servers and is triggered on a custom schedule.
steps.
getCompletedToDos
auth
to use OAuth tokens and API keys in code via theauths object
(auths.microsoft_graph_api)
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, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
}
36

import fetch from 'node-fetch';

// set date filter to now - 7
let lastWeek = new Date();
lastWeek.setDate(lastWeek.getDate() - 7);
/*
Bug found 2/9/2012, just the Z coming back broke shit, so remove it.
*/
let lastWeekStr = `${lastWeek.getFullYear()}-${lastWeek.getMonth()+1}-${lastWeek.getDate()}`;
console.log('lastWeek',lastWeekStr);

const rootUrl = `https://graph.microsoft.com/v1.0/me/todo/lists/AQMkADAwATMzAGZmAS04MDU4LWQ4ZjctMDACLTAwCgAuAAAD2b-xt4VpMU28CRdh70oBigEAzwpFFkTJnUqSIr7l4olnFgACofznJAAAAA==/tasks?$filter=status eq 'completed' and completedDateTime/dateTime ge '${lastWeekStr}'`;

async function getCompletedToDos(todos = [], url = rootUrl) {
  let result = await fetch(url, {
    headers: {
      'Authorization':`Bearer ${auths.microsoft_graph_api.oauth_access_token}`
    }
  });
  let data = await result.json();
  console.log(data);
  data.value.forEach(d => {
    todos.push({
      title:d.title,
      completed:d.completedDateTime.dateTime
    })
  });
  if(data['@odata.nextLink']) {
    return await getCompletedToDos(todos, data['@odata.nextLink']);
  } else return todos;
}

return await getCompletedToDos();
steps.
endifempty
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
if(steps.getCompletedToDos.$return_value.length === 0) $end('No completed tasks');
steps.
makeemail
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
}
19
let html = `
<h2>Look What You Did!</h2>
<p>
Life is hard, but somehow this week you managed to scratch off a few items from your task list! You should
feel great about finishing the following:
</p>
<ul>
`;

steps.getCompletedToDos.$return_value.forEach(todo => {
  html += `
<li>${todo.title}</li>  
  `
});

html += '</ul>';
return html;
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
 
string ·params.subject
Text
 
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)