RequestBin.com New User Workflow
@tod
code:
data:privatelast updated:1 year agoarchived
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 800,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.
checkpoint
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
20
21
22
23
24
}
25
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
steps.
chat_post_message
Sends a message to a channel.
auth
(auths.slack)
params
Optional
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
23
24
25
26
27
28
29
30
31
}
32
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
}
steps.
sendgrid
auth
to use OAuth tokens and API keys in code via theauths object
(auths.sendgrid)
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
37
38
39
40
}
41
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)
steps.
follow_a_user
auth
to use OAuth tokens and API keys in code via theauths object
(auths.github)
params
Username

Name of a member.

 
string ·params.username
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
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)
}
steps.
rocketreach
auth
to use OAuth tokens and API keys in code via theauths object
(auths.rocketreach)
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
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")
}
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
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}`,
        }
    ]
} 
steps.
chat_post_message_1
Sends a message to a channel.
auth
(auths.slack)
params
Optional
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
23
24
25
26
27
28
29
30
31
}
32
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
}
steps.
sql
Pipedream automatically generates a table and schema based on the event shape.
params
Table Name

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.

 
string ·params.table
Payload

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.

 
string ·params.payload
code
async params => {
1
2
3
4
5
}
6
  $send.sql({
    table: params.table,
    payload: params.payload,
  })