Commerce Automation Recipe Soon

This recipe provides the general steps to implement commerce automation with Medusa.

Overview#

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.

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.


Re-Stock Notifications#

Customers may be interested in a product that is currently out of stock.

To implement sending restock notifications, you can:

  • Create a module that manages the customers subscribed to a variant's restock notification.
  • Create relationships to the Product and Sales Channel modules. A variant's inventory is managed by the sales channel's associated stock locations.
  • Create an API route that allows customers to subscribe to a variant's restock notification.
  • Create a subscriber that listens to the inventory-item.updated event and sends a notification to the subscribed customers if the variant's quantity is more than 0.
Coming soonThe inventory-item.updated event is currently not emitted.
Create a Module
Learn how to create a module in Medusa.
Create a Data Model
Learn how to create a data model.
Create an API Route
Learn how to create an API route in Medusa.
Create a Subscriber
Learn how to create a subscriber in Medusa.
Example

Automated Customer Support#

Customer support is essential to build a store's brand and customer loyalty. This can include integrating with third-party services or automating notifications sent to customers when changes happen related to their orders, returns, exchanges, and more.

You can use the Notification Module to send notifications when an action is triggered, such as when a customer or their order is updated.

Medusa also provides Notification Module Providers that integrate with third-party services, such as SendGrid.

Notification Module
Learn about the Notification Module.
Create Subscriber
Learn how to create a subscriber to handle events.

Automatic Data Synchronization#

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.

To implement that:

  • Create a workflow that implements the synchronization steps, along with retry and rollback logic.
  • Create a scheduled job that executes the workflow automatically at the specified time pattern.
Create a Scheduled Job
Learn how to create a scheduled job in Medusa.
Example: Synchronizing products with a third-party service

Order Management Automation#

Using Medusa's architecture and commerce features, you can automate a large amount of order management functionalities.

To handle events within an order flow and automate actions, create a subscriber. For example, create a subscriber that listens to the order.placed event and automatically creates a fulfillment if predefined conditions are met.

Coming soonThe order.placed event is currently not emitted.
Create a Subscriber
Learn how to create a subscriber in Medusa.

Automated RMA Flow#

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.

Medusa's commerce features are geared towards automating RMA flows and ensuring a good customer experience:

  • Customers can create order returns from the storefront. Merchants then receive a notification and handle the return from the Medusa Admin.
  • Merchants can make order changes and request the customer's approval for them. The customer can also send any additional payment if necessary.
  • 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.
Order Module
Learn about the Order Module and its features.
Create a Subscriber
Learn how to create a subscriber in Medusa.

Customer Segmentation#

Businesses use customer segmentation to organize customers into different groups and then apply different price rules to these groups.

Medusa's commerce modules provide the necessary features to implement this use case:

  • The Customer Module provides a customer groups feature to organize customers into customer groups.
  • The Pricing Module provides the features to specify prices based on a condition, such as the group of the customer.

For example, to group customers with over twenty orders:

  1. Create a subscriber that listens to the order.placed event.
  2. If the customer has more than 20 orders, add them to the VIP customer group.
Coming soonThe order.placed event is currently not emitted.
Customer Module
Learn about the Customer Module and its features.
Pricing Module
Learn about the Pricing Module and its features.
Create a Subscriber
Learn how to create a subscriber in Medusa.
Example: Add customer to VIP group

Marketing Automation#

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.

To do that, create a subscriber that listens to the product.created, and send an email to subscribed customers with tools like SendGrid or Mailchimp.

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.

Create a Subscriber
Learn how to create a subscriber in Medusa.
Scheduled Jobs
Learn how to create a scheduled job in Medusa.
Example: Sending a newsletter email after adding ten products
Was this page helpful?
Edit this page