MCPcopy Index your code
hub / github.com/simstudioai/sim / formatMessages

Function formatMessages

apps/sim/connectors/microsoft-teams/microsoft-teams.ts:139–158  ·  view source on GitHub ↗

* Converts fetched messages into a single document content string. * Each line: "[ISO timestamp] username: message text"

(messages: TeamsMessage[])

Source from the content-addressed store, hash-verified

137 * Each line: "[ISO timestamp] username: message text"
138 */
139function formatMessages(messages: TeamsMessage[]): string {
140 const lines: string[] = []
141
142 // Process in reverse so oldest messages come first
143 const chronological = [...messages].reverse()
144
145 for (const msg of chronological) {
146 const bodyText =
147 msg.body.contentType === 'html' ? htmlToPlainText(msg.body.content) : msg.body.content
148
149 if (!bodyText.trim()) continue
150
151 const timestamp = msg.createdDateTime
152 const userName = msg.from?.user?.displayName || msg.from?.application?.displayName || 'unknown'
153
154 lines.push(`[${timestamp}] ${userName}: ${bodyText}`)
155 }
156
157 return lines.join('\n')
158}
159
160/**
161 * Resolves a channel name or ID to a channel object within the given team.

Callers 1

microsoft-teams.tsFile · 0.70

Calls 3

htmlToPlainTextFunction · 0.90
joinMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected