auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
import { parseISO, format } from 'date-fns';
const eventEmojiMapping = {
RelationshipInstalled: ':tada:',
RelationshipUninstalled: ':sob:',
RelationshipDeactivated: ':red_circle:',
RelationshipReactivated: ':repeat',
SubscriptionChargeActivated: ':dollar:',
SubscriptionChargeAccepted: ':dollar:',
SubscriptionChargeCanceled: ':x:',
SubscriptionChargeDeclined: ':x:',
SubscriptionChargeFrozen: ':cold:'
}
let blocks = [
{"type": "header", "text": { "type": "plain_text", "text": `${steps.trigger.event.__typename.replace(/([A-Z])/g, ' $1').trim()} ${eventEmojiMapping[steps.trigger.event.__typename]}` }},
{type: "section", text: { type: "mrkdwn", text: `<https://${steps.trigger.event.shop.myshopifyDomain}|${steps.trigger.event.shop.name}>` }},
{type: "context", elements: [ { type: 'plain_text', text: format(parseISO(steps.trigger.event.occurredAt), 'MMMM do yyyy') } ]}
];
if(steps.trigger.event?.charge) {
const block = { type: "section", text: { type: 'mrkdwn', text: `${steps.trigger.event.charge.name} for $${steps.trigger.event.charge.amount.amount}` } }
blocks.splice(2, 0, block);
}
return blocks;
Send a message using Slack's Block Kit UI framework to a channel, group or user
Select a public or private channel, or a user or group.
Enter an array of structured blocks as a URL-encoded string. E.g., [{ "type": "section", "text": { "type": "mrkdwn", "text": "This is a mrkdwn section block :ghost: *this is bold*, and ~this is crossed out~, and <https://pipedream.com|this is a link>" }}]
Tip: Construct your blocks in a code step, return them as an array, and then pass the return value to this step.
Optionally provide a string for Slack to display as the new message notification (if you do not provide this, notification will be blank).
Optionally pass TRUE
to post the message as the authed user, instead of as a bot. Defaults to FALSE
.
Optionally customize your bot's user name (default is Pipedream
). Must be used in conjunction with as_user
set to false, otherwise ignored.
Optionally provide an emoji to use as the icon for this message. E.g., :fire:
Overrides icon_url
. Must be used in conjunction with as_user
set to false
, otherwise ignored.
Optionally provide an image URL to use as the icon for this message. Must be used in conjunction with as_user
set to false
, otherwise ignored.