auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
const _ = require('lodash')
//end workflow execution if no text is found
if(_.get(event,'body.text',false) === false) {
const msg = `Could not find text to analyze. To use this workflow, make an HTTP POST request to your endpoint the following payload: {"text":"TEXT_TO_ANALYZE"}`
//return the payload to the client using $respond
$respond({
status: 400,
body: msg
})
//if returning a response to the client is not enabled, console log the URL to enable it
if(event.url.search('pipedream_response=1') === -1) {
console.log(`Make requests to https://${event.headers.host}?pipedream_response=1 to return messages to the client` )
}
//end the workflow execution
$end(msg)
}
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
var Sentiment = require('sentiment');
var sentiment = new Sentiment();
this.sentiment = sentiment.analyze(event.body.text)
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
//create a payload for Pipedream's SQL service
this.payload = {
"timestamp": steps.trigger.context.ts,
"text": event.body.text,
"sentiment": steps.analyze_text.sentiment
}
//return the payload to the client using $respond
$respond({
status: 200,
body: this.payload
})
//if returning a response to the client is not enabled, console log the URL to enable it
if(event.url.search('pipedream_response=1') === -1) {
console.log(`Inspect the results below or make an HTTP POST request to https://${event.headers.host}?pipedream_response=1 to return the sentiment score to the client` )
}
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,
})