External Webhook Call Handling in DRUID
The /GenericIntegration
endpoint allows external webhooks to send requests to DRUID, triggering a connector integration to process the data. When a webhook call is received, DRUID extracts key request details—such as query parameters, headers, and the request body—and stores them in predefined entity fields. The system then executes the specified integration and returns a response.
This enables flexible automation by allowing developers to configure Custom Code integrations that process incoming data and generate tailored responses. By leveraging this feature, you can interact with external systems efficiently while maintaining structured data handling within the DRUID platform.
Limitations
- Supports only the POST method.
- Accepts only bearer tokens (permanent or short-lived) generated in the Webhooks > Authentication tab. For more information, see Webhooks.
Prerequisites
Before using this endpoint, ensure that the entity where the integration will be executed includes the following fields:
Field Name | Data Type | Description |
---|---|---|
RequestParams | String | Stores the query parameters as a string. |
RequestBody | JObject | Stores the request body. |
RequestHeaders | String | Stores request headers as a concatenated string in URL query format (headerKey1=value1&headerKey2=value2). |
ResponseBody | JObject | Stores the response data returned to the external webhook. |
Syntax
POST https://<tenant_name>.druidplatform.com/api/Druid/<BotId>/<entityName>/<integrationId>/GenericIntegration?<QueryParams>
Where:
-
<tenant_name>
and<BotId>
are automatically filled when you copy the URL from Webhooks > Druid. - Replace
<entityName>
with the name of the entity where the integration was created. - Replace
<integrationId>
with the ID of the connector action you want to execute in DRUID.
Request
You can send query parameters, additional headers, and a request body (in text or JSON format) with your request.
To include query parameters, add them to the request URL after the ? symbol, using the following format:
POST https://<tenant_name>.druidplatform.com/api/Druid/<BotId>/<entityName>/<integrationId>/GenericIntegration?Parameter1=value&Parameter2=value&...
When DRUID receives a request through this endpoint, it processes the request as follows:
- Extracts {entityName} from the URL path.
- Performs the integration having the ID provided in the request URL.
- Captures and stores request components in dedicated DRUID entity fields:
- RequestParams: Stores query parameters.
- RequestBody: Stores the request body.
- RequestHeaders: Stores request headers as a concatenated string.
To use the received data in DRUID, create a Custom Code integration and process the data as needed.
Response
By default, the API call response is stored in ResponseBody (JObject). The entire response payload is sent to the external webhook. You can modify the Custom Code integration to send specific text or data.
The following example updates the response entity with specific data before sending it back to the webhook.
Example: Custom Code to Send Data Back to the External Webhook
// Default Custom Code snippet
(function main() {
// Retrieve the request entity
let requestEntity = Context.GetRequestEntity();
// Handle case where the request entity is not initialized
if (requestEntity == null) {
Context.RaiseError("No entity", "Request entity is null");
}
// Modify request entity fields as needed
requestEntity.Name = JSON.stringify(requestEntity.RequestBody);
requestEntity.ResponseBody = {
"Street": "Costache Negri",
"Town": "Bucuresti",
"Building": "Opera Center"
};
// Set the response entity
Context.SetResponseEntity(requestEntity);
})();
The following example sends an acknowledgment response instead of a data payload, providing the external webhook with confirmation that DRUID successfully processed the request.
Example: Custom Code to Send an Acknowledgment Message
// Custom Code to send an acknowledgment response
(function main() {
// Retrieve the request entity
let requestEntity = Context.GetRequestEntity();
// Handle case where the request entity is not initialized
if (requestEntity == null) {
Context.RaiseError("No entity", "Request entity is null");
}
// Send an acknowledgment message
requestEntity.ResponseBody = {
"status": "success",
"message": "The data was received successfully."
};
// Set the response entity
Context.SetResponseEntity(requestEntity);
})();