Skip to content

Commit bbbf1c2

Browse files
aadamgoughAdam Gough
andauthored
fix(teams-wh): fixed teams wh payload (#1119)
* first push * fixed variable res * lint --------- Co-authored-by: Adam Gough <[email protected]>
1 parent efc487a commit bbbf1c2

File tree

3 files changed

+81
-48
lines changed

3 files changed

+81
-48
lines changed

apps/sim/components/ui/tag-dropdown.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useSubBlockStore } from '@/stores/workflows/subblock/store'
1414
import { useWorkflowStore } from '@/stores/workflows/workflow/store'
1515
import type { BlockState } from '@/stores/workflows/workflow/types'
1616
import { getTool } from '@/tools/utils'
17-
import { getTriggersByProvider } from '@/triggers'
17+
import { getTrigger, getTriggersByProvider } from '@/triggers'
1818

1919
interface BlockTagGroup {
2020
blockName: string
@@ -104,8 +104,8 @@ const getOutputTypeForPath = (
104104
outputPath: string
105105
): string => {
106106
if (block?.triggerMode && blockConfig?.triggers?.enabled) {
107-
const triggers = getTriggersByProvider(block.type)
108-
const firstTrigger = triggers[0]
107+
const triggerId = blockConfig?.triggers?.available?.[0]
108+
const firstTrigger = triggerId ? getTrigger(triggerId) : getTriggersByProvider(block.type)[0]
109109

110110
if (firstTrigger?.outputs) {
111111
const pathParts = outputPath.split('.')
@@ -418,8 +418,10 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
418418
}
419419
} else {
420420
if (sourceBlock?.triggerMode && blockConfig.triggers?.enabled) {
421-
const triggers = getTriggersByProvider(sourceBlock.type)
422-
const firstTrigger = triggers[0]
421+
const triggerId = blockConfig?.triggers?.available?.[0]
422+
const firstTrigger = triggerId
423+
? getTrigger(triggerId)
424+
: getTriggersByProvider(sourceBlock.type)[0]
423425

424426
if (firstTrigger?.outputs) {
425427
// Use trigger outputs instead of block outputs
@@ -687,8 +689,10 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
687689
} else {
688690
const blockState = blocks[accessibleBlockId]
689691
if (blockState?.triggerMode && blockConfig.triggers?.enabled) {
690-
const triggers = getTriggersByProvider(blockState.type) // Use block type as provider
691-
const firstTrigger = triggers[0]
692+
const triggerId = blockConfig?.triggers?.available?.[0]
693+
const firstTrigger = triggerId
694+
? getTrigger(triggerId)
695+
: getTriggersByProvider(blockState.type)[0]
692696

693697
if (firstTrigger?.outputs) {
694698
// Use trigger outputs instead of block outputs

apps/sim/executor/handlers/trigger/trigger-handler.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ export class TriggerBlockHandler implements BlockHandler {
6363
}
6464
}
6565

66+
if (provider === 'microsoftteams') {
67+
const providerData = (starterOutput as any)[provider] || webhookData[provider] || {}
68+
// Expose the raw Teams message payload at the root for easy indexing
69+
const payloadSource = providerData?.message?.raw || webhookData.payload || {}
70+
return {
71+
...payloadSource,
72+
// Keep nested copy for backwards compatibility with existing workflows
73+
[provider]: providerData,
74+
webhook: starterOutput.webhook,
75+
}
76+
}
77+
6678
// Provider-specific early return for Airtable: preserve raw shape entirely
6779
if (provider === 'airtable') {
6880
return starterOutput

apps/sim/triggers/microsoftteams/webhook.ts

Lines changed: 58 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,50 +22,67 @@ export const microsoftTeamsWebhookTrigger: TriggerConfig = {
2222
},
2323

2424
outputs: {
25-
type: {
26-
type: 'string',
27-
description: 'Type of Teams message (e.g., message)',
28-
},
29-
id: {
30-
type: 'string',
31-
description: 'Unique message identifier',
32-
},
33-
input: {
34-
type: 'string',
35-
description: 'Input message',
36-
},
37-
timestamp: {
38-
type: 'string',
39-
description: 'Message timestamp',
40-
},
41-
localTimestamp: {
42-
type: 'string',
43-
description: 'Local timestamp of the message',
44-
},
45-
serviceUrl: {
46-
type: 'string',
47-
description: 'Microsoft Teams service URL',
48-
},
49-
channelId: {
50-
type: 'string',
51-
description: 'Teams channel ID where the event occurred',
52-
},
53-
from_id: {
54-
type: 'string',
55-
description: 'User ID who sent the message',
56-
},
57-
from_name: {
58-
type: 'string',
59-
description: 'Username who sent the message',
25+
// Expose the raw Teams message payload at the root for direct access
26+
id: { type: 'string', description: 'Raw message ID' },
27+
code: { type: 'string', description: 'Code (nullable)' },
28+
from: {
29+
id: { type: 'string', description: 'Sender ID' },
30+
name: { type: 'string', description: 'Sender name' },
31+
role: { type: 'string', description: 'Sender role (nullable)' },
32+
aadObjectId: { type: 'string', description: 'AAD Object ID' },
6033
},
61-
conversation_id: {
62-
type: 'string',
63-
description: 'Conversation/thread ID',
34+
name: { type: 'string', description: 'Top-level name (nullable)' },
35+
text: { type: 'string', description: 'Message HTML content' },
36+
label: { type: 'string', description: 'Label (nullable)' },
37+
speak: { type: 'string', description: 'Speak (nullable)' },
38+
value: { type: 'string', description: 'Value (nullable)' },
39+
action: { type: 'string', description: 'Action (nullable)' },
40+
locale: { type: 'string', description: 'Locale (e.g., en-US)' },
41+
summary: { type: 'string', description: 'Summary (nullable)' },
42+
callerId: { type: 'string', description: 'Caller ID' },
43+
entities: { type: 'array', description: 'Array of entities (clientInfo, ...)' },
44+
channelId: { type: 'string', description: 'Channel ID (msteams)' },
45+
inputHint: { type: 'string', description: 'Input hint (nullable)' },
46+
listenFor: { type: 'string', description: 'Listen for (nullable)' },
47+
recipient: { type: 'string', description: 'Recipient (nullable)' },
48+
relatesTo: { type: 'string', description: 'RelatesTo (nullable)' },
49+
replyToId: { type: 'string', description: 'Reply to ID (nullable)' },
50+
timestamp: { type: 'string', description: 'Timestamp' },
51+
topicName: { type: 'string', description: 'Topic name (nullable)' },
52+
valueType: { type: 'string', description: 'Value type (nullable)' },
53+
expiration: { type: 'string', description: 'Expiration (nullable)' },
54+
importance: { type: 'string', description: 'Importance (nullable)' },
55+
serviceUrl: { type: 'string', description: 'Service URL' },
56+
textFormat: { type: 'string', description: 'Text format (plain)' },
57+
attachments: { type: 'array', description: 'Array of attachments' },
58+
channelData: {
59+
team: { id: { type: 'string', description: 'Team ID' } },
60+
tenant: { id: { type: 'string', description: 'Tenant ID' } },
61+
channel: { id: { type: 'string', description: 'Channel ID' } },
62+
teamsTeamId: { type: 'string', description: 'Teams team ID' },
63+
teamsChannelId: { type: 'string', description: 'Teams channel ID' },
6464
},
65-
text: {
66-
type: 'string',
67-
description: 'Message text content',
65+
conversation: {
66+
id: { type: 'string', description: 'Composite conversation ID' },
67+
name: { type: 'string', description: 'Conversation name (nullable)' },
68+
role: { type: 'string', description: 'Conversation role (nullable)' },
69+
isGroup: { type: 'boolean', description: 'Is group conversation' },
70+
tenantId: { type: 'string', description: 'Tenant ID' },
71+
aadObjectId: { type: 'string', description: 'AAD Object ID (nullable)' },
72+
conversationType: { type: 'string', description: 'Conversation type (channel)' },
6873
},
74+
deliveryMode: { type: 'string', description: 'Delivery mode (nullable)' },
75+
membersAdded: { type: 'array', description: 'Members added (nullable)' },
76+
localTimezone: { type: 'string', description: 'Local timezone' },
77+
localTimestamp: { type: 'string', description: 'Local timestamp' },
78+
membersRemoved: { type: 'array', description: 'Members removed (nullable)' },
79+
reactionsAdded: { type: 'array', description: 'Reactions added (nullable)' },
80+
semanticAction: { type: 'string', description: 'Semantic action (nullable)' },
81+
textHighlights: { type: 'string', description: 'Text highlights (nullable)' },
82+
attachmentLayout: { type: 'string', description: 'Attachment layout (nullable)' },
83+
historyDisclosed: { type: 'boolean', description: 'History disclosed (nullable)' },
84+
reactionsRemoved: { type: 'array', description: 'Reactions removed (nullable)' },
85+
suggestedActions: { type: 'string', description: 'Suggested actions (nullable)' },
6986
},
7087

7188
instructions: [

0 commit comments

Comments
 (0)