Set Up Automatic Processing
Automating processes within your business can boost efficiency and reduce manual workloads. This page shows you how to set up automated processing using Appsmith Workflows.
Prerequisites
Before you begin, make sure you have:
- A self-hosted Appsmith instance with a business subscription. Refer to the Appsmith installation guides for detailed instructions if you need to set up your instance. You can also get a trial license by signing up on customer.appsmith.com.
- Basic knowledge of creating a basic workflow in Appsmith. If you're new to Workflows, follow the Tutorial - Create Basic Workflow to learn the workflow basics.
- Basic understanding of writing queries in workflows. For more information, see the Write Query to Send Email section.
Configure automated processing
-
Open your workflow and edit the Main JS Object under JS Objects.
-
Set up SQL queries or APIs to modify data based on automated processing requirements.
-
Replace the code in the Main JS Object with custom logic for automatic processing. For instance, the following snippet processes orders based on criteria like order value. If it's below $10, the workflow updates the record, processes a refund, and sends a notification email.
export default {
async executeWorkflow(order) {
// add custom logic to verify required parameters
if (order && order.order_id) {
console.log('Processing order: ' + order.order_id);
// Fetch order details using the provided order ID
const orderDetails = await getOrderDetails.run({ "order_id": order.order_id });
// Check if the order meets processing criteria
if (orderDetails && orderDetails.amount < 10) {
// Process refund
await initiateRefund.run({
"order_id": order.order_id,
"status": 'Refund Processed'
});
// Notify the customer
await notifyUser.run({
"user_email": orderDetails.customer_email,
"user_name": orderDetails.customer_name
});
}
}
}
} -
Trigger the workflow to process requests automatically. You can do this in one of the following ways:
- From within an Appsmith app - Create a workflow query with Trigger Workflow as the request type. Pass the required parameters for processing, and bind it to the action from where the triggering happens. For more information on triggering a workflow, see Trigger Workflow from Appsmith App guide.
- From an external system - Configure the webhook trigger in the workflow. Call the webhook through a POST request and pass the required parameters in the request body. For more information, see Trigger Workflow using REST Client.
-
Click Deploy in the top right to apply your changes.
-
Execute the workflow when relevant events occur, like a new order request.
Troubleshooting
If you face issues, contact the support team using the chat widget at the bottom right of this page.
See also
- Debug Workflow - Learn to debug workflows as you build them.
- Pass Parameters to Workflows - Learn how to pass parameters to workflows from the Appsmith app or external systems.
- Workflow Functions - Explore the variety of functions available for your workflows.