AS AgentScopeAPI 手册 / API Reference

DingTalkInboundMapper

public final class DingTalkInboundMapper
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkInboundMapper.java:55–232

DingTalk 入站 Mapper,把智能体接入外部消息渠道与企业平台。位于 io.agentscope.extensions.channel.dingtalk 包。核心成员包括 map、extractMsgId、DingTalkInboundMapper。

Parses a DingTalk bot-message payload (Stream topic /v1.0/im/bot/messages/get or the HTTP callback body of the same protocol) into an InboundMessage.

Text messages (msgtype=text) map to their content. Media messages (picture / audio / video / file) map to a neutral marker text plus the ChannelMediaMetadata contract: the downloadCode and per-kind metadata are preserved verbatim, and exchanging the code for bytes (a server-side API call yielding a temporary download URL) is left to the application. Note the platform delivers audio/video/file to the robot in single chat only, not on group @-mention. richText and unknown types are returned as Optional#empty() so the caller can ack the event without dispatching to the agent.

Conversation kinds:

  • conversationType="1" → DM (PeerKind#DIRECT). Peer id = sender staff id.

  • conversationType="2" → group (PeerKind#GROUP). Peer id = conversation id.

Group messages typically arrive only when the bot is @-mentioned (DingTalk's bot SDK dispatches mention-triggered events only); the leading @bot text is preserved by the platform in text.content.

构造器摘要Constructor Summary

构造器Constructor说明Description
public DingTalkInboundMapper(String channelId, String accountId)
初始化 `DingTalkInboundMapper` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public Optional<InboundMessage> map(JsonNode payload)
设置映射。
Builds an `InboundMessage` from a DingTalk bot-message JSON payload.
public static Optional<String> extractMsgId(JsonNode payload)
static
设置该参数。
Returns the `msgId` field if present, used by the idempotency store.

构造器详情Constructor Detail

DingTalkInboundMapper

public DingTalkInboundMapper(String channelId, String accountId)

初始化 DingTalkInboundMapper 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
channelIdString渠道标识(类型 `String`)。The channel id.
accountIdStringaccount 标识(类型 `String`)。The account id.
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkInboundMapper.java:60–63

方法详情Method Detail

map

public Optional<InboundMessage> map(JsonNode payload)

设置映射。

Builds an InboundMessage from a DingTalk bot-message JSON payload.

参数Parameters
名称Name类型Type说明Description
payloadJsonNode负载(类型 `JsonNode`)。The payload.
返回Returns Optional<InboundMessage>
返回可选。Returns optional.
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkInboundMapper.java:71–80

extractMsgId

public static Optional<String> extractMsgId(JsonNode payload)
static

设置该参数。

Returns the msgId field if present, used by the idempotency store.

参数Parameters
名称Name类型Type说明Description
payloadJsonNode负载(类型 `JsonNode`)。The payload.
返回Returns Optional<String>
返回可选。Returns optional.
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkInboundMapper.java:217–223
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.