Class FeishuInboundMapper
java.lang.Object
io.agentscope.extensions.channel.feishu.FeishuInboundMapper
Parses a decrypted Feishu Event Subscription v2 envelope into an
InboundMessage.
Schema 2.0 envelope shape:
{
"schema": "2.0",
"header": {"event_id":"...","event_type":"im.message.receive_v1","tenant_key":"...", ...},
"event": {
"sender": {"sender_id":{"open_id":"...","user_id":"...","union_id":"..."}, "sender_type":"user"},
"message": {
"message_id":"om_...",
"chat_id":"oc_...",
"chat_type":"p2p|group",
"message_type":"text|...",
"content":"{\"text\":\"@_user_1 hello\"}"
}
}
}
Text messages (message_type=text) map to their content; the inner content
field is a JSON-encoded string and is re-parsed to read the text field. Media messages
(image / file / folder / audio / media) map to a
neutral marker text plus the ChannelMediaMetadata contract: the image_key /
file_key material identifiers and per-kind metadata are preserved verbatim, and
fetching the bytes (a token-authenticated message-resource download) is left to the
application. Other message types (post, sticker, interactive, share cards, ...) are returned
as Optional.empty() so the caller can ack without dispatching.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionextractEventId(com.fasterxml.jackson.databind.JsonNode envelope) Returns theheader.event_id, used by the idempotency store.extractSenderOpenId(com.fasterxml.jackson.databind.JsonNode envelope) Returns theevent.sender.sender_id.open_idfor bot-loop self-detection.extractTenantKey(com.fasterxml.jackson.databind.JsonNode envelope) Returns theheader.tenant_key(multi-tenant id).extractUrlChallenge(com.fasterxml.jackson.databind.JsonNode envelope) Returns the URL verification challenge if the envelope is a verification request.Optional<io.agentscope.harness.agent.gateway.channel.InboundMessage>map(com.fasterxml.jackson.databind.JsonNode envelope) Maps a decrypted Schema 2.0 envelope into anInboundMessage.
-
Constructor Details
-
FeishuInboundMapper
-
-
Method Details
-
extractEventId
Returns theheader.event_id, used by the idempotency store. -
extractUrlChallenge
public static Optional<String> extractUrlChallenge(com.fasterxml.jackson.databind.JsonNode envelope) Returns the URL verification challenge if the envelope is a verification request. -
extractSenderOpenId
public static Optional<String> extractSenderOpenId(com.fasterxml.jackson.databind.JsonNode envelope) Returns theevent.sender.sender_id.open_idfor bot-loop self-detection. -
extractTenantKey
Returns theheader.tenant_key(multi-tenant id). -
map
public Optional<io.agentscope.harness.agent.gateway.channel.InboundMessage> map(com.fasterxml.jackson.databind.JsonNode envelope) Maps a decrypted Schema 2.0 envelope into anInboundMessage. Text messages map to their content; media messages map to a neutral marker plusChannelMediaMetadataentries. Returns empty for other message types or malformed events so the caller can ack without dispatching.
-