> For the complete documentation index, see [llms.txt](https://docs.eximee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eximee.com/documentation/documentation-en/eksploatacja-aplikacji/obsluga-zdarzen/lowcode-do-kafki.md).

# Low-code to Kafka

{% hint style="info" %}
Availability of functionality depends on the license and may not be available in all deployments.
{% endhint %}

## Purpose

Enabling sending messages to a specified Kafka instance and specified topic directly from requests (scripts) and BPMN processes (script tasks).

## Usage examples

* Updating data in the data warehouse
* Notifying CRM about process status changes
* Communication with external systems (e.g. the bank's systems)

## Use in a script/script task

> Note that the Kafka instance name ("kafkaid" in the example) must be written in lowercase and without special characters.

```js
try {
    api.events.v1.publishAsync(
        "kafkaid",                  // Kafka instance name (configured by the administrator, written only in lowercase letters, without special characters)
        "topicName",                // topic name (configured by the administrator)    
        {                           // message content – must be valid JSON
            "id": "123",
            "status": {
                "code": "OK",
                "message": "Everything is fine!"
            },
            "list": [1, 2, 3],
            "boolean": true,
            "date": new Date()
        },
        "key",                      // message key (optional – it should be assigned if we need to preserve the order of events)
        {                           // headers (optional)
            "header1": "header1-value",
            "header2": "header2-value"
        }
    );
} catch (e) {
    // error handling
}
```

## Important information

* Sending is asynchronous – the script does not wait for confirmation of message delivery
* Remember to handle exceptions. The function may throw an error if there is no connection to Kafka or if the message buffer for sending in the application overflows
* Successful execution of the function confirms that the message has been added to the buffer, but does not guarantee error-free sending of the message. We are unable to catch errors from the sending itself
* The message content must be valid JSON – the passed object is automatically serialized
* The key is optional, but recommended when you care about the order of messages within a single partition
* The sending timeout is configured by the administrator – it cannot be changed from the script
* Topics are created and managed by administrators
* `kafkaId` must match the name of the Kafka instance configured in the application


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.eximee.com/documentation/documentation-en/eksploatacja-aplikacji/obsluga-zdarzen/lowcode-do-kafki.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
