Shopify Partner to Slack
@pierce
code:
data:privatelast updated:2 years ago
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
active
last updated:-last event:-
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
15
16
17
18
19
20
21
22
23
24
25
26
27
28
}
29
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;
steps.
send_block_kit_message

Send a message using Slack's Block Kit UI framework to a channel, group or user

configure

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.

 
Enter a value for blocks

Optionally provide a string for Slack to display as the new message notification (if you do not provide this, notification will be blank).

 
Enter a value for Notification Text

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.

 
Enter a value for Bot Username

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.

 
Enter a value for Icon (emoji)

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.

 
Enter a value for Icon (image URL)