Learn how to trigger WorqHat workflows by sending JSON data
Trigger WorqHat workflows by sending JSON data to them, allowing you to integrate workflow automation with your applications and respond to events in real-time.
Copy
POST https://api.worqhat.com/api/workflows/trigger/{workflow-id}
This endpoint allows you to start a workflow execution by sending structured JSON data. The workflow processes this data according to the steps youβve defined in the WorqHat Workflow Builder, enabling automation based on your specific business logic.
The JSON data to send to the workflow. This can be any valid JSON object structure that your workflow is designed to process.Example: Customer data, order information, configuration settings, etc.
This example shows how to trigger a workflow that processes new customer information.
Copy
import Worqhat from 'worqhat';// Initialize the WorqHat clientconst client = new Worqhat({ apiKey: process.env.WORQHAT_API_KEY, // Always use environment variables for API keys});// Customer data to be processed by the workflowconst customerData = { name: "Jane Smith", email: "jane.smith@example.com", plan: "premium", company: "Acme Inc.", preferences: { notifications: true, newsletter: false, productUpdates: true }};async function onboardNewCustomer() { try { // Trigger the onboarding workflow with customer data const response = await client.flows.triggerWithPayload( 'workflow-id-for-customer-onboarding', { body: customerData } ); console.log(`Onboarding workflow started! Tracking ID: ${response.analytics_id}`); // You can store this analytics_id to check the status later return response; } catch (error) { console.error('Error triggering onboarding workflow:', error); // Handle the error appropriately }}onboardNewCustomer();
Triggering workflows with JSON payloads provides a flexible way to integrate WorqHatβs automation capabilities into your applications. By following the patterns and practices outlined in this guide, you can create powerful, event-driven systems that respond to your business needs in real-time.For more advanced use cases, consider exploring workflow chaining (triggering workflows from other workflows) and combining JSON payload triggers with file upload triggers for comprehensive data processing solutions.