Skip to content

Commit e435db3

Browse files
authored
Merge pull request #25358 from microsoftgraph/users/sumanac/getforwardedmessage
Get forwarded message as an attachment
2 parents ab0e388 + 2351d46 commit e435db3

File tree

5 files changed

+171
-48
lines changed

5 files changed

+171
-48
lines changed

api-reference/beta/api/chatmessage-get.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,89 @@ Content-type: application/json
658658
}
659659
```
660660

661+
### Example 6: Get a chat message with a forwarded message
662+
663+
The following example shows a request that gets a chat message with a forwarded message as an attachment.
664+
665+
#### Request
666+
667+
The following example shows a request.
668+
669+
<!-- {
670+
"blockType": "request",
671+
"name": "get_chatmessage_6",
672+
"sampleKeys": ["19:e2ed97baac8e4bffbb91299a38996790@thread.v2", "1727903166936"]
673+
}-->
674+
```msgraph-interactive
675+
GET https://graph.microsoft.com/beta/chats/19:e2ed97baac8e4bffbb91299a38996790@thread.v2/messages/1727903166936
676+
```
677+
678+
#### Response
679+
680+
The following example shows the response. The message body contains a forwarded message as an attachment. The **contentType** for the forwarded message is identified as `forwardedMessageReference`. The original message that was forwarded is also available in the attachment **content**.
681+
682+
<!-- {
683+
"blockType": "response",
684+
"truncated": true,
685+
"@odata.type": "microsoft.graph.chatMessage"
686+
} -->
687+
688+
```http
689+
HTTP/1.1 200 OK
690+
Content-type: application/json
691+
692+
{
693+
"@odata.context": "https://graph.microsoft.com/beta/$metadata#chats('19%3Ae2ed97baac8e4bffbb91299a38996790%40thread.v2')/messages/$entity",
694+
"@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET chats('<key>')/messages('<key>')?$select=attachments,body",
695+
"id": "1727903166936",
696+
"replyToId": null,
697+
"etag": "1727903166936",
698+
"messageType": "message",
699+
"createdDateTime": "2024-10-02T21:06:06.936Z",
700+
"lastModifiedDateTime": "2024-10-02T21:06:06.936Z",
701+
"lastEditedDateTime": null,
702+
"deletedDateTime": null,
703+
"subject": null,
704+
"summary": null,
705+
"chatId": "19:e2ed97baac8e4bffbb91299a38996790@thread.v2",
706+
"importance": "normal",
707+
"locale": "en-us",
708+
"webUrl": null,
709+
"channelIdentity": null,
710+
"onBehalfOf": null,
711+
"policyViolation": null,
712+
"eventDetail": null,
713+
"from": {
714+
"application": null,
715+
"device": null,
716+
"user": {
717+
"@odata.type": "#microsoft.graph.teamworkUserIdentity",
718+
"id": "28c10244-4bad-4fda-993c-f332faef94f0",
719+
"displayName": null,
720+
"userIdentityType": "aadUser",
721+
"tenantId": "2432b57b-0abd-43db-aa7b-16eadd115d34"
722+
}
723+
},
724+
"body": {
725+
"contentType": "html",
726+
"content": "<attachment id=\"1727881360458\"></attachment>"
727+
},
728+
"attachments": [
729+
{
730+
"id": "1727881360458",
731+
"contentType": "forwardedMessageReference",
732+
"contentUrl": null,
733+
"content": "{\"originalMessageId\":\"1727881360458\",\"originalMessageContent\":\"\\n<p>hello</p>\\n\",\"originalConversationId\":\"19:97641583cf154265a237da28ebbde27a@thread.v2\",\"originalSentDateTime\":\"2024-10-02T15:02:40.458+00:00\",\"originalMessageSender\":{\"application\":null,\"device\":null,\"user\":{\"userIdentityType\":\"aadUser\",\"tenantId\":\"2432b57b-0abd-43db-aa7b-16eadd115d34\",\"id\":\"28c10244-4bad-4fda-993c-f332faef94f0\",\"displayName\":null}}}",
734+
"name": null,
735+
"thumbnailUrl": null,
736+
"teamsAppId": null
737+
}
738+
],
739+
"mentions": [],
740+
"reactions": []
741+
}
742+
```
743+
661744
## Related content
662745

663746
- [List messages in a channel](channel-list-messages.md)

api-reference/beta/resources/chatmessageattachment.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Namespace: microsoft.graph
1515

1616
Represents an attachment to a chat message entity.
1717

18-
An entity of type `chatMessageAttachment` is returned as part of the [Get channel messages](../api/channel-list-messages.md) API, as a part of [chatMessage](chatmessage.md) entity.
18+
An entity of type **chatMessageAttachment** is returned as part of the [Get channel messages](../api/channel-list-messages.md) API, as a part of [chatMessage](chatmessage.md) entity.
1919

2020
## Properties
2121
| Property | Type |Description|
2222
|:---------------|:--------|:----------|
23-
|id|string| Read-only. The unique id of the attachment.|
24-
|contentType| string | The media type of the content attachment. It can have the following values: <br><ul><li>`reference`: Attachment is a link to another file. Populate the <b>contentURL</b> with the link to the object.</li><li>Any <b>contentType</b> that is supported by the Bot Framework's [Attachment object](/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?#attachment-object).</li><li>`application/vnd.microsoft.card.codesnippet`: A code snippet. </li><li>`application/vnd.microsoft.card.announcement`: An announcement header. </li>|
25-
|contentUrl|string|The URL for the content of the attachment. |
2623
|content|string|The content of the attachment. If the attachment is a [rich card](/microsoftteams/platform/task-modules-and-cards/cards/cards-reference), set the property to the rich card object. This property and **contentUrl** are mutually exclusive.|
24+
|contentType| string | The media type of the content attachment. The possible values are: <br><ul><li>`reference`: The attachment is a link to another file. Populate the <b>contentURL</b> with the link to the object.</li><li>`forwardedMessageReference`: The attachment is a reference to a forwarded message. Populate the <b>content</b> with the original message context.</li><li>Any <b>contentType</b> that is supported by the Bot Framework's [Attachment object](/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?#attachment-object).</li><li>`application/vnd.microsoft.card.codesnippet`: A code snippet. </li><li>`application/vnd.microsoft.card.announcement`: An announcement header. </li>|
25+
|contentUrl|string|The URL for the content of the attachment. |
26+
|id|string| Read-only. The unique ID of the attachment.|
2727
|name|string|Name of the attachment.|
2828
|teamsAppId| string |The ID of the Teams app that is associated with the attachment. The property is used to attribute a Teams message card to the specified app.|
2929
|thumbnailUrl| string |The URL to a thumbnail image that the channel can use if it supports using an alternative, smaller form of **content** or **contentUrl**. For example, if you set **contentType** to application/word and set **contentUrl** to the location of the Word document, you might include a thumbnail image that represents the document. The channel could display the thumbnail image instead of the document. When the user selects the image, the channel would open the document.|
@@ -46,10 +46,10 @@ An entity of type `chatMessageAttachment` is returned as part of the [Get channe
4646

4747
```json
4848
{
49-
"id": "string (identifier)",
49+
"content": "string",
5050
"contentType": "string",
5151
"contentUrl": "string",
52-
"content": "string",
52+
"id": "string (identifier)",
5353
"name": "string",
5454
"teamsAppId": "string",
5555
"thumbnailUrl": "string"

changelog/Microsoft.Teams.Core.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5645,6 +5645,24 @@
56455645
"CreatedDateTime": "2024-09-16T18:15:55.2254479Z",
56465646
"WorkloadArea": "Teamwork and communications",
56475647
"SubArea": "Messaging"
5648+
},
5649+
{
5650+
"ChangeList": [
5651+
{
5652+
"Id": "3a5a736c-80cd-4f40-b4dc-d3c3a6ea14c0",
5653+
"ApiChange": "Property",
5654+
"ChangedApiName": "contentType",
5655+
"ChangeType": "Change",
5656+
"Description": "Added `forwardedMessageReference` as a supported value for the **contentType** property in the [chatMessageAttachment](https://learn.microsoft.com/en-us/graph/api/resources/chatmessageattachment?view=graph-rest-beta) resource.",
5657+
"Target": "chatMessageAttachment"
5658+
}
5659+
],
5660+
"Id": "3a5a736c-80cd-4f40-b4dc-d3c3a6ea14c0",
5661+
"Cloud": "Prod",
5662+
"Version": "beta",
5663+
"CreatedDateTime": "2024-10-22T18:15:55.2254479Z",
5664+
"WorkloadArea": "Teamwork and communications",
5665+
"SubArea": "Messaging"
56485666
}
56495667
]
56505668
}

