Sep 28 2022 09:10 AM - edited Sep 28 2022 09:11 AM
Hi,
I just found a weird behavior that I believe to be a bug.
When using the Connector API, I can create a message with this kind of Axios config :
{
method: "POST",
headers: { Authorization: botBearerToken },
url: `${connectorApiBaseURI}/v3/conversations/${conversationId}/activities`,
data: {
type: "message",
text: "random text message",
inputHint: "acceptingInput",
},
}
I can retrieve the activity/message id I just created in the response body.
But if I add some attachments to the message, the message with its attachments is properly created in Teams but the id in the response body is undefined. This is a plague for my app, as the message Id is mandatory to update the message afterwards when necessary.
Here is the Axios config in this case :
{
method: "POST",
headers: { Authorization: botBearerToken },
url: `${connectorApiBaseURI}/v3/conversations/${conversationId}/activities`,
data: {
type: "message",
text: "random text message",
inputHint: "acceptingInput",
attachmentLayout: "list",
attachments: [...],
},
}
My request is to have the message/activity Id in the response body reliably when the message/activity creation succeeds.
Sep 28 2022 11:34 PM
Oct 04 2022 11:13 AM
@GuillaumeStD - We tried sending message with an attachment using graph explorer and through a bot. In both the cases we can see below in the response.
Response for a bot
{
"attachments": [
{
"contentType": "application/vnd.microsoft.teams.file.download.info",
"content": {
"downloadUrl": "https://m365x654992-my.sharepoint.com/personal/admin_m365x654992_onmicrosoft_com/_layouts/15/download.aspx?UniqueId=94520df7-36a1-4b58-b5ce-074ded665c4c&Translate=false&tempauth=eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAvbTM2NXg2NTQ5OTItbXkuc2hhcmVwb2ludC5jb21AMzZhNzA4ZWYtNzAwZC00ZDYwLTlkZTAtMGE1ZjdiNzY5M2RmIiwiaXNzIjoiMDAwMDAwMDMtMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwIiwibmJmIjoiMTY2NDkwNjU0MiIsImV4cCI6IjE2NjQ5MTAxNDIiLCJlbmRwb2ludHVybCI6Ik8wUW0rZW1XcWkzMHgyU2VUcEdvUGpsVHgySU5vbmxBajJtSS9Cc29rNTA9IiwiZW5kcG9pbnR1cmxMZW5ndGgiOiIxNjgiLCJpc2xvb3BiYWNrIjoiVHJ1ZSIsImNpZCI6Ik1EUTFNekE1TXpFdE1EQmxZaTAwT0Rjd0xXSXlaRFF0WWpCaE4yRXpNelEzTXpRMyIsInZlciI6Imhhc2hlZHByb29mdG9rZW4iLCJzaXRlaWQiOiJabVJtTm1Wak5qWXRPVEl6WWkwME4yVTBMVGt6WlRBdE5qUm1ZekF3WVdVeE1qWmoiLCJhcHBfZGlzcGxheW5hbWUiOiJNaWNyb3NvZnQgVGVhbXMgU2VydmljZXMiLCJnaXZlbl9uYW1lIjoiTU9EIiwiZmFtaWx5X25hbWUiOiJBZG1pbmlzdHJhdG9yIiwiYXBwaWQiOiJjYzE1ZmQ1Ny0yYzZjLTQxMTctYTg4Yy04M2IxZDU2YjRiYmUiLCJ0aWQiOiIzNmE3MDhlZi03MDBkLTRkNjAtOWRlMC0wYTVmN2I3NjkzZGYiLCJ1cG4iOiJhZG1pbkBtMzY1eDY1NDk5Mi5vbm1pY3Jvc29mdC5jb20iLCJwdWlkIjoiMTAwMzIwMDExQUE2RjI1QyIsImNhY2hla2V5IjoiMGguZnxtZW1iZXJzaGlwfDEwMDMyMDAxMWFhNmYyNWNAbGl2ZS5jb20iLCJzY3AiOiJncm91cC53cml0ZSBhbGxzaXRlcy53cml0ZSBhbGxwcm9maWxlcy53cml0ZSIsInR0IjoiMiIsInVzZVBlcnNpc3RlbnRDb29raWUiOm51bGwsImlwYWRkciI6IjIwLjE5MC4xNTUuMzYifQ.L1g3MzhqVlNpeUgrazVISlRpVTZsZFFFblZwUWxGZ3VGeWhhbmRTdlF5OD0&ApiVersion=2.0",
"uniqueId": "94520df7-36a1-4b58-b5ce-074ded665c4c",
"fileType": "png"
},
"contentUrl": "https://m365x654992-my.sharepoint.com/personal/admin_m365x654992_onmicrosoft_com/Documents/Microsoft Teams Chat Files/signin.PNG",
"name": "signin.PNG"
},
{
"contentType": "text/html",
"content": ""
}
],
"type": "message",
"timestamp": "2022-10-04T18:02:25.4863209Z",
"localTimestamp": "2022-10-04T23:32:25.4863209+05:30",
"id": "1664906545384",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer/",
"from": {
"id": "29:1QT50AaMqBsYzEGE5xVhu92Gt-jdb_x2lKt0hrduDCLdBM8wljPfJqvjGNPsU15bPg8i_psUiCGZr-8MVsZ0xQg",
"name": "MOD Administrator",
"aadObjectId": "4ebcc4d0-291b-4154-a85f-a89cd77aefa8"
},
"conversation": {
"conversationType": "personal",
"tenantId": "36a708ef-700d-4d60-9de0-0a5f7b7693df",
"id": "a:1YY_gZHYmENg-dpmwpbAkI240ELNnoF_xKLtRo03Vt917Ym5g5wppjuRSQve0xiD7pqqY9OIsG8ogBXMYUFgNJbLdJgPCMYLDG7tnUTQzGrtbUrW7188iBgp8Uay4Y_oZ"
},
"recipient": {
"id": "28:7ad956d2-7b3c-4769-8792-3236a0618da4",
"name": "appssonpm"
},
"entities": [
{
"locale": "en-US",
"country": "US",
"platform": "Web",
"timezone": "Asia/Calcutta",
"type": "clientInfo"
}
],
"channelData": {
"tenant": {
"id": "36a708ef-700d-4d60-9de0-0a5f7b7693df"
}
},
"locale": "en-US",
"localTimezone": "Asia/Calcutta"
}
Response while sending attachment using Graph -
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('27dd5b6f-0048-4338-acfd-5852b944b714')/channels('19%3A76a3f036b7bf4e6d9641c45347da23a1%40thread.tacv2')/messages/$entity",
"id": "1664904065325",
"replyToId": null,
"etag": "1664904065325",
"messageType": "message",
"createdDateTime": "2022-10-04T17:21:05.325Z",
"lastModifiedDateTime": "2022-10-04T17:21:05.325Z",
"lastEditedDateTime": null,
"deletedDateTime": null,
"subject": null,
"summary": null,
"chatId": null,
"importance": "normal",
"locale": "en-us",
"webUrl": "https://teams.microsoft.com/l/message/19%3A76a3f036b7bf4e6d9641c45347da23a1%40thread.tacv2/1664904065325?groupId=27dd5b6f-0048-4338-acfd-5852b944b714&tenantId=36a708ef-700d-4d60-9de0-0a5f7b7693df&createdTime=1664904065325&parentMessageId=1664904065325",
"policyViolation": null,
"eventDetail": null,
"from": {
"application": null,
"device": null,
"user": {
"id": "4ebcc4d0-291b-4154-a85f-a89cd77aefa8",
"displayName": "MOD Administrator",
"userIdentityType": "aadUser"
}
},
"body": {
"contentType": "html",
"content": "Here's the latest budget. <attachment id=\"7bd0609d-0ca7-41f2-aed9-2f2cbae6cae2\"></attachment>"
},
"channelIdentity": {
"teamId": "27dd5b6f-0048-4338-acfd-5852b944b714",
"channelId": "19:76a3f036b7bf4e6d9641c45347da23a1@thread.tacv2"
},
"attachments": [
{
"id": "7bd0609d-0ca7-41f2-aed9-2f2cbae6cae2",
"contentType": "reference",
"contentUrl": "https://m365x654992-my.sharepoint.com/personal/admin_m365x654992_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7B7BD0609D-0CA7-41F2-AED9-2F2CBAE6CAE2%7D&file=Document2.docx",
"content": null,
"name": "Document2.docx",
"thumbnailUrl": null
}
],
"mentions": [],
"reactions": []
}
Oct 05 2022 05:46 AM - edited Oct 05 2022 05:48 AM
@Meghana-MSFT Thanks for the response.
Unfortunately I can't use Graph API because I need to send messages as my bot and Graph API doesn't support that as stated in MS documentation.
I have 2 questions :
- Can you send the detailed request that resulted in this bot response ?
- You tried sending the message "through a bot", is it via a bot SDK like this one or the Connector API directly ?
Oct 06 2022 07:42 AM
- I used this sample to send attachment to a bot - https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/56.teams-file-up....
- I used bot not connector API.
Unfortunately I can't use Graph API because I need to send messages as my bot and Graph API doesn't support that as stated in MS documentation.
Could you please clarify what your bot and Graph API do not support, your exact requirement? Thank you.
Oct 10 2022 06:08 AM
Hi @Meghana-MSFT , thanks for your response.
@Meghana-MSFT wrote:- I used this sample to send attachment to a bot - https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/56.teams-file-up....
- I used bot not connector API.
- I use nodeJS, so I have tried with this sample, but it has the same issue. The context.
=> Graph API doesn't support sending message as a bot as stated in its docs here (only delegated permissions work, not application permissions) : https://learn.microsoft.com/en-us/graph/api/chat-post-messages?view=graph-rest-1.0&tabs=http#permiss...
@Meghana-MSFT wrote:Could you please clarify what your bot and Graph API do not support, your exact requirement? Thank you.
Oct 11 2022 10:18 AM
Oct 20 2022 03:05 AM
@Meghana-MSFT any update so far ?
Oct 21 2022 09:28 AM
@GuillaumeStD - We did setup the nodejs sample and saw that https://github.com/microsoft/BotBuilder-Samples/blob/b578bbe1127827db86baba670cd0f81e1ae359fb/sample... does not return anything when attachment is uploaded using below option.
Oct 26 2022 01:13 AM
@Meghana-MSFT Exactly, but it should return its message/activity ID since it was posted successfully. Can you request this fix to the Microsoft dev team working on it ?
Oct 26 2022 11:55 AM