1 ---
2 products:
3 - product
4 - customer
5 - order
6 ---
7
8 import { AcademicCapSolid, BoltSolid } from "@medusajs/icons"
9
10 export const metadata = {
11 title: `Commerce Automation Recipe`,
12 }
13
14 # {metadata.title}
15
16 This recipe provides the general steps to implement commerce automation with Medusa.
17
18 ## Overview
19
20 Commerce automation is essential for businesses to save costs, provide a better user experience, and avoid manual, repetitive tasks that lead to human errors. Businesses utilize automation in different domains, including marketing, customer support, and order management.
21
22 Medusa provides the necessary architecture and tools to implement commerce automation for order management, customer service, and more. You can perform an asynchronous action when an event is triggered, schedule a job that runs at a specified interval, and more.
23
24 ---
25
26 ## Re-Stock Notifications
27
28 Customers may be interested in a product that is currently out of stock. Instead of losing their interest, you can allow them to subscribe to receive a notification when the product is back in stock.
29
30 Then, you can listen to product-related events and notify subscribed customers when a product variant is back in stock.
31
32 The following guide explains how to add restock notifications in your Medusa application:
33
34 <Card
35 href="/recipes/commerce-automation/restock-notification"
36 title="Restock Notification Guide"
37 text="Learn how to implement restock notifications in the Medusa application."
38 icon={AcademicCapSolid}
39 />
40
41 ---
42
43 ## Automated Customer Support
44
45 Customer support is essential to build a store's brand and customer loyalty. However, to provide an efficient customer support, you often need to integrate with third-party services, like Zendesk, and automate customer notifications.
46
47 ### Integrate with Third-Party Services
48
49 To provide customer support, you can Integrate with third-party services, such as ticket systems or chat bots in the storefront.
50
51 Medusa allows you to easily integrate with third-party services by creating a custom module, then build workflows for your business logic that perform actions with the third-party service.
52
53 This approach allows you to interact with the third-party service within custom and existing flows, while maintaining data consistency across systems. You can then execute the wokflow when an event is triggered, such as when a customer places an order or requests a return.
54
55 <CardList items={[
56 {
57 href: "!docs!/learn/fundamentals/modules",
58 title: "Create Module",
59 text: "Learn about how to create a custom module.",
60 icon: AcademicCapSolid,
61 },
62 {
63 href: "!docs!/learn/fundamentals/workflows",
64 title: "Create Workflow",
65 text: "Learn how to create a workflow.",
66 icon: AcademicCapSolid,
67 },
68 ]} />
69
70 ### Automate Customer Notifications
71
72 You can also automate sending notifications to customers when changes happen related to their orders, returns, exchanges, and more.
73
74 Medusa's Notification Module allows you to send notifications when an event is triggered, such as when a customer's order is updated. You can use third-party services, like [SendGrid](../../infrastructure-modules/notification/sendgrid/page.mdx), to send emails to customers.
75
76 <CardList items={[
77 {
78 href: "/infrastructure-modules/notification",
79 title: "Notification Module",
80 text: "Learn about the Notification Module.",
81 icon: AcademicCapSolid,
82 },
83 {
84 href: "!docs!/learn/fundamentals/events-and-subscribers",
85 title: "Create Subscriber",
86 text: "Learn how to create a subscriber to handle events.",
87 icon: AcademicCapSolid,
88 },
89 ]} />
90
91 ---
92
93 ## Automatic Data Synchronization
94
95 As your commerce store grows, you'll likely need to synchronize data across different systems. For example, you need to synchronize data with an ERP system or a data warehouse.
96
97 <Note title="Integrating an ERP?">
98
99 Refer to the [ERP](../erp/page.mdx) recipe for a focused guide on how to integrate with an ERP system.
100
101 </Note>
102
103 To implement that, you can:
104
105 - Create a workflow that implements the synchronization steps, along with retry and rollback logic. By using a workflow, you ensure data consistency across systems.
106 - Create a scheduled job that executes the workflow automatically at the specified time pattern.
107
108 <CardList items={[
109 {
110 href: "!docs!/learn/fundamentals/workflows",
111 title: "Create Workflow",
112 text: "Learn how to create a workflow.",
113 icon: AcademicCapSolid,
114 },
115 {
116 href: "!docs!/learn/fundamentals/scheduled-jobs",
117 title: "Create a Scheduled Job",
118 text: "Learn how to create a scheduled job.",
119 icon: AcademicCapSolid,
120 },
121 ]} />
122
123 ---
124
125 ## Order Management Automation
126
127 Medusa's architecture, Commerce Modules, and Framework for customizations facilitate automating a large amount of order management functionalities.
128
129 For example, you can automatically:
130
131 - Create a fulfillment when an order is placed.
132 - Create a refund when an item is returned.
133 - Send a notification when an order is shipped.
134
135 To handle events within an order flow and automate actions, you can create a subscriber that listens to the relevant event. For example, you can create a subscriber that listens to the `order.placed` event and automatically creates a fulfillment if predefined conditions are met.
136
137 <CardList items={[
138 {
139 href: "!docs!/learn/fundamentals/events-and-subscribers",
140 title: "Create a Subscriber",
141 text: "Learn how to create a subscriber in Medusa.",
142 icon: AcademicCapSolid,
143 },
144 {
145 href: "/references/events",
146 title: "Events Reference",
147 text: "Check out triggered events by each Commerce Module.",
148 icon: AcademicCapSolid,
149 },
150 ]} />
151
152 ---
153
154 ## Automated RMA Flow
155
156 Businesses must optimize their Return Merchandise Authorization (RMA) flow to ensure a good customer experience and service. By automating the flow, customers request to return their received items, and businesses quickly support them.
157
158 Medusa's commerce features are geared towards automating RMA flows and ensuring a good customer experience:
159
160 - Customers can create order returns from the storefront. Merchants then receive a notification and handle the return from the Medusa Admin.
161 - Merchants can make order changes and request the customer's approval for them. The customer can also send any additional payment if necessary.
162 - Every order-related action triggers an event, which you can listen to with a subscriber. This allows you to handle order events to automate actions.
163
164 <CardList items={[
165 {
166 href: "/commerce-modules/order",
167 title: "Order Module",
168 text: "Learn about the Order Module and its features.",
169 icon: AcademicCapSolid,
170 },
171 {
172 href: "!docs!/learn/fundamentals/events-and-subscribers",
173 title: "Create a Subscriber",
174 text: "Learn how to create a subscriber in Medusa.",
175 icon: AcademicCapSolid,
176 },
177 ]} />
178
179 ---
180
181 ## Customer Segmentation
182
183 Businesses use customer segmentation to organize customers into different groups and then apply different price rules to these groups.
184
185 Medusa's Commerce Modules provide the necessary features to implement this use case:
186
187 - The Customer Module allows you to organize customers into customer groups.
188 - The Pricing Module allows you to specify prices based on a condition, such as the group of the customer.
189
190 For example, to group customers with over twenty orders:
191
192 1. Create a subscriber that listens to the `order.placed` event.
193 2. If the customer has more than 20 orders, add them to the VIP customer group.
194
195 <CardList items={[
196 {
197 href: "/commerce-modules/customer",
198 title: "Customer Module",
199 text: "Learn about the Customer Module and its features.",
200 icon: AcademicCapSolid,
201 },
202 {
203 href: "/commerce-modules/pricing",
204 title: "Pricing Module",
205 text: "Learn about the Pricing Module and its features.",
206 icon: AcademicCapSolid,
207 },
208 {
209 href: "!docs!/learn/fundamentals/events-and-subscribers",
210 title: "Create a Subscriber",
211 text: "Learn how to create a subscriber in Medusa.",
212 icon: AcademicCapSolid,
213 },
214 {
215 href: "/references/events",
216 title: "Events Reference",
217 text: "Check out triggered events by each Commerce Module.",
218 icon: AcademicCapSolid,
219 },
220 ]} />
221
222 ---
223
224 ## Marketing Automation
225
226 In your commerce store, you may utilize marketing strategies that encourage customers to make purchases. For example, you send a newsletter when new products are added to your store.
227
228 To do that, create a subscriber that listens to the `product.created`, and send an email to subscribed customers with tools like [SendGrid](../../infrastructure-modules/notification/sendgrid/page.mdx).
229
230 You can also create a scheduled job that checks whether the number of new products has exceeded a set threshold, then sends out the newsletter.
231
232 <CardList items={[
233 {
234 href: "!docs!/learn/fundamentals/events-and-subscribers",
235 title: "Create a Subscriber",
236 text: "Learn how to create a subscriber in Medusa.",
237 icon: AcademicCapSolid,
238 },
239 {
240 href: "!docs!/learn/fundamentals/scheduled-jobs",
241 title: "Scheduled Jobs",
242 text: "Learn how to create a scheduled job in Medusa.",
243 icon: AcademicCapSolid,
244 },
245 ]} />