ByteChef LogoByteChef

Microsoft Teams

Microsoft Teams is a collaboration platform that combines workplace chat, video meetings, file storage, and application integration.

Categories: Communication

Type: microsoftTeams/v1


Connections

Version: 1

OAuth2 Authorization Code

Properties

NameLabelTypeDescriptionRequired
clientIdClient IdSTRINGtrue
clientSecretClient SecretSTRINGtrue
tenantIdTenant IdSTRINGtrue

Connection Setup

Create OAuth 2.0 Application

Creation of OAuth 2.0 application is documented here.

Grant Necessary Permissions

  1. Open the Azure Portal: https://portal.azure.com/
  2. Click on App registrations.
  3. Click on All applications.
  4. Click on application you want to connect to Microsoft Teams.
  5. Click on API permissions.
  6. Click on Microsoft Graph (1).
  7. Select following scopes:
    • Channel.Create
    • Channel.ReadBasic.All
    • ChannelMessage.Send
    • Chat.ReadWrite
    • Chat.Read
    • ChatMember.Read
    • Team.ReadBasic.All
    • offline_access
  8. After selecting all the scopes click on Update permissions

Grant Necessary Permissions - For Microsoft OneDrive (needed for sending attachments)

  1. Open the Azure Portal: https://portal.azure.com/
  2. Click on App registrations.
  3. Click on All applications.
  4. Click on application you want to connect to Microsoft OneDrive.
  5. Click on API permissions.
  6. Click on Microsoft Graph (1).
  7. Select following scopes:
  • Files.Read
  • Files.ReadWrite.All
  • offline_access
  1. After selecting all the scopes click on Update permissions

Actions

Create Channel

Name: createChannel

Creates a new channel within a team.

Properties

NameLabelTypeDescriptionRequired
teamIdTeam IDSTRINGID of the team where the channel will be created.true
displayNameChannel NameSTRINGtrue
descriptionDescriptionSTRINGDescription for the channel.false

Example JSON Structure

{
  "label" : "Create Channel",
  "name" : "createChannel",
  "parameters" : {
    "teamId" : "",
    "displayName" : "",
    "description" : ""
  },
  "type" : "microsoftTeams/v1/createChannel"
}

Output

Type: OBJECT

Properties

NameTypeDescription
@odata.contextSTRINGThe OData context URL that indicates the metadata for the response.
idSTRINGID of the channel.
createdDateTimeDATE_TIMEThe date and time when the channel was created.
displayNameSTRINGName of the channel that will appear to the user in Microsoft Teams.
descriptionSTRINGDescription of the channel.
isFavoriteByDefaultBOOLEAN
Options true, false
Indicates whether the channel is marked as favorite by default.
emailSTRINGThe email address of the channel if it is enabled to receive emails.
webUrlSTRINGURL to access the channel in a web browser.
membershipTypeSTRINGThe type of channel membership, e.g., standard or private.
isArchivedBOOLEAN
Options true, false
Indicates whether the channel is archived.

Output Example

{
  "@odata.context" : "",
  "id" : "",
  "createdDateTime" : "2021-01-01T00:00:00",
  "displayName" : "",
  "description" : "",
  "isFavoriteByDefault" : false,
  "email" : "",
  "webUrl" : "",
  "membershipType" : "",
  "isArchived" : false
}

Find Team ID

To find the Team ID, click here.

Send Channel Message

Name: sendChannelMessage

Sends a message to a channel. Sending attachments is supported with Message Text Format is set to "html".

Properties

NameLabelTypeDescriptionRequired
teamIdTeam IDSTRINGID of the team where the channel is located.true
channelIdChannel IDSTRING
Depends On teamId
Channel to send message to.true
contentTypeMessage Text FormatSTRING
Options text, html
true
contentMessage TextSTRINGtrue
attachmentsAttachmentsARRAY
Items [STRING($attachment)]
The attachments to send with the message. The file to attach must already be in SharePoint.false

Example JSON Structure

{
  "label" : "Send Channel Message",
  "name" : "sendChannelMessage",
  "parameters" : {
    "teamId" : "",
    "channelId" : "",
    "contentType" : "",
    "content" : "",
    "attachments" : [ "" ]
  },
  "type" : "microsoftTeams/v1/sendChannelMessage"
}

