Forum Discussion
MessageId undefined when creating a message
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": []
}
- GuillaumeStDOct 05, 2022Copper Contributor
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 https://learn.microsoft.com/en-us/graph/api/chat-post-messages?view=graph-rest-1.0&tabs=http.
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 https://www.npmjs.com/package/botbuilder or the Connector API directly ?- Meghana-MSFTOct 06, 2022Former Employee
- I used this sample to send attachment to a bot - https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/56.teams-file-upload.
- 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.
- GuillaumeStDOct 10, 2022Copper Contributor
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-upload.
- I used bot not connector API.- I use nodeJS, so I have tried with this sample, but it has the same issue. The context.
sendActivity() method doesn't return the created activity ID when the created activity contains attachments : https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/javascript_nodejs/56.teams-file-upload
- For your information, bot sdk uses the Connector API under the hood, so by using the bot sdk, we are using the Connector API.
=> 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#permissions
Meghana-MSFT wrote:Could you please clarify what your bot and Graph API do not support, your exact requirement? Thank you.