When building automated systems and leveraging the power of the .do platform, a key decision often arises: how should you initiate your workflows and actions? Two common methods are using traditional APIs and utilizing Trigger.do. While seemingly similar at first glance, they serve distinct purposes and are best suited for different use cases.
This post will explore the differences between using a standard API call and employing Trigger.do, helping you choose the right method for igniting your business logic.
APIs (Application Programming Interfaces) are the backbone of modern software development. They provide a structured way for different software applications to communicate with each other. When you make an API call, you are typically interacting directly with a specific function or endpoint, expecting a synchronous response.
Think of it like ordering food from a restaurant's menu (the API). You choose a specific dish (the endpoint), place your order (the API call), and wait for your food to be prepared and delivered (the synchronous response).
APIs are excellent for:
Trigger.do, on the other hand, is specifically designed to initiate workflows and complex business logic within the .do platform. Instead of calling a specific function directly, you are signaling an event that kicks off a predefined series of actions or a complete workflow.
Imagine Trigger.do as pressing a button that starts a complex assembly line. You press the button (trigger the event), and the assembly line (the workflow) begins its automated process, potentially involving multiple steps and systems. You don't necessarily need an immediate, synchronous response to the trigger itself; the value lies in the automated execution of the workflow that follows.
The example above demonstrates how simple it is to use the .do SDK to trigger a workflow programmatically. You specify the workflow ID and can pass relevant data that the workflow can then utilize.
Trigger.do excels at:
The choice between using an API call and Trigger.do boils down to the nature of the action you want to initiate:
Feature | API Call | Trigger.do |
---|---|---|
Purpose | Perform a specific, self-contained action | Initiate a workflow or complex business logic |
Response | Typically synchronous | Often asynchronous |
Complexity | Usually simple, direct interaction | Ignites potentially complex, multi-step processes |
Use Cases | Data retrieval, simple actions | Workflow automation, event-driven systems |
Execution | Executes the called function directly | Kicks off a pre-defined workflow |
Choose an API when:
Choose Trigger.do when:
Trigger allows you to initiate workflows or specific actions within the .do platform. It acts as the starting point for your automated business logic.
You can trigger workflows based on various events, such as user actions, data changes, external system notifications, or scheduled intervals.
Yes, you can pass relevant data along with the trigger event using the SDK. This data can then be accessed and used within your triggered workflow.
The .do SDK provides a simple and intuitive way to integrate triggering functionality into your applications, allowing for programmatic control over your workflows.
Trigger.do is a powerful tool for automating your business logic and igniting your AI-powered applications on the .do platform. By understanding the distinction between traditional API calls and workflow triggering, you can choose the most efficient and appropriate method for orchestrating your automated processes.
Start exploring the possibilities of triggering workflows and streamlining your operations with Trigger.do today!
import { trigger } from '@dotdo/sdk';
const result = await trigger('your_workflow_id', {
data: { userId: '123', eventType: 'login' }
});
console.log(result);