auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
const get = require("lodash.get")
const includes = require("lodash.includes")
const MAX_ITEMS = 5000
const { email } = event.body
// Process event emails we haven't seen before. End early if we've already seen the ID.
const idsSeenSoFar = get(this, '$checkpoint', [])
if (includes(idsSeenSoFar, email)) {
$end(`We've already seen email id - ${email}. Exiting`)
}
console.log(`We haven't seen email id ${email}. Processing event...`)
// Remove the last ID we processed if we've exceeded our length
// of IDs we want to store.
if (idsSeenSoFar.length >= MAX_ITEMS) {
idsSeenSoFar.pop()
}
// This is a FIFO queue, so we add the newest item to the front
// and save the IDs back to this.checkpoint
idsSeenSoFar.unshift(email)
this.$checkpoint = idsSeenSoFar
async
(params, auths) => {
}
const data = {
attachments: params.attachments,
unfurl_links: params.unfurl_links,
text: params.text,
unfurl_media: params.unfurl_media,
parse: params.parse,
as_user: params.as_user,
mrkdwn: params.mrkdwn,
channel: params.channel,
username: params.username,
blocks: params.blocks,
icon_emoji: params.icon_emoji,
link_names: params.link_names,
reply_broadcast: params.reply_broadcast,
thread_ts: params.thread_ts,
icon_url: params.icon_url,
}
try {
return (await require("axios")({
method: "post",
url: `https://slack.com/api/chat.postMessage`,
headers: {
Authorization: `Bearer ${auths.slack.oauth_access_token}`,
},
data,
})).data
} catch (err) {
this.err = err
throw err
}
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, auths) => {
}
console.log(auths.sendgrid.api_key)
const sgMail = require("@sendgrid/mail")
// We wait a few minutes to send the email, to make sure
// the user has had a change to play around with the product
const SECONDS_DELAY = 41 * 60
const sendAt = Math.round((new Date()).getTime() / 1000) + SECONDS_DELAY
// HTML for our email
// We're using Sendgrid. They're automatically inserting a custom Unsubscribe / Address
// footer for us, for all emails sent from our account.
// See https://sendgrid.com/docs/ui/sending-email/subscription-tracking
const html = `<html>\
<body>\
Welcome to RequestBin! I am Tod Sacerdoti, one of the founders.<br /><br />\
We are currently working on a new and improved version of RequestBin built on the Pipedream platform for running hosted, backend components. This new version allows you to manage bins and events via API, subscribe to real-time event streams via SSE and trigger a workflow on every event.
<br /><br />\
If you would like to try it out, <a href="http://tod.ly/38qCUjj">click here</a>.
<br /><br />\
Lastly, let me know how we can help you get stuff done or improve our products. We love feedback and hope to hear from you!<br /><br />\
cheers,<br />\
${process.env.WELCOME_EMAIL_FROM_NAME.split(/\s+/)[0].toLowerCase()}<br /><br /><br />`
// Send the email at the specified time
sgMail.setApiKey(auths.sendgrid.api_key)
console.log(process.env.WELCOME_EMAIL_BCC_ADDR)
const msg = {
to: event.body.email,
cc: process.env.WELCOME_EMAIL_BCC_ADDR,
from: {
email: process.env.WELCOME_EMAIL_FROM_ADDR,
name: process.env.WELCOME_EMAIL_FROM_NAME,
},
subject: process.env.WELCOME_EMAIL_SUBJECT,
html,
sendAt
}
const res = await sgMail.send(msg)
console.log(res)
auths
objectName of a member.
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params, auths) => {
}
if (steps.trigger.event.body.connection === "github") {
const config = {
method: "put",
url: `https://api.github.com/user/following/${params.username}`,
headers: {
Authorization: `Bearer ${auths.github.oauth_access_token}`,
"Content-Length": 0,
},
}
return await require("@pipedreamhq/platform").axios(this, config)
}
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, auths) => {
}
var requestify = require('requestify');
var emailurl = `https://api.rocketreach.co/v1/api/lookupProfile?api_key=${auths.rocketreach.api_key}&email=${event.body.email}`;
try {
var response = await requestify.get(emailurl)
console.log(`Reponse: ${response}`)
if (!response) {
$end("No RocketReach enrichment data — exiting")
}
this.payload = JSON.parse(response.body)
} catch (err) {
console.log(err)
$end("No RocketReach enrichment data — exiting")
}
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
this.rocketreachData = {
attachments: [
{
author_name: `${steps.rocketreach.payload[0].current_title}`,
author_link: `${steps.rocketreach.payload[0].links.twitter}`,
author_icon: `${steps.rocketreach.payload[0].profile_pic}`,
text: `${event.body.email}`,
title: `LinkedIn`,
title_link: `${steps.rocketreach.payload[0].linkedin_url}`,
}
]
}
async
(params, auths) => {
}
const data = {
attachments: params.attachments,
unfurl_links: params.unfurl_links,
text: params.text,
unfurl_media: params.unfurl_media,
parse: params.parse,
as_user: params.as_user,
mrkdwn: params.mrkdwn,
channel: params.channel,
username: params.username,
blocks: params.blocks,
icon_emoji: params.icon_emoji,
link_names: params.link_names,
reply_broadcast: params.reply_broadcast,
thread_ts: params.thread_ts,
icon_url: params.icon_url,
}
try {
return (await require("axios")({
method: "post",
url: `https://slack.com/api/chat.postMessage`,
headers: {
Authorization: `Bearer ${auths.slack.oauth_access_token}`,
},
data,
})).data
} catch (err) {
this.err = err
throw err
}
Enter the name of the table (e.g., my_table_name) to load the payload data into. Pipedream's SQL service automatically creates the table and adapts the schema to your data.
Enter a reference to the data (for example, event.body or steps.step_name.return_value) you'd like to insert into the table. Pipedream’s SQL service automatically converts the data to JSON and maps the table schema to its keys.
async
params => {
}
$send.sql({
table: params.table,
payload: params.payload,
})