There are two main types of triggers: Schedule and API endpoint. The Schedule trigger also supports adding custom conditions (e.g., run the workflow only if new emails are available).
Schedule:
CRON expressions are used to schedule workflow triggers. You can also add custom conditions.
API:
Triggering a workflow:
POST/workflows/{id}/jobs
To trigger a workflow via API, send a POST request to https://api.trudo.ai/workflows/{workflow_id_here}/jobs with the required data. This will start the workflow and return a job ID, which can be used to monitor the workflow's status.
To receive the API call results, set the system variable wait_for_result to true. Keep in mind that wait_for_result is not forwarded to the workflow itself.
To return an API response from the node, use the api_response key like this:
return { 'api_response': your_data_here }
The maximum size of the input and output data is limited to 200 KB.
Headers
Name
Value
Content-Type
application/json
Authorization
Bearer <api_key>
Body
Name
Type
Description
wait_for_result
boolean
optional (default: False)
... your own variables
Include on same level
Response
{
"job_id": "new_job_id", // use this job_id to check status
"status": "COMPLETED", // PENDING | RUNNING | FAILED | COMPLETED
"data": {
// your data from the api_response will be included here.
}
}
{
"statusCode": 400,
"body": "Unsupported method or path"
}
{
"statusCode": 403,
"body": "Authorization failure. Please check the API key."
}
{
"statusCode": 404,
"body": "error_message_here"
}
example errors:
- Endpoint with this workflowId is not deployed.
- Please provide a valid workflow_id: /workflows/{workflow_id}/jobs
{
"statusCode": 500,
"body": "Something went wrong, please try again later."
}
Python sample
import requests
# Sample data based on listOfParameters
data = {
#wait_for_result is a system variable, not passed to the workflow
"wait_for_result": True,
#... include the rest of your parameters below. Samples
"user_id": "3298fh3298dsa",
"message": "Please renew my membership"
}
# API endpoint
api_endpoint = "https://api.trudo.ai/workflows/{workflow_id}/jobs"
# Headers
headers = {
"content-type": "application/json",
"authorization": "Bearer YOUR_API_KEY"
}
# Make the POST request
response = requests.post(api_endpoint, json=data, headers=headers)
# Check if the request was successful
if response.status_code == 200:
print("Success:", response.json())
else:
print("Error:", response.text)
Get job's results and status:
GET/workflows/{id}/jobs/{id}
To get the status and output of a workflow job , send a GET request to https://api.trudo.ai/workflows/{workflow_id_here}/jobs/{job_id}
Headers
Name
Value
Content-Type
application/json
Authorization
Bearer <api_key>
Response
{
"job_id": "job_id", // use this job_id to check status
"status": "COMPLETED", // PENDING | RUNNING | FAILED | COMPLETED
"data": {
// your data from the api_response will be included here.
}
}
{
"statusCode": 400,
"body": "Unsupported method or path"
}
{
"statusCode": 403,
"body": "Authorization failure. Please check the API key."
}
{
"statusCode": 404,
"body": "error_message_here"
}
example errors:
- Endpoint with this workflowId is not deployed.
- Please provide a valid workflow_id: /workflows/{workflow_id}/jobs
{
"statusCode": 500,
"body": "Something went wrong, please try again later."
}
import requests
# API endpoint
api_endpoint = f"https://api.trudo.ai/workflows/{workflow_id}/jobs/{job_id}"
# Headers
headers = {
"content-type": "application/json",
"authorization": "Bearer YOUR_API_KEY"
}
# Make the GET request
response = requests.get(api_endpoint, headers=headers)
# Check if the request was successful
if response.status_code == 200:
print("Job Status:", response.json())
else:
print("Error:", response.text)