File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import {
3131 resolveMSTeamsUserAllowlist ,
3232} from "./resolve-allowlist.js" ;
3333import { getMSTeamsRuntime } from "./runtime.js" ;
34+ import { resolveMSTeamsOutboundSessionRoute } from "./session-route.js" ;
3435import { msteamsSetupAdapter } from "./setup-core.js" ;
3536import { msteamsSetupWizard } from "./setup-surface.js" ;
3637import { resolveMSTeamsCredentials } from "./token.js" ;
@@ -181,6 +182,7 @@ export const msteamsPlugin: ChannelPlugin<ResolvedMSTeamsAccount> = {
181182 setup : msteamsSetupAdapter ,
182183 messaging : {
183184 normalizeTarget : normalizeMSTeamsMessagingTarget ,
185+ resolveOutboundSessionRoute : ( params ) => resolveMSTeamsOutboundSessionRoute ( params ) ,
184186 targetResolver : {
185187 looksLikeId : ( raw ) => {
186188 const trimmed = raw . trim ( ) ;
Original file line number Diff line number Diff line change 1+ import {
2+ buildChannelOutboundSessionRoute ,
3+ stripChannelTargetPrefix ,
4+ stripTargetKindPrefix ,
5+ type ChannelOutboundSessionRouteParams ,
6+ } from "openclaw/plugin-sdk/core" ;
7+
8+ export function resolveMSTeamsOutboundSessionRoute ( params : ChannelOutboundSessionRouteParams ) {
9+ let trimmed = stripChannelTargetPrefix ( params . target , "msteams" , "teams" ) ;
10+ if ( ! trimmed ) {
11+ return null ;
12+ }
13+
14+ const lower = trimmed . toLowerCase ( ) ;
15+ const isUser = lower . startsWith ( "user:" ) ;
16+ const rawId = stripTargetKindPrefix ( trimmed ) ;
17+ if ( ! rawId ) {
18+ return null ;
19+ }
20+ const conversationId = rawId . split ( ";" ) [ 0 ] ?? rawId ;
21+ const isChannel = ! isUser && / @ t h r e a d \. t a c v 2 / i. test ( conversationId ) ;
22+ return buildChannelOutboundSessionRoute ( {
23+ cfg : params . cfg ,
24+ agentId : params . agentId ,
25+ channel : "msteams" ,
26+ accountId : params . accountId ,
27+ peer : {
28+ kind : isUser ? "direct" : isChannel ? "channel" : "group" ,
29+ id : conversationId ,
30+ } ,
31+ chatType : isUser ? "direct" : isChannel ? "channel" : "group" ,
32+ from : isUser
33+ ? `msteams:${ conversationId } `
34+ : isChannel
35+ ? `msteams:channel:${ conversationId } `
36+ : `msteams:group:${ conversationId } ` ,
37+ to : isUser ? `user:${ conversationId } ` : `conversation:${ conversationId } ` ,
38+ } ) ;
39+ }
You can’t perform that action at this time.
0 commit comments