Skip to main content

Pre-messaging

Pre-messaging events fire before a message is delivered to its recipients. Your server receives the pending message and can respond to modify its content, push settings, or metadata, or to block delivery entirely.

There are four event types — one per channel type — but they all share the same payload structure.

note

Pre-messaging events require a Chat Pro plan. The option is disabled in the console if your app does not qualify.

For the complete webhook setup and signature verification guide, see Webhooks overview.

Event types

Event typeChannel
direct_channel:pre_messagingDirect channel (one-to-one)
group_channel:pre_messagingGroup channel
open_channel:pre_messagingOpen channel
community_channel:pre_messagingCommunity channel

How it works

Pre-messaging events are synchronous. Nexconn waits for your server's response (up to 5 seconds) before deciding whether to proceed with message delivery.

Your server responds with a JSON body containing a required pass field to control delivery:

Response actionHow to signal it
Allow delivery unchangedReturn HTTP 200 with pass set to 1 or 2. Omit modification fields to leave original values.
Modify the messageReturn HTTP 200 with pass set to 1 or 2, plus the fields you want to override (see Response fields).
Block deliveryReturn HTTP 200 with pass set to 0. Include extra to pass data back to the sender.

If your server does not respond within 5 seconds, Nexconn retries up to 2 times. If all attempts time out, the message is not delivered.

Payload

Envelope

FieldTypeRequiredDescription
typeStringYesOne of the four event types listed above.
idStringYesUnique event ID.
timeLongYesEvent generation time (Unix ms).
dataArrayYesArray containing one pre-messaging object. See Data fields.

Data fields

FieldTypeRequiredDescription
appKeyStringYesThe App Key for the application.
userIdStringYesThe sender's user ID.
channelIdStringYesTarget channel ID: recipient user ID (direct), group ID, open channel ID, or community channel ID.
channelTypeNumberYesChannel type. See Channel types.
messageTypeStringYesMessage type identifier (e.g., RC:TxtMsg, RC:ImgMsg).
contentStringYesMessage content body as a JSON string.
timeLongYesTime the server received the message (Unix ms).
messageIdStringYesUnique message identifier.
osStringYesSender's platform. One of: iOS, Android, Websocket, Server.
pushContentStringNoPush notification text.
disablePushBooleanNoWhether push notifications are suppressed for this message.
pushConfigStringNoExtended push configuration as a JSON string.
isMetadataBooleanNoWhether the message supports metadata expansion.
metadataObjectNoMessage metadata key-value pairs.
groupUserIdsString[]NoRecipient user IDs for targeted group messages. Only present for directed messages.
originalMessageIdStringNoOriginal message ID. Only present in community channels.
subchannelIdStringNoCommunity channel subchannel ID. Only present in community channels.
clientIpStringNoThe sender's IP address and port.
aiGeneratedBooleanNoWhether the message was generated by AI. Only returned when the feature is enabled.

Response fields

FieldTypeRequiredDescription
passIntYesDelivery control. 0 = block delivery. 1 = allow delivery and continue remaining callbacks. 2 = allow delivery and skip remaining callbacks.
replaceContentStringNoReplacement message content (JSON structure). Supports up to six levels of nesting. Empty string or omitted = keep original.
replacePushContentStringNoReplacement push notification text. Empty string or omitted = keep original.
replaceDisablePushBooleanNoSilent message override. true = suppress offline push notifications. Defaults to false.
replacePushConfigStringNoReplacement push configuration (JSON string). Keep ≤ 1.5 KB. Empty string or omitted = keep original.
replaceMetadataObjectNoReplaces extraMetadata. Format: {"key": {"v": "value"}}. Key ≤ 32 chars, value ≤ 4096 chars.
extraStringNoData returned to the sender via the client's sensitive-message interception callback. Valid only when pass is 0. Max 1024 chars.

Example

Response

JSON
{
"pass": 1,
"replaceContent": "{\"content\":\"Hello [*** replaced]\"}",
"replacePushContent": "You have a new message",
"replaceDisablePush": false,
"replacePushConfig": "{\"pushTitle\":\"System notification\"}",
"replaceMetadata": {
"ai_reviewed": {
"v": "true",
"t": 1710652800
}
}
}

direct_channel:pre_messaging

JSON
{
"type": "direct_channel:pre_messaging",
"id": "550e8400-e29b-41d4-a716-446655440008",
"time": 1730192400000,
"data": [
{
"appKey": "your_app_key",
"userId": "user_001",
"channelId": "user_002",
"channelType": 1,
"messageType": "RC:TxtMsg",
"content": "{\"content\":\"Hello\",\"extra\":\"\"}",
"pushContent": "user_001: Hello",
"disablePush": false,
"pushConfig": "{}",
"isMetadata": false,
"time": 1730192400000,
"messageId": "msg_pre_001",
"os": "iOS",
"clientIp": "192.168.1.100:12345"
}
]
}