concepts/teams-messaging-overview.md

Lines changed: 63 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,6 @@ The [chatMessage](/graph/api/resources/chatMessage) resource type represents mes
2222

2323
The [chatMessageAttachment](/graph/api/resources/chatmessageattachment) resource type represents entities that can be referenced from a [chatMessage](/graph/api/resources/chatMessage?preserve-view=true). These entities include files, tabs, cards, meetings, or other messages. The items themselves might be located somewhere else. For example, files might be stored in SharePoint. The following sections describe the possible types of attachments on a **chatMessage** object.
2424

25-
#### file attachment
26-
27-
When an [attachment](/graph/api/resources/chatmessageattachment) object refers to a file, it contains information about the file, including the link to open the file. The file itself is located in an accessible store like SharePoint. When a **chatMessage** has an attachment of type file, the value of the **contentType** property on the [attachment](/graph/api/resources/chatmessageattachment) resource is set to `reference`, and the **contentUrl** property contains the file URL.
28-
29-
> **Note:** The SharePoint URL is the link that opens the file; it is not the Microsoft Graph URL. Callers can, however, use the [access shared items](/graph/api/shares-get) API to get the information about the contents of the file.
30-
31-
The following example shows the schema for a file attachment.
32-
33-
```json
34-
"attachments": [
35-
{
36-
"id": "924D1F74-E0D2-4927-8A67-15ECEF455527",
37-
"contentType": "reference",
38-
"contentUrl": "https://testing.sharepoint.com/sites/Samples/Shared Documents/General/color.png",
39-
"content": null,
40-
"name": "color.png",
41-
"thumbnailUrl": null,
42-
"teamsAppId": null
43-
}
44-
],
45-
```
46-
47-
#### tab attachment
48-
49-
When an [attachment](/graph/api/resources/chatmessageattachment) object refers to a [tab](/graph/api/resources/teamstab) hosted in the present context, the **contentType** property is set to `tabReference`, the **id** property is set to the ID of the tab, and the **name** property is set to the tab name. This scenario often applies when tabs are newly added.
50-
51-
The following example shows the schema for an tab attachment.
52-
53-
``` json
54-
"attachments": [
55-
{
56-
"id": "tab::d64ea8d0-8b63-4f53-9bf6-806648176968",
57-
"contentType": "tabReference",
58-
"contentUrl": null,
59-
"content": null,
60-
"name": "Bing",
61-
"thumbnailUrl": null,
62-
"teamsAppId": null
63-
}
64-
],
65-
```
6625
#### card attachment
6726

