[ { "label": "Text a discount code to a customer after they have placed two orders", "trigger_type": [ "order_paid" ], "object_type": "order", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": [ { "conditions": { "0": { "field": "order.customer.orders_count", "settings": { "operator": "gte", "value": "2" }, "weight": 10 }, "4": { "field": "order.customer.sms_marketing_consent.state", "settings": { "operator": "any", "value": { "subscribed": "subscribed", "not_subscribed": 0, "pending": 0, "redacted": 0, "unsubscribed": 0 }, "condition_type": "AND" }, "weight": 20 }, "5": { "field": "order.customer.database", "settings": { "multiple": "any", "key": "discount_code_sent", "operator": "empty", "value": "", "token_object_type": "order", "condition_type": "AND" }, "weight": 30 }, "3": { "field": "order.customer.phone", "settings": { "operator": "not_empty", "value": "" }, "weight": 40 } }, "actions": { "0": { "type": "sms", "settings": { "wait": "0", "custom_wait": "", "to": "{{ order.customer.phone }}", "body": "Use code [CODE] for 20% off your next order at {{ shop.name }}" }, "weight": 50, "target_key": "order" }, "2": { "type": "customer_set_database", "settings": { "token_object_type": "order", "key": "discount_code_sent", "value": "1", "wait": "0", "cw_timezone": "America\/New_York", "custom_wait": "" }, "weight": 70, "target_key": "order.customer" } } } ], "shared_workflow_id": 334 }, "description": "This workflow is triggered when a customer pays for an order. The workflow checks that the customer accepts text messages, and that they have not yet received the discount code. It also tracks if the customer has already received the discount code. If all conditions are met, the text message is sent. " } ]