Output

Type: OBJECT

Properties

NameTypeDescription
idSTRINGUnique identifier of the message.
replyToIdSTRINGID of the parent message if this is a reply.
etagSTRINGEntity tag for versioning.
messageTypeSTRINGType of the message.
createdDateTimeSTRINGTimestamp when the message was created.
lastModifiedDateTimeSTRINGTimestamp when the message was last modified.
lastEditedDateTimeSTRINGTimestamp when the message was last edited.
deletedDateTimeSTRINGTimestamp when the message was deleted.
subjectSTRINGSubject/title of the message.
summarySTRINGSummary of the message.
chatIdSTRINGID of the chat.
importanceSTRINGImportance level of the message.
localeSTRINGLocale of the message.
webUrlSTRINGWeb URL to access the message.
policyViolationSTRINGPolicy violation details if applicable.
eventDetailSTRINGEvent details associated with the message.
fromOBJECT
Properties {{}(application), {}(device), {STRING(@odata.type), STRING(id), STRING(displayName), STRING(userIdentityType), STRING(tenantId)}(user)}
Information about the sender.
bodyOBJECT
Properties {STRING(contentType), STRING(content)}
Plaintext/HTML representation of the content of the chat message.
channelIdentityOBJECT
Properties {STRING(teamId), STRING(channelId)}
Channel identity where the message was posted.
attachmentsARRAY
Items []
List of attachments included in the message.
mentionsARRAY
Items []
List of mentions in the message.
reactionsARRAY
Items []
List of reactions to the message.

Output Example

{
  "id" : "",
  "replyToId" : "",
  "etag" : "",
  "messageType" : "",
  "createdDateTime" : "",
  "lastModifiedDateTime" : "",
  "lastEditedDateTime" : "",
  "deletedDateTime" : "",
  "subject" : "",
  "summary" : "",
  "chatId" : "",
  "importance" : "",
  "locale" : "",
  "webUrl" : "",
  "policyViolation" : "",
  "eventDetail" : "",
  "from" : {
    "application" : { },
    "device" : { },
    "user" : {
      "@odata.type" : "",
      "id" : "",
      "displayName" : "",
      "userIdentityType" : "",
      "tenantId" : ""
    }
  },
  "body" : {
    "contentType" : "",
    "content" : ""
  },
  "channelIdentity" : {
    "teamId" : "",
    "channelId" : ""
  },
  "attachments" : [ ],
  "mentions" : [ ],
  "reactions" : [ ]
}

Find Team ID and Channel ID

To find the Team ID, click here.

To find the Channel ID, click here.

Send Direct Message

Name: sendDirectMessage

Sends a direct message in an existing chat. Sending attachments is supported with Message Text Format set to "html".

Properties

NameLabelTypeDescriptionRequired
chatIdChat IDSTRINGtrue
contentTypeMessage Text FormatSTRING
Options text, html
true
contentMessage TextSTRINGtrue
attachmentsAttachmentsARRAY
Items [STRING($attachment)]
The attachments to send with the message. The file to attach must already be in SharePoint.false

Example JSON Structure

{
  "label" : "Send Direct Message",
  "name" : "sendDirectMessage",
  "parameters" : {
    "chatId" : "",
    "contentType" : "",
    "content" : "",
    "attachments" : [ "" ]
  },
  "type" : "microsoftTeams/v1/sendDirectMessage"
}

Output

Type: OBJECT

Properties

NameTypeDescription
idSTRINGUnique identifier of the message.
replyToIdSTRINGID of the parent message if this is a reply.
etagSTRINGEntity tag for versioning.
messageTypeSTRINGType of the message.
createdDateTimeSTRINGTimestamp when the message was created.
lastModifiedDateTimeSTRINGTimestamp when the message was last modified.
lastEditedDateTimeSTRINGTimestamp when the message was last edited.
deletedDateTimeSTRINGTimestamp when the message was deleted.
subjectSTRINGSubject/title of the message.
summarySTRINGSummary of the message.
chatIdSTRINGID of the chat.
importanceSTRINGImportance level of the message.
localeSTRINGLocale of the message.
webUrlSTRINGWeb URL to access the message.
policyViolationSTRINGPolicy violation details if applicable.
eventDetailSTRINGEvent details associated with the message.
fromOBJECT
Properties {{}(application), {}(device), {STRING(@odata.type), STRING(id), STRING(displayName), STRING(userIdentityType), STRING(tenantId)}(user)}
Information about the sender.
bodyOBJECT
Properties {STRING(contentType), STRING(content)}
Plaintext/HTML representation of the content of the chat message.
channelIdentityOBJECT
Properties {STRING(teamId), STRING(channelId)}
Channel identity where the message was posted.
attachmentsARRAY
Items []
List of attachments included in the message.
mentionsARRAY
Items []
List of mentions in the message.
reactionsARRAY
Items []
List of reactions to the message.

