IFTTT hoje handler
@lucasew
code:
data:privatelast updated:3 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
(auths.telegram_bot_api)
(auths.google_tasks)
params
TasklistId
 
string ·params.tasklistId
Telegram
Chat id
 
string ·params.telegram.chat_id
object ·params.telegram
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, params, 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
}
93
if ($checkpoint === undefined) {
  $checkpoint = [];
}
let text = new Buffer(steps.trigger.raw_event.body_b64, 'base64').toString();
if (text == '') {
  if (steps.trigger.raw_event.uri == '/favicon.ico') {
    return;
  }
  let debarredText = steps.trigger.raw_event.uri.slice(1)
  text = decodeURIComponent(debarredText)
}
console.log(text)
let separator = "https://"
let parts = text.split(separator)
if (parts.length < 2) {
  separator = "http://"
  parts = text.split(separator)
}
if (parts.length < 2) {
  separator = ""
  parts = [parts[0], ""]
} 
let [message, url] = parts
url = `${separator}${url}`
console.log({message, url})
const actions = {
/*  remnote({text, url}) {
    return require("@pipedreamhq/platform").axios(this, {
      method: 'POST',
      url: 'https://api.remnote.io/api/v0/create',
      data: {
        apiKey: params.remnote.apiKey,
        userId: params.remnote.userId,
        text: text == "" ? "Nova nota" : text,
        source: url,
        addToEditLater: true
      }
    })
  },*/
  task({text, url}) {
    return require("@pipedreamhq/platform").axios(this, {
      method: 'POST',
      url: `https://tasks.googleapis.com/tasks/v1/lists/${params.tasklistId}/tasks`,
      data: {
        kind: "tasks#task",
        title: `${text} ${url}`
      },
      headers: {
        "Authorization": `Bearer ${auths.google_tasks.oauth_access_token}`
      }
    })
  },
  telegram({text, url}) {
    return require("@pipedreamhq/platform").axios(this, {
      method: 'POST',
      url: `https://api.telegram.org/bot${auths.telegram_bot_api.token}/sendMessage`,
      data: {
        chat_id: params.telegram.chat_id,
        text: `${text} ${url}`,
        disable_notification: true
      }
    })
  }
}
if (event.headers.only) {
  if (actions[event.headers.only] != undefined) {
    $checkpoint.push({
      action: event.headers.only,
      text: message,
      url
    })
  }
} else {
  Object.keys(actions).map(key => $checkpoint.push({
    action: key,
    text: message,
    url
}));
}
while ($checkpoint.length > 0) {
  tasks = $checkpoint.slice(0, 10)
  let todo = tasks.map(cur => actions[cur.action](cur).catch((err) => {
    console.log("fail", cur)
    $checkpoint.push(cur)
    console.log(err)
    return err
  }))
  await Promise.all(todo)
  $checkpoint = $checkpoint.slice(10)
  console.log(`terminada rodada. itens restantes: ${$checkpoint.length}`)
}