API Integration
Overview
In LemmeBuild, you can use your workflows as APIs, enabling you to trigger actions directly from your frontend. This guide walks you through how to copy the API endpoint, configure access settings, send and receive data, and structure your API responses.
Setting Up API Access
- Edit Workflow: Click the Edit button on your workflow in LemmeBuild.
- Copy the API Endpoint: Once inside the workflow editor, you can find and copy the API endpoint for triggering the workflow.
- Configure Access Settings:
- Choose the appropriate access level for the API, depending on your use case:
- Public: Anyone can trigger the API.
- Private: Only team members can trigger the API.
- Choose the appropriate access level for the API, depending on your use case:
Sending Data to the Workflow
Once you’ve set the access level and obtained the API endpoint, you can trigger the workflow using standard HTTP methods from your frontend (e.g., GET
or POST
).
When sending data to the LemmeBuild API, ensure you structure your payload properly. You can send custom parameters that can be accessed inside your workflow using the $trigger
object.
Example: Sending Data to LemmeBuild via POST
Here’s an example of sending data from your frontend using a POST
request:
fetch('https://your-lemmbuild-endpoint.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'John Doe',
age: 25,
}),
});
Receiving Data in the Workflow
To receive the data sent from the frontend in your LemmeBuild workflow, you’ll use the $trigger
object.
For example, if you send parameters like name
and age
from the frontend, you can access them in the workflow using the following syntax:
- Accessing parameters:
{{$trigger.name}}
— For thename
field.{{$trigger.age}}
— For theage
field.
You can use these parameters dynamically within your workflow blocks to process or respond to the data.
Structuring API Responses
The Result Block is used to structure the response sent back to your frontend. Make sure to set the response format according to what your frontend expects (JSON, text, etc.).
Example: JSON Response in the Result Block
In the Result Block, you can structure your API response like this:
{
"status": "success",
"message": "Workflow executed successfully",
"data": {
"processedName": "{{$state.processedName}}",
"processedAge": "{{$state.processedAge}}"
}
}
The response will then be sent back to the frontend based on the result of the workflow.
Example Workflow Setup
- Trigger a Workflow from your frontend using the API endpoint and appropriate access level.
- Send Data to the workflow using
POST
orGET
methods. - Access Data within the workflow using the
$trigger
object. - Return a Response using the Result Block, structuring the response as per your frontend's needs.
With the API Integration feature in LemmeBuild, you can seamlessly trigger workflows from the frontend, pass dynamic data, and return structured responses, enabling powerful automation and integration with external systems.