Platform SDK

Tasks script has access to the Kiwi Automation platform JS SDK which provides convenient utility functions.

const { auths, libs } = require('platform');

Methods

libs.shopify.get()

Returns an instance of Shopify-api-node library, with the credentials already set up. You can then call Shopify APIs directly, like the following.

Rest API: Get Order tags
Graphql: Get product tags from order
Rest API: Get Order tags
const shopify = libs.shopify.get();
const { tags } = await shopify.order.get(order_id, { fields: 'tags' });
Graphql: Get product tags from order
const shopify = libs.shopify.get();
const query = `{
order(id: "gid://shopify/Order/${orderID}") {
id
tags
lineItems (first: 100) {
edges {
node {
id
product {
id
tags
}
}
}
}
}
}`;
const { order } = await shopify.graphql(query);

libs.email.get()

Requires the Email SMTP integration to be set up

Returns an instance of nodemailer transporter. You can directly use it to start sending emails

Send simple Email
Send simple Email
const mailer = libs.email.get();
await mailer.sendMail({
to: "test@gmail.com", // list of receivers
subject: "Hello ", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // html body
});