[ { "label": "Send yesterdays sales to slack", "trigger_type": [ "order_custom" ], "object_type": "order", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": { "1": { "conditions": [], "actions": { "1": { "type": "custom", "settings": { "wait": "0", "custom_wait": "", "label": "Send yesterday's total sales to slack", "twig": "{% set report_date = \"now\"| date_modify('-1 days') | date('Y-m-d') %}\r\n{% set orders = RUN_ACTION('shopify_api_request',{\r\n method: \"GET\",\r\n path: \"orders\",\r\n data: {status:\"any\",created_at_min:report_date, created_at_max:\"now\"|date('Y-m-d')}\r\n}) %}\r\n{% set total_sales = 0.0 %}\r\n{% for order in orders.response.orders %}\r\n{% set total_sales=total_sales + order.subtotal_price %}\r\n{% endfor %}\r\nTotal Sales: {{total_sales}}\r\n{% do QUEUE_ACTION(\"slack\", {\r\n to: \"#random\",\r\n body: \"Total Sales for \"~report_date~\" was \"~total_sales\r\n}) %}\r\n", "token_object_type": "order" }, "weight": 999, "target_key": "order" } } } }, "shared_workflow_id": 33620 }, "description": "This automation sends the total sum of yesterday's sales as a slack message, just after midnight" } ]