auths
objectEnter your Postgres database host name.
Enter your database name.
Enter your database username.
Enter your database password or use an environment variable (configure at https://pipedream.com/settings)
Enter the port for your database.
Enter the SQL query you want to run. The results will be exported from this step as an array. You can access the data in any subsequent steps by referencing steps.query_postgres.results
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const { Client } = require('pg')
const client = new Client({
host: params.host,
database: params.database,
user: params.user,
password: params.password,
port: params.port,
})
await client.connect()
this.results = (await client.query(params.sql_query)).rows
await client.end()
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
// write node.js glue code here to transform your query results
// the message you generate here is sent via sms using Twilio in the next step
// you can also optionally send to email and slack. just activate the steps using the toggle and configure them.
return `Your query returned ${steps.query_postgres.results.length} rows.`
The destination phone number. Format with a '+' and country code e.g., +16175551212 (E.164 format).
A Twilio phone number (in E.164 format) or alphanumeric sender ID enabled for the type of message you wish to send. Phone numbers or short codes purchased from Twilio work here. You cannot (for example) spoof messages from your own cell phone number.
The text of the message you want to send, limited to 1600 characters.
async
(params, auths) => {
}
const data = {
To: params.To,
From: params.From,
MessagingServiceSid: params.MessagingServiceSid,
Body: params.Body,
MediaUrl: params.MediaUrl,
}
const config = {
method: "post",
url: `https://api.twilio.com/2010-04-01/Accounts/${auths.twilio.AccountSid}/Messages.json`,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
auth: {
username: auths.twilio.Sid,
password: auths.twilio.Secret,
},
data: require("qs").stringify(data),
}
return await require("@pipedreamhq/platform").axios(this, config)
async
params => {
}
const options = {
subject: params.subject,
text: params.text,
}
if (params.html) {
options.html = params.html
}
$send.email(options)
Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See below for more details.
Text of the message to send. See below for an explanation of formatting. This field is usually required, unless you're providing only attachments instead. Provide no more than 40,000 characters or risk truncation.
async
(params, auths) => {
}
const data = {
channel: params.channel,
text: params.text,
as_user: params.as_user,
attachments: params.attachments,
blocks: params.blocks,
icon_emoji: params.icon_emoji,
icon_url: params.icon_url,
link_names: params.link_names,
mrkdwn: params.mrkdwn,
parse: params.parse,
reply_broadcast: params.reply_broadcast,
thread_ts: params.thread_ts,
unfurl_links: params.unfurl_links,
unfurl_media: params.unfurl_media,
username: params.username,
}
const config = {
method: "post",
url: `https://slack.com/api/chat.postMessage`,
headers: {
Authorization: `Bearer ${auths.slack.oauth_access_token}`,
},
data,
}
return await require("@pipedreamhq/platform").axios(this, config)