Output Example

{
  "id" : "",
  "replyToId" : "",
  "etag" : "",
  "messageType" : "",
  "createdDateTime" : "",
  "lastModifiedDateTime" : "",
  "lastEditedDateTime" : "",
  "deletedDateTime" : "",
  "subject" : "",
  "summary" : "",
  "chatId" : "",
  "importance" : "",
  "locale" : "",
  "webUrl" : "",
  "policyViolation" : "",
  "eventDetail" : "",
  "from" : {
    "application" : { },
    "device" : { },
    "user" : {
      "@odata.type" : "",
      "id" : "",
      "displayName" : "",
      "userIdentityType" : "",
      "tenantId" : ""
    }
  },
  "body" : {
    "contentType" : "",
    "content" : ""
  },
  "channelIdentity" : {
    "teamId" : "",
    "channelId" : ""
  },
  "attachments" : [ ],
  "mentions" : [ ],
  "reactions" : [ ]
}

Find Chat ID

To find the Chat ID, click here.

Reply to Channel Message

Name: replyToChannelMessage

Sends a reply to a channel message. Sending attachments is supported with Message Text Format is set to "html".

Properties

NameLabelTypeDescriptionRequired
teamIdTeam IDSTRINGID of the team where the channel is located.true
channelIdChannel IDSTRING
Depends On teamId
Channel of the message that will get a reply.true
messageIdMessage IDSTRINGID of the message that will get a reply.true
contentTypeMessage Text FormatSTRING
Options text, html
true
contentMessage TextSTRINGtrue
attachmentsAttachmentsARRAY
Items [STRING($attachment)]
The attachments to send with the message. The file to attach must already be in SharePoint.false

Example JSON Structure

{
  "label" : "Reply to Channel Message",
  "name" : "replyToChannelMessage",
  "parameters" : {
    "teamId" : "",
    "channelId" : "",
    "messageId" : "",
    "contentType" : "",
    "content" : "",
    "attachments" : [ "" ]
  },
  "type" : "microsoftTeams/v1/replyToChannelMessage"
}

Output

Type: OBJECT

Properties

NameTypeDescription
idSTRINGUnique identifier of the message.
replyToIdSTRINGID of the parent message if this is a reply.
etagSTRINGEntity tag for versioning.
messageTypeSTRINGType of the message.
createdDateTimeSTRINGTimestamp when the message was created.
lastModifiedDateTimeSTRINGTimestamp when the message was last modified.
lastEditedDateTimeSTRINGTimestamp when the message was last edited.
deletedDateTimeSTRINGTimestamp when the message was deleted.
subjectSTRINGSubject/title of the message.
summarySTRINGSummary of the message.
chatIdSTRINGID of the chat.
importanceSTRINGImportance level of the message.
localeSTRINGLocale of the message.
webUrlSTRINGWeb URL to access the message.
policyViolationSTRINGPolicy violation details if applicable.
eventDetailSTRINGEvent details associated with the message.
fromOBJECT
Properties {{}(application), {}(device), {STRING(@odata.type), STRING(id), STRING(displayName), STRING(userIdentityType), STRING(tenantId)}(user)}
Information about the sender.
bodyOBJECT
Properties {STRING(contentType), STRING(content)}
Plaintext/HTML representation of the content of the chat message.
channelIdentityOBJECT
Properties {STRING(teamId), STRING(channelId)}
Channel identity where the message was posted.
attachmentsARRAY
Items []
List of attachments included in the message.
mentionsARRAY
Items []
List of mentions in the message.
reactionsARRAY
Items []
List of reactions to the message.

Output Example