6827
Cards represent visual elements backed by a predefined schema. Teams supports the cards defined by the [Bot Framework](/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0&preserve-view=true#attachment-object) in addition to the following card types:
@@ -108,7 +67,49 @@ The following example shows the schema for an adaptive card attachment when the
10867
]
10968
```
11069

111-
> **Note:** Microsoft Graph only supports cards that have the **OpenUrl** action set. Other actions like **ShowCard** are not supported. Microsoft Graph does allow messages posted by bots that have other actions in them to be read.
70+
> **Note:** Microsoft Graph only supports cards that have the **OpenUrl** action set. Other actions like **ShowCard** aren't supported. Microsoft Graph does allow messages posted by bots that have other actions in them to be read.
71+
72+
#### file attachment
73+
74+
When an [attachment](/graph/api/resources/chatmessageattachment) object refers to a file, it contains information about the file, including the link to open the file. The file itself is located in an accessible store like SharePoint. When a **chatMessage** has an attachment of type file, the value of the **contentType** property on the [attachment](/graph/api/resources/chatmessageattachment) resource is set to `reference`, and the **contentUrl** property contains the file URL.
75+
76+
> **Note:** The SharePoint URL is the link that opens the file; it isn't the Microsoft Graph URL. Callers can, however, use the [access shared items](/graph/api/shares-get) API to get the information about the contents of the file.
77+
78+
The following example shows the schema for a file attachment.
79+
80+
```json
81+
"attachments": [
82+
{
83+
"id": "924D1F74-E0D2-4927-8A67-15ECEF455527",
84+
"contentType": "reference",
85+
"contentUrl": "https://testing.sharepoint.com/sites/Samples/Shared Documents/General/color.png",
86+
"content": null,
87+
"name": "color.png",
88+
"thumbnailUrl": null,
89+
"teamsAppId": null
90+
}
91+
],
92+
```
93+
94+
#### forwarded message attachment
95+
96+
An [attachment](/graph/api/resources/chatmessageattachment) object contains a forwarded message that was forwarded to a [chat](/graph/api/resources/chat). For message attachments, the **id** property contains the ID of the forwarded message. The **content** property contains more details about the message; for example, the original message context and original sender detail. For message attachments, the **contentType** property is set to `forwardedMessageReference`.
97+
98+
The following example shows the schema for a forwarded message attachment.
99+
100+
```json
101+
"attachments": [
102+
{
103+
"id": "1727881360458",
104+
"contentType": "forwardedMessageReference",
105+
"contentUrl": null,
106+
"content": "{\"originalMessageId\":\"1727881360458\",\"originalMessageContent\":\"\\n<p>hello</p>\\n\",\"originalConversationId\":\"19:97641583cf154265a237da28ebbde27a@thread.v2\",\"originalSentDateTime\":\"2024-10-02T15:02:40.458+00:00\",\"originalMessageSender\":{\"application\":null,\"device\":null,\"user\":{\"userIdentityType\":\"aadUser\",\"tenantId\":\"2432b57b-0abd-43db-aa7b-16eadd115d34\",\"id\":\"28c10244-4bad-4fda-993c-f332faef94f0\",\"displayName\":null}}}",
107+
"name": null,
108+
"thumbnailUrl": null,
109+
"teamsAppId": null
110+
}
111+
],
112+
```
112113

113114
#### meeting attachment
114115

@@ -147,6 +148,26 @@ The following example shows the schema for a message attachment.
147148
],
148149
```
149150

