Skip to main content
When a moderation rule uses OpenAI or your own Custom API, CometChat calls that engine for every matching message. If the engine cannot return a usable decision, CometChat sends a moderation_engine_failed webhook describing what went wrong.
This event is additional. It does not replace moderation_engine_approved or moderation_engine_blocked — you still receive the usual decision event for the same message.

What happens to the message

A failure never changes how a message is handled. Your error-handling setting decides that, exactly as before — On OpenAI Error and On Custom API Error under Moderation → Settings → Advanced Settings.
Block Message applies the rule’s configured action, which is not always a block. If the rule’s action is to flag for review, a failure flags the message rather than blocking it, and outcome reads approved. The message is only blocked when the rule’s action list includes blocking.
The two settings are independent, so one app can approve on an OpenAI failure and block on a Custom API failure at the same time.

The response contract

There is no status code that means “block this message.” The only way to return a decision is HTTP 200 with a valid JSON body. Any non-2xx response is treated as a failure — CometChat does not read the body of a non-2xx response or infer meaning from its status.
A 400 from your endpoint does not mean “this content is bad”. It means your endpoint did not answer, and your On Custom API Error setting takes over.

Failure categories

Time limits are 2 seconds for Custom API and 5 seconds for OpenAI text moderation. OpenAI image moderation scales with the number of images — 5 seconds for the first, 3 seconds for each additional one, capped at 30 seconds.

Example payload

A Custom API endpoint that returned HTTP 500 while moderating an image.

Fields

data

failures[]

failures[].context

Fields are omitted, not null. Any field without a value is left out of the payload entirely. Check that a field exists before reading it — failures[0].context.request.url throws on an OpenAI failure, because OpenAI failures carry no request object.

Reading the payload correctly

One event per moderation pass

All failures from a single pass arrive in one event, in failures[] — not one event per failure. Two failing rules produce one event with two entries. A message can still produce two events when it is moderated twice. An image with a caption goes through text moderation and then image moderation, and each pass reports separately. Use contentType to tell them apart. Because Block Message stops evaluation at the first failure, failures[] holds what actually ran, not everything configured.

responseBody is opaque text

It is capped at 2 KB and may be cut mid-string, so it is not guaranteed to be valid JSON even when your endpoint returned JSON. responseBodyTruncated tells you when it was cut. Treat it as text for diagnostics — do not parse it.

When no event is sent

Only a failure of the engine itself produces this event. Problems on the CometChat side do not:

Enabling the event

Enable it in the CometChat Dashboard under:
Application → Webhooks → Create Webhook → Triggers → Moderation
Basic Auth and retry-on-failure work exactly as they do for your other webhooks.