{
  "id" : "",
  "replyToId" : "",
  "etag" : "",
  "messageType" : "",
  "createdDateTime" : "",
  "lastModifiedDateTime" : "",
  "lastEditedDateTime" : "",
  "deletedDateTime" : "",
  "subject" : "",
  "summary" : "",
  "chatId" : "",
  "importance" : "",
  "locale" : "",
  "webUrl" : "",
  "policyViolation" : "",
  "eventDetail" : "",
  "from" : {
    "application" : { },
    "device" : { },
    "user" : {
      "@odata.type" : "",
      "id" : "",
      "displayName" : "",
      "userIdentityType" : "",
      "tenantId" : ""
    }
  },
  "body" : {
    "contentType" : "",
    "content" : ""
  },
  "channelIdentity" : {
    "teamId" : "",
    "channelId" : ""
  },
  "attachments" : [ ],
  "mentions" : [ ],
  "reactions" : [ ]
}

Find Team ID and Channel ID

To find the Team ID, click here.

To find the Channel ID, click here.

To find the Message ID, click here.

Triggers

New Channel Message

Name: newChannelMessage

Triggers when new message is received in selected channel.

Type: POLLING

Properties

NameLabelTypeDescriptionRequired
teamIdTeam IDSTRINGID of the team where the channel is located.true
channelIdChannel IDSTRING
Depends On teamId
Channel to monitor for new messages.true
includeRepliesInclude RepliesBOOLEAN
Options true, false
Whether replies to a channel message will trigger the workflow.true

Output

Type: OBJECT

Properties

NameTypeDescription
idSTRINGUnique identifier of the message.
replyToIdSTRINGID of the parent message if this is a reply.
etagSTRINGEntity tag for versioning.
messageTypeSTRINGType of the message.
createdDateTimeSTRINGTimestamp when the message was created.
lastModifiedDateTimeSTRINGTimestamp when the message was last modified.
lastEditedDateTimeSTRINGTimestamp when the message was last edited.
deletedDateTimeSTRINGTimestamp when the message was deleted.
subjectSTRINGSubject/title of the message.
summarySTRINGSummary of the message.
chatIdSTRINGID of the chat.
importanceSTRINGImportance level of the message.
localeSTRINGLocale of the message.
webUrlSTRINGWeb URL to access the message.
policyViolationSTRINGPolicy violation details if applicable.
eventDetailSTRINGEvent details associated with the message.
fromOBJECT
Properties {{}(application), {}(device), {STRING(@odata.type), STRING(id), STRING(displayName), STRING(userIdentityType), STRING(tenantId)}(user)}
Information about the sender.
bodyOBJECT
Properties {STRING(contentType), STRING(content)}
Plaintext/HTML representation of the content of the chat message.
channelIdentityOBJECT
Properties {STRING(teamId), STRING(channelId)}
Channel identity where the message was posted.
attachmentsARRAY
Items []
List of attachments included in the message.
mentionsARRAY
Items []
List of mentions in the message.
reactionsARRAY
Items []
List of reactions to the message.

JSON Example

{
  "label" : "New Channel Message",
  "name" : "newChannelMessage",
  "parameters" : {
    "teamId" : "",
    "channelId" : "",
    "includeReplies" : false
  },
  "type" : "microsoftTeams/v1/newChannelMessage"
}

Find Team ID and Channel ID

To find the Team ID, click here.

To find the Channel ID, click here.

New Direct Message

Name: newDirectMessage

Triggers when new direct message is received.

Type: POLLING

Properties

NameLabelTypeDescriptionRequired
chatIdChat IDSTRINGtrue

Output

Type: OBJECT

Properties

