Script Specification

module.exports(payload, context)

A Mesa Script exports a class with a script() method that is passed the following parameters:

Parameters

Name
Type
Description

payload

object

The payload data

context

Contains data relative to the current task that is running.

Returns

  • Void

{object} Context()

context parameter

Parameters

Name
Type
Description

payload

object

The payload data

shop

Complete Shopify shop object

shop.email

string

Merchant's email address

shop.myshopify_domain

string

Shop string. Example: myshop.myshopify.com

shop.myshopify_domain

domain

Shop's domain if it has been customized, otherwise the myshopify domain

steps

object

An object containing the full payload for each step run in this automation so far, keyed by each step's key. For example steps.shopify.

trigger

The complete Trigger object contains information about the current step being run

task

The complete Task object contains information about this specific task run

automation

The complete Automation object contains information about the workflow

Returns

  • Void

{object} Task()

Task details for the current step.

Parameters

Name
Type
Description

is_test

boolean

If this is a test run, it will not be billed

is_premium

boolean

Whether this will is a premium step run

execution_time

number

memory

number

replay_of

string

ID of the task that this task is a replay of

replayed_by

string

ID of the task that replayed this task

replay_count

number

automation

object

automation._id

string

automation.automation_name

string

trigger

object

Step information

trigger._id

string

trigger.trigger_name

string

trigger.trigger_type

string

trigger.trigger_key

string

trigger.task_id

string

parents

object

Tasks that were ran before this one in the current run

parents._id

string

parents.trigger_name

string

parents.trigger_type

string

parents.trigger_key

string

parents.task_id

string

depth_parent_id

string

child_id

child_fails

number

The number of child failed tasks.

child_stops

number

The number of child stopped tasks.

child_completes

number

The number of child completed tasks that successfully completed all of the steps in the workflow.

source

string

Human-readable source of the task

context

object

context.headers

object

A key-value object of all of the headers passed to this task (if it was an input)

context.timestamp

string

payload_hash

string

A hash of the payload that is used to deduplicate duplicate webhooks

billable

boolean

Whether or not this was a billable task (criteria: is an input, not a test, etc)

billable_amount

number

The number of units this task cost (1 if just the input for an automation, 2 if it's the input of an automation that contains a premium step)

unbillable_reason

string

The reason this task is unbillable. not_input, etc

external_id

string

The ID of this object in the external system (shopify order id, etc)

external_label

string

A human-readable representation of this object in the external system (Shopify Order Name like #1001, etc)

external_url

string

The URL to the record in the external system, for example a link to the Shopify order in the admin

enqueued

boolean

active

boolean

_id

created_at

updated_at

Returns

  • Void

{object} Trigger()

Trigger details for the current step including the service and step configuration.

Parameters

Name
Type
Description

schema

number

version

string

trigger_type

string

is_premium

boolean

is_pro

boolean

uuid

string

automation

string

type

string

entity

string

action

string

operation_id

string

name

string

key

string

trigger_name

string

metadata

object

metadata.script

string

local_fields

object

Optional

weight

number

script

on_error

string

created_at

string

updated_at

string

tokens_ignore_previous

response

object

fields

object

fields.key

string

fields.type

string

fields.tokens

string

fields.location

string

fields.label

string

fields.file

string

response_example

object

response_example.trigger_type

string

response_example.connector

string

response_example.title

string

response_example.description

string

response_example.icon

string

response_example.endpoint

string

response_example.operation_id

string

response_example.key

string

{}

request_example

configuration_aside

connector_name

string

icon

string

description

string

raw_metadata

object

The raw metadata without any token replacements. This can be helpful if we want to to have a field where the merchant enters a token (like Dropbox)

Optional

Returns

  • Void

{object} Automation()

The details of the current workflow.

Parameters

Name
Type
Description

uuid

string

key

string

name

string

version

string

template

string

helpscout_article_id

string

description

string

video

string

is_premium

boolean

enabled

boolean

did_complete

boolean

logging

boolean

debug

boolean

seconds

number

notifications

object

notifications.enabled

boolean

_id

string

created_at

string

updated_at

string

inputs

array.trigger

outputs

array.trigger

scripts

array.script

source_entity

string

key_editable

boolean

Returns

  • Void

{object} Shop()

Details from the active Shopify store including email address and domain.

Parameters

Name
Type
Description

id

number

name

string

email

string

Store's email address

domain

string

Store's public-facing domain name, ex: www.mystore.com

province

string

country

string

address1

string

zip

string

city

string

source

phone

string

latitude

longitude

primary_locale

string

address2

created_at

string

updated_at

string

country_code

string

country_name

string

currency

string

customer_email

string

timezone

string

iana_timezone

string

shop_owner

string

money_format

string

money_with_currency_format

string

weight_unit

string

province_code

string

taxes_included

boolean

auto_configure_tax_inclusivity

tax_shipping

county_taxes

boolean

plan_display_name

string

plan_name

string

has_discounts

boolean

has_gift_cards

boolean

myshopify_domain

string

google_apps_domain

google_apps_login_enabled

money_in_emails_format

string

money_with_currency_in_emails_format

string

eligible_for_payments

boolean

requires_extra_payments_agreement

boolean

password_enabled

boolean

has_storefront

boolean

eligible_for_card_reader_giveaway

boolean

finances

boolean

primary_location_id

number

cookie_consent_level

string

visitor_tracking_consent_preference

string

checkout_api_supported

boolean

multi_location_enabled

boolean

setup_required

boolean

pre_launch_enabled

boolean

enabled_presentment_currencies

Array.<string>

Returns

  • Void

Last updated