151+
#### tab attachment
152+
153+
When an [attachment](/graph/api/resources/chatmessageattachment) object refers to a [tab](/graph/api/resources/teamstab) hosted in the present context, the **contentType** property is set to `tabReference`, the **id** property is set to the ID of the tab, and the **name** property is set to the tab name. This scenario often applies when tabs are newly added.
154+
155+
The following example shows the schema for an tab attachment.
156+
157+
``` json
158+
"attachments": [
159+
{
160+
"id": "tab::d64ea8d0-8b63-4f53-9bf6-806648176968",
161+
"contentType": "tabReference",
162+
"contentUrl": null,
163+
"content": null,
164+
"name": "Bing",
165+
"thumbnailUrl": null,
166+
"teamsAppId": null
167+
}
168+
],
169+
```
170+
150171
### body
151172

152173
The **body** property of a **chatMessage** object represents the body of the message. The **body** property can refer to other elements in the schema such as mentions or attachments. The contents can be `text` or `html`, as specified by the **contentType** property of the [itemBody](/graph/api/resources/itembody) resource type.

concepts/whats-new-overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ The Microsoft Entra Health monitoring alerts APIs enable you to detect anomalous
103103
### Teamwork and communications | Messaging
104104

105105
- Updated the [chatMessage: delta](/graph/api/chatmessage-delta?view=graph-rest-beta&preserve-view=true) method to use a new endpoint that gets the list of delta messages from all chats in which a user is a participant, including one-on-one chats, group chats, and meeting chats.
106+
- [Get](/graph/api/chatmessage-get?view=graph-rest-beta&preserve-view=true#example-6-get-a-chat-message-with-a-forwarded-message) a chat message that has a forwarded message as an attachment.
106107
- [Remove multiple members](/graph/api/conversationmember-remove?view=graph-rest-beta&preserve-view=true) from a [team](/graph/api/resources/team?view=graph-rest-beta&preserve-view=true) in a single request.
107108

108109
### Users

0 commit comments

Comments
 (0)