Get Chats
Lists all chats that the authenticated user is a member of.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.
Input
- Client Id - The client ID from the Connect node. Optional if using direct credentials.
Output
- Chats - Collection of chats containing:
value- Array of chat objects- Each chat has:
Id- Unique chat identifierTopic- Chat topic/title (null for one-on-one)ChatType- Type: oneOnOne, group, meetingCreatedDateTime- When chat was createdLastUpdatedDateTime- Last activity timeWebUrl- Link to open chat in Teams
Options
- Credentials - OAuth2 credentials JSON (optional if using Client ID). Allows direct authentication without Connect node.
Examples
List All Chats
Get all chats for the authenticated user:
// Get Chats node
// Output: chats collection
all_chats = chats.value
console.log("Found " + all_chats.length + " chats")
for (chat of all_chats) {
console.log("Chat: " + (chat.Topic || "One-on-One"))
console.log(" Type: " + chat.ChatType)
console.log(" ID: " + chat.Id)
}
Find Chat by Topic
Search for specific chat by name:
// Get Chats node
chats = message.chats.value
// Find by topic
project_chat = chats.find(c =>
c.Topic && c.Topic.includes("Project Alpha")
)
if (project_chat) {
console.log("Found chat: " + project_chat.Topic)
chat_id = project_chat.Id
// Use chat_id for further operations
} else {
console.log("Chat not found")
}
Filter Group Chats
Get only group chats:
// Get Chats node
all_chats = message.chats.value
// Filter for group chats
group_chats = all_chats.filter(c =>
c.ChatType === "group"
)
console.log("Group chats:")
for (chat of group_chats) {
console.log("- " + chat.Topic)
}
Get Recent Chats
Find recently active chats:
// Get Chats node
chats = message.chats.value
// Sort by last update time
chats.sort((a, b) =>
new Date(b.LastUpdatedDateTime) - new Date(a.LastUpdatedDateTime)
)
// Get 5 most recent
recent_chats = chats.slice(0, 5)
console.log("Recent chats:")
for (chat of recent_chats) {
console.log("- " + (chat.Topic || "Direct message"))
console.log(" Last updated: " + chat.LastUpdatedDateTime)
}
Count Chats by Type
Get statistics about chat types:
// Get Chats node
chats = message.chats.value
// Count by type
one_on_one = chats.filter(c => c.ChatType === "oneOnOne").length
group = chats.filter(c => c.ChatType === "group").length
meeting = chats.filter(c => c.ChatType === "meeting").length
console.log("Chat statistics:")
console.log(" One-on-One: " + one_on_one)
console.log(" Group: " + group)
console.log(" Meeting: " + meeting)
console.log(" Total: " + chats.length)
Monitor for New Chats
Track new chats since last check:
// Load last check time from database/storage
last_check = "2025-01-01T00:00:00Z"
// Get Chats node
all_chats = message.chats.value
// Find new chats
new_chats = all_chats.filter(c =>
new Date(c.CreatedDateTime) > new Date(last_check)
)
if (new_chats.length > 0) {
console.log("New chats since last check:")
for (chat of new_chats) {
console.log("- " + (chat.Topic || "Direct chat"))
}
}
// Update last check time
// Save current time to database
Tips for Effective Use
- Handle null topics: One-on-one chats typically don't have topics
- Chat types: Understand difference between oneOnOne, group, and meeting chats
- Sorting: Sort by LastUpdatedDateTime to find active chats
- Filtering: Filter by ChatType for specific use cases
- Pagination: Be aware of potential pagination for users with many chats
- Caching: Cache chat list to reduce API calls
- Regular updates: Refresh chat list periodically to catch new chats
Common Errors and Solutions
Empty Chat List
Cause: User has no chats or API returned empty result.
Solution:
// Get Chats node
chats = message.chats.value || []
if (chats.length === 0) {
console.log("No chats found")
// Handle empty case
} else {
// Process chats
}
"ErrNotFound: Client ID not found"
Cause: Invalid or expired client ID from Connect.
Solution:
// Ensure Connect was successful
// Connect node
client_id = message.client_id
if (!client_id) {
throw new Error("Connection failed")
}
// Then use Get Chats
Missing Chat Information
Cause: Some chat fields may be null or undefined.
Solution:
// Safe property access
for (chat of chats) {
topic = chat.Topic || "(No topic)"
type = chat.ChatType || "unknown"
console.log(topic + " (" + type + ")")
}
Best Practices
- Null handling: Always check for null Topic in one-on-one chats
- Type checking: Verify ChatType before type-specific operations
- Error handling: Handle empty chat lists gracefully
- Caching: Store chat list and refresh periodically
- Filtering: Filter by ChatType or other criteria for specific needs
- Sorting: Sort by LastUpdatedDateTime for most relevant chats first
- Logging: Log chat counts for monitoring and debugging
Chat Types Explained
- oneOnOne: Direct message between two users (no topic)
- group: Group chat with multiple participants (has topic)
- meeting: Chat associated with a Teams meeting (has topic)
Output Data Structure
{
"value": [
{
"Id": "19:meeting_abc123...",
"Topic": "Project Discussion",
"ChatType": "group",
"CreatedDateTime": "2025-01-15T10:30:00Z",
"LastUpdatedDateTime": "2025-01-20T14:25:00Z",
"WebUrl": "https://teams.microsoft.com/..."
},
{
"Id": "19:abc123def456...",
"Topic": null,
"ChatType": "oneOnOne",
"CreatedDateTime": "2025-01-10T09:00:00Z",
"LastUpdatedDateTime": "2025-01-20T13:15:00Z",
"WebUrl": "https://teams.microsoft.com/..."
}
]
}
Related Nodes
- GetChat - Get specific chat details
- GetChatMembers - Get chat participants
- GetMessages - Get messages from chat
- SendMessage - Send message to chat