NameTypeDescription
idSTRINGUnique identifier of the message.
replyToIdSTRINGID of the parent message if this is a reply.
etagSTRINGEntity tag for versioning.
messageTypeSTRINGType of the message.
createdDateTimeSTRINGTimestamp when the message was created.
lastModifiedDateTimeSTRINGTimestamp when the message was last modified.
lastEditedDateTimeSTRINGTimestamp when the message was last edited.
deletedDateTimeSTRINGTimestamp when the message was deleted.
subjectSTRINGSubject/title of the message.
summarySTRINGSummary of the message.
chatIdSTRINGID of the chat.
importanceSTRINGImportance level of the message.
localeSTRINGLocale of the message.
webUrlSTRINGWeb URL to access the message.
policyViolationSTRINGPolicy violation details if applicable.
eventDetailSTRINGEvent details associated with the message.
fromOBJECT
Properties {{}(application), {}(device), {STRING(@odata.type), STRING(id), STRING(displayName), STRING(userIdentityType), STRING(tenantId)}(user)}
Information about the sender.
bodyOBJECT
Properties {STRING(contentType), STRING(content)}
Plaintext/HTML representation of the content of the chat message.
channelIdentityOBJECT
Properties {STRING(teamId), STRING(channelId)}
Channel identity where the message was posted.
attachmentsARRAY
Items []
List of attachments included in the message.
mentionsARRAY
Items []
List of mentions in the message.
reactionsARRAY
Items []
List of reactions to the message.

JSON Example

{
  "label" : "New Direct Message",
  "name" : "newDirectMessage",
  "parameters" : {
    "chatId" : ""
  },
  "type" : "microsoftTeams/v1/newDirectMessage"
}

Find Chat ID

To find the Chat ID, click here.

What to do if your action is not listed here?

If this component doesn't have the action you need, you can use Custom Action to create your own. Custom Actions empower you to define HTTP requests tailored to your specific requirements, allowing for greater flexibility in integrating with external services or APIs.

To create a Custom Action, simply specify the desired HTTP method, path, and any necessary parameters. This way, you can extend the functionality of your component beyond the predefined actions, ensuring that you can meet all your integration needs effectively.


Additional Instructions

How to find Team ID

You can get your Team ID from your Microsoft Teams:

  1. Open Microsoft Teams
  2. Go to Teams and Channels
  3. Click the three dots (...) next to the team name
  4. Select Copy link
  5. You'll get URL like: https://teams.microsoft.com/l/team/19%3aabc123def456%40thread.tacv2/conversations?groupId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&tenantId=yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
  6. The Team ID is the value of: groupId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

How to find Channel ID

You can get your Channel ID from your Microsoft Teams:

  1. Open Microsoft Teams
  2. Go to Teams and Channels
  3. Click the three dots (...) next to the channel name
  4. Select Copy link
  5. You'll get URL like: https://teams.microsoft.com/l/channel/19%3abc8e04002356415884ba1769f437de36%40thread.tacv2/General?groupId=e95fd37a-caad-496e-8a89-762f0aa441bf&tenantId=43f519c0-e5a6-438f-808f-6491be63b3be
  6. The Channel ID is the value after /l/channel/: 19:bc8e04002356415884ba1769f437de36@thread.tacv2
  7. Important notice is that string in the URL is URL encoded 19%3abc8e04002356415884ba1769f437de36%40thread.tacv2 so you will have to decode it to get 19:bc8e04002356415884ba1769f437de36@thread.tacv2

How to find Chat ID

  1. Go to Microsoft Graph Explorer
  2. Sign in with your Microsoft 365 account by clicking Sign in to Graph Explorer
  3. In the request bar, make sure GET is selected and enter: https://graph.microsoft.com/v1.0/me/chats
  4. Click Run query
  5. In the Response preview panel below, you will see a list of chats
  6. Find your chat in the value array and copy the id field:

How to find Message ID

  1. Go to Microsoft Graph Explorer
  2. Sign in with your Microsoft 365 account by clicking Sign in to Graph Explorer
  3. In the request bar, make sure GET is selected and enter: https://graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/messages
    • Replace {teamId} with your Team ID (same as Group ID from the Channel link)
    • Replace {channelId} with your Channel ID found using the steps above
  4. Click Run query
  5. In the Response preview panel below, you will see a list of messages
  6. Find your message in the value array and copy the id field:
{
  "value": [
    {
      "id": "1616990032035",
      "messageType": "message",
      "createdDateTime": "2021-03-29T04:13:52.035Z",
      "body": {
        "content": "Your message content here"
      }
    }
  ]
}
  1. The Channel Message ID is the id value: 1616990032035

Note: You can identify the right message by matching the createdDateTime or checking body.content. If you need a reply message ID specifically, add /$expand=replies to the request URL to include replies in the response, then find the reply's id inside the replies array of the parent message

How is this guide?

Last updated on

On this page