How-toRecipes for one specific task, for when you know the basics and have a goal.

Send SMS to Units with LEKAB

This guide sends SMS messages through the LEKAB SMS API to units in your Bosbec account. It uses one workflow with two triggers: one to send messages to selected units, and one to update each message's delivery status.

The sending workflow finds units with the send_sms metadata value set to true. It sends one message to each unit's phone number, then clears that flag so the unit is not selected again on the next run.

Create the recipient units first. You can import them from a CRM, PBX, or another system with POST Units to HTTP-in, or add them manually in the admin platform. Each recipient must have a phone number.


GET STARTED FOR FREE


What you will build

Trigger Purpose
Send SMS Sends an SMS to every selected unit and saves the LEKAB message ID and initial status.
Update status Retrieves the current status for messages that have not reached a final state.

Each unit that receives an SMS uses these metadata fields:

Metadata key Value or purpose
send_sms Set to true to select the unit for the next sending run. The workflow changes it to false after sending.
message_id The message ID returned by LEKAB.
message_status The most recently returned LEKAB status.
message_status_final false while the workflow should continue checking the message status.

Before you start

Import the workflow

Open Workflow Builder and navigate to View > Workflow Library.

Import Lekab: Send SMS via API. The workflow contains the LEKAB requests and unit-processing logic for both the Send SMS and Update status triggers.

If you created your account using the button on this page, you may already have selected these templates when launching Workflow Builder and can skip this step.

Add the LEKAB credentials

In Workflow Builder, open Edit > Workflow Settings and select Custom Settings & Secrets. Scroll to the bottom and add the following secrets:

Key Value
lekab_username Your LEKAB SMS API username
lekab_password Your LEKAB SMS API password

The workflow builds its Basic Authentication header from these secrets. Keep the credentials in workflow secrets rather than writing them into an HTTP request job.

Save and make sure the workflow is active when the configuration is complete.

Select recipients and send SMS

Set the send_sms metadata value to true on every unit that should receive the next message. You can set it when creating units with the POST Units to HTTP-in workflow, manually in the admin platform, or through another workflow.

Run the Send SMS trigger. It finds all units where send_sms equals true, then processes each one in a For Each Resource loop.

For each recipient, the workflow creates Basic Authentication from the configured secrets and sends a request to:

https://secure.lekab.com/restsms/api/send

The request body has this shape:

{
  "from": "Bosbec",
  "to": [
    "{{recipient.phone}}"
  ],
  "message": "Hello!",
  "checknumber": true
}

Update the from and message values in the workflow before sending a production message. The exact message content depends on your use case and consent requirements.

After each request, the workflow updates the unit with the LEKAB message ID, sets message_status to QUEUED, sets message_status_final to false, and changes send_sms to false. Clearing the selection flag prevents the same unit from being included by the next sending run.

Update delivery statuses

Run the Update status trigger after sending messages. It finds units where message_status_final equals false, then checks the current status for each unit's saved message ID.

For each unit, it sends this request to:

https://secure.lekab.com/restsms/api/status
{
  "id": ["{{current_check.metadata.message_id}}"]
}

The workflow always updates message_status with LEKAB's returned status. For QUEUED, SENT, SCHEDULED, and UNKNOWN, it leaves message_status_final as false so that a later run checks again. Any other status is treated as final and changes message_status_final to true.

Schedule the Update status trigger to run at regular intervals after a sending run. This lets it continue tracking messages until LEKAB returns a final status.

Use the saved message status

The message ID and status are stored on each recipient unit, so another workflow or service can use them. For example, adapt GET Units from HTTP-in to return recipient names, phone numbers, and message_status values through an endpoint.

Because the status is stored on the unit, the API can return the latest known delivery state without calling LEKAB for every request.

Limitations

This base version does not handle rejected SMS messages or failed requests to LEKAB. It also stores one message status per recipient, so sending a new message replaces the previous message ID and status.

To extend the solution, add a route for failed or rejected responses and save each message in a separate unit or resource. LEKAB also supports status checks for multiple message IDs in one request, which can reduce the number of API calls for large recipient lists.


GET STARTED FOR FREE