Skip to content

Commit 91cde9e

Browse files
authored
Merge pull request #12 from codee-sh/improvement/update-githubs
docs: Enhance README and documentation for automation features and ru…
2 parents 2fa7f51 + b3306a3 commit 91cde9e

3 files changed

Lines changed: 279 additions & 52 deletions

File tree

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ A comprehensive automation plugin for Medusa v2 that provides a flexible rule-ba
44

55
## Features
66

7-
- **Automation Triggers**: Create automations triggered by events, schedules, or manual actions
8-
- **Automation Management**: Create, edit, and delete automation triggers with automatic cleanup of related data
9-
- **Rule-Based Conditions**: Define complex conditions using rule attributes (e.g., inventory levels, order status)
10-
- **Multiple Action Types**: Execute various actions including email notifications, Slack messages, SMS, push notifications, and custom actions
11-
- **Event Subscribers**: Built-in subscribers for common Medusa events (inventory updates, order events, payment events)
12-
- **Admin Panel**: Manage automations directly from Medusa Admin
13-
- **Flexible Rules**: Support for multiple rule types and operators (equals, greater than, less than, contains, etc.)
14-
- **Slack Notifications**: Rich Slack notifications with Block Kit support including headers, action buttons, and dividers
15-
- **Extensible Actions**: Add custom action handlers to extend automation capabilities
7+
- **Automation Triggers**: Create automations triggered by events, schedules, or manual actions ([see details](#automation-triggers))
8+
- **Rule-Based Conditions**: Define complex conditions with support for arrays, relations, and multiple data types ([see details](#rules-and-conditions))
9+
- **Rich Attribute Support**: Pre-configured attributes for Products, Variants, Tags, Categories, and Inventory ([see available attributes](./docs/configuration.md#available-attributes-reference))
10+
- **Multiple Action Types**: Execute various actions including email notifications, Slack messages, SMS, push notifications, and custom actions ([see details](#actions))
11+
- **Event Subscribers**: Built-in subscribers for common Medusa events ([see available events](./docs/configuration.md#available-subscribers))
12+
- **Admin Panel**: Manage automations directly from Medusa Admin ([see details](#admin-panel))
13+
- **Extensible**: Add custom action handlers and extend automation capabilities
1614
- **Type-Safe**: Full TypeScript support with exported types and workflows
1715

1816
## Compatibility
@@ -50,6 +48,8 @@ The plugin includes database migrations for automation models. Run migrations to
5048
medusa migrations run
5149
```
5250

51+
See [Database Migrations](./docs/configuration.md#database-migrations) for more details about the created tables.
52+
5353
### 3. Access Admin Panel
5454

5555
Navigate to **Notifications > Automations** in your Medusa Admin dashboard, or directly access:
@@ -63,17 +63,20 @@ Navigate to **Notifications > Automations** in your Medusa Admin dashboard, or d
6363
### Automation Triggers
6464

6565
Automations are triggered by:
66-
- **Events**: Medusa events (e.g., `inventory.inventory-level.updated`, `order.placed`)
66+
- **Events**: Medusa events (e.g., `inventory.inventory-level.updated`, `product.updated`)
6767
- **Schedule**: Time-based triggers with configurable intervals (In progress)
6868
- **Manual**: Triggered manually from the admin panel
6969

70+
See [Available Subscribers](./docs/configuration.md#available-subscribers) in the configuration documentation for a complete list of supported events.
71+
7072
### Rules and Conditions
7173

72-
Each automation can have multiple rules that define when actions should be executed:
74+
Each automation can have multiple rules that define when actions should be executed. Rules support primitive fields, relations (arrays), nested objects, and various operators for complex conditions.
7375

74-
- **Rule Attributes**: Available attributes for conditions
75-
- **Operators**: Comparison operators (equals, greater than, less than, contains, in, etc.)
76-
- **Rule Values**: Values to compare against
76+
For detailed information, see:
77+
- [Available Attributes Reference](./docs/configuration.md#available-attributes-reference) - Complete list of attributes for each event type
78+
- [Rule Operators](./docs/configuration.md#rule-operators) - All supported operators with examples
79+
- [Rule Values](./docs/configuration.md#rule-values) - Supported data types and usage
7780

7881
### Actions
7982

@@ -83,7 +86,7 @@ When automation rules pass, actions are executed. Supported action types include
8386
- **Slack**: Send Slack messages with Block Kit formatting
8487
- **Custom**: Extend with custom action handlers
8588

86-
See [Configuration Documentation](./docs/configuration.md) for details on built-in subscribers, available actions, and extending functionality.
89+
See [Actions](./docs/configuration.md#actions) and [Slack Notification Provider](./docs/configuration.md#slack-notification-provider) in the configuration documentation for details on configuring and extending actions.
8790

8891
## Admin Panel
8992

docs/admin.md

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,25 @@ Automations can be triggered by:
3737

3838
Each automation can have multiple rules that define conditions:
3939

40-
- **Rule Attributes**: Select from available attributes (e.g., `inventory_level.available_quantity`)
41-
- **Operators**: Choose comparison operators (equals, greater than, less than, contains, in, etc.)
42-
- **Values**: Set values to compare against
40+
- **Rule Attributes**: Select from available attributes including:
41+
- Primitive fields: `product.title`, `inventory_level.available_quantity`
42+
- Relations: `product.tags.id`, `product.categories.name` (arrays)
43+
- Nested objects: `inventory_level.inventory_item.*`
44+
- **Operators**: Choose comparison operators:
45+
- **Basic**: `equals`, `not equals`, `greater than`, `less than`, `greater than or equal`, `less than or equal`
46+
- **Array operations**: `in`, `not in`, `contains`, `not contains`
47+
- **Null checks**: `empty`, `not empty`
48+
- **Values**: Set values to compare against:
49+
- **Single values**: Enter a single string or number (e.g., `10`, `"Electronics"`)
50+
- **Array values**: Use the chip input to add multiple values (e.g., tag IDs, category names)
51+
- **No value**: For `empty` and `not empty` operators, no value input is required
4352

4453
#### Actions
4554

4655
When all rules pass, actions are executed:
4756

48-
- **Channels**: Configure delivery channels (email, slack, admin, etc.)
49-
- **Metadata**: Add custom metadata for actions
57+
- **Channels**: Configure delivery channels (email, slack etc.)
58+
- **Metadata**: Add custom config for actions
5059

5160
## Using the Admin Panel
5261

@@ -60,13 +69,19 @@ When all rules pass, actions are executed:
6069
- If schedule: Set interval in minutes
6170
- Set a name and description
6271
4. **Add Rules**:
63-
- Select rule attributes from available options
64-
- Choose operators
65-
- Set comparison values
66-
- Add multiple rules as needed
72+
- Select rule attributes from available options (including relations and nested objects)
73+
- Choose operators based on your needs:
74+
- Use `in` or `not in` for checking if a value exists in an array
75+
- Use `contains` or `not contains` for partial matches in arrays
76+
- Use `empty` or `not empty` to check for null/empty values
77+
- Set comparison values:
78+
- For array operators (`in`, `not in`, `contains`, `not contains`): Use the chip input to add multiple values
79+
- For basic operators: Enter a single value
80+
- For `empty`/`not empty`: No value input needed
81+
- Add multiple rules as needed (all rules must pass for the automation to trigger)
6782
5. **Configure Actions**:
6883
- Set delivery channels
69-
- Add metadata if needed
84+
- Add config if needed
7085
6. **Save**: Save the automation configuration
7186

7287
### Editing an Automation
@@ -91,21 +106,37 @@ Create an automation that sends a notification when inventory levels drop below
91106
- **Rule**: `inventory_level.available_quantity` is less than `10`
92107
- **Action**: Send email notification
93108

94-
### High Stock Alert
109+
### Product Tag Automation
95110

96-
Create an automation for when inventory exceeds a certain level:
111+
Create an automation that triggers when a product has specific tags:
112+
113+
- **Trigger**: Event `product.product.updated`
114+
- **Rule**: `product.tags.id` is `in` `[tag-premium, tag-featured]` (use chip input for multiple tag IDs)
115+
- **Action**: Send Slack notification
116+
117+
### Category-Based Automation
118+
119+
Create an automation for products in specific categories:
120+
121+
- **Trigger**: Event `product.product.created`
122+
- **Rule**: `product.categories.name` contains `"Electronics"` (or use `in` operator with multiple category names)
123+
- **Action**: Send email notification
124+
125+
### Empty Inventory Check
126+
127+
Create an automation that triggers when inventory is empty:
97128

98129
- **Trigger**: Event `inventory.inventory-level.updated`
99-
- **Rule**: `inventory_level.stocked_quantity` is greater than `1000`
100-
- **Action**: Send admin notification
130+
- **Rule**: `inventory_level.available_quantity` is `empty`
131+
- **Action**: Send Slack notification
101132

102-
### Scheduled Inventory Report
133+
### High Stock Alert
103134

104-
Create a scheduled automation that runs periodically:
135+
Create an automation for when inventory exceeds a certain level:
105136

106-
- **Trigger**: Schedule with interval of `1440` minutes (daily)
107-
- **Rules**: Configure conditions for what to include in the report
108-
- **Action**: Generate and send inventory report
137+
- **Trigger**: Event `inventory.inventory-level.updated`
138+
- **Rule**: `inventory_level.stocked_quantity` is greater than `1000`
139+
- **Action**: Send Slack notification
109140

110141
## Best Practices
111142

@@ -114,4 +145,10 @@ Create a scheduled automation that runs periodically:
114145
3. **Monitor Performance**: Keep an eye on automation execution and performance
115146
4. **Use Appropriate Triggers**: Choose the right trigger type for your use case
116147
5. **Combine Rules**: Use multiple rules to create complex conditions
117-
6. **Document Automations**: Add descriptions to explain automation purpose
148+
6. **Document Automations**: Add descriptions to explain automation purpose
149+
7. **Choose the Right Operator**:
150+
- Use `in`/`not in` for exact matches in arrays (e.g., checking if product has specific tags)
151+
- Use `contains`/`not contains` for partial matches (e.g., checking if category name contains a substring)
152+
- Use `empty`/`not empty` for null checks
153+
8. **Use Array Values Correctly**: When using array operators (`in`, `not in`, `contains`, `not contains`), use the chip input to add multiple values
154+
9. **Leverage Relations**: Use relation-based attributes (e.g., `product.tags.id`, `product.categories.name`) to create powerful automations based on related data

0 commit comments

Comments
 (0)