Skip to main content

Read and Watch Channels

Read recent messages:

teams message list --team "$TEAM_ID" --channel "$CHANNEL_ID" --page-size 20 --output json

Read a thread's replies​

A channel listing returns thread roots only, so on its own it cannot tell you whether a post has been answered. Pass a root's ID to list the replies under it, paged like any other listing:

teams message list --team "$TEAM_ID" --channel "$CHANNEL_ID" --message-id "$ROOT_MESSAGE_ID" --output json
teams message list --team "$TEAM_ID" --channel "$CHANNEL_ID" --message-id "$ROOT_MESSAGE_ID" --all-pages --output json

The root itself is not part of the result. Graph serves this collection in pages of up to 50, so keep --page-size at or below that and use --all-pages to walk a long thread. Both listings need ChannelMessage.Read.All, which is not in the default scope set; see the permissions matrix.

Human-readable listings include a Subject column, so a titled post keeps its subject even when it is not the first row. JSON omits the field for untitled messages.

Watch a channel​

For event-driven workflows, create a subscription and run the local listener behind HTTPS.

teams listen --port 8080
teams subscribe create --resource "/teams/$TEAM_ID/channels/$CHANNEL_ID/messages" --change-type created --webhook-url "$HTTPS_URL"