file info in attachments field in the request body is missing! when receiving files using bots.

zhongwei_xu 21 Reputation points
2022-09-02T06:54:19.11+00:00

Background

We are using bot service. The Config in Azure Portal is like the picture below.

237182-%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88-2022-09-02-151418.png

When user send some thing to the bot via teams, the bot service will redirect the request to the endpoint which is directed to our server.
User can send normal text and attachment file to the bot.
237126-chat-with-bot.png

When user send text and attachments file to the bot
Our message endpoint will get the request from bot service and the body is like this

   2022/09/02 06:29:08.034127 DEBUG RESTY   
     
   ==============================================================================  
     
   ~~~ REQUEST ~~~  
   POST  out message endpoint  HTTP/1.1  
   HOST   : host.docker.internal  
   HEADERS:  
   	Accept: application/json;charset=utf-8  
   	Content-Type: application/json;charset=utf-8  
   	User-Agent: go-resty/2.3.0 (https://github.com/go-resty/resty)  
   BODY   :  
   {  
      "type": "text",  
      "session_id": "teams::conversationID",  
      "text": "text with attachment",  
      "data_config_index": "8",  
      "location": "location url",  
      "original_request": {  
         "from": "teams",  
         "body": {  
            "text": "text with attachment",  
            "type": "message",  
            "timestamp": "2055-10-02T06:29:02.4103628Z",  
            "id": "id",  
            "channelId": "msteams",  
            "serviceUrl": "https://smba.trafficmanager.net/jp/",  
            "from": {  
               "id": "id",  
               "name": "name",  
               "aadObjectId": "id"  
            },  
            "conversation": {  
               "conversationType": "personal",  
               "tenantId": "tenantId",  
               "id": "id"  
            },  
            "recipient": {  
               "id": "id",  
               "name": "name"  
            },  
            "channelData": {  
               "tenant": {  
                  "id": "id"  
               }  
            },  
            "attachments": [  
               {  
                  "content": {  
                     "downloadUrl": "downloadUrl?Version=2.0",  
                     "fileType": "png",  
                     "uniqueId": "uniqueId"  
                  },  
                  "contentType": "application/vnd.microsoft.teams.file.download.info",  
                  "contentUrl": "https://xxxxxxx-my.sharepoint.com/personal/xxxxxxxxx/Documents/Microsoft Teams Chat Files/attachments.png",  
                  "name": "attachments.png"  
               },  
               {  
                  "content": "\u003cp\u003etext with attachment\u003c/p\u003e",  
                  "contentType": "text/html"  
               }  
            ],  
            "entities": [  
               {  
                  "country": "country",  
                  "locale": "local",  
                  "platform": "Web",  
                  "timezone": "somewhere in earth/somewhere in earth",  
                  "type": "clientInfo"  
               }  
            ],  
            "locale": "somecode-somecountryCode"  
         }  
      }  
   }  

Issue Case

Describe

But some time when user send a attachment file to the bot, file info in attachments field in the request body is missing!
This is seldom occurred but it does occurred. We checked the error log on our server but no thing happed when the strange case happened.
And from our request log, we can see that the body in the request is unusual.
So we are doubting that is it caused by the reason that the rate limit for file attachment is reached and bot service stopped to deal with the attachment file?

   ~~~ REQUEST ~~~  
   POST  out message endpoint  HTTP/1.1  
   HOST   : host.docker.internal  
   HEADERS:  
   	Accept: application/json;charset=utf-8  
   	Content-Type: application/json;charset=utf-8  
   	User-Agent: go-resty/2.3.0 (https://github.com/go-resty/resty)  
   BODY   :  
   {  
      "type": "text",  
      "session_id": "teams::conversationID",  
      "text": "text with attachment",  
      "data_config_index": "8",  
      "location": "location url",  
      "original_request": {  
         "from": "teams",  
         "body": {  
            "text": "text with attachment",  
            "type": "message",  
            "timestamp": "2055-10-02T06:29:02.4103628Z",  
            "id": "id",  
            "channelId": "msteams",  
            "serviceUrl": "https://smba.trafficmanager.net/jp/",  
            "from": {  
               "id": "id",  
               "name": "name",  
               "aadObjectId": "id"  
            },  
            "conversation": {  
               "conversationType": "personal",  
               "tenantId": "tenantId",  
               "id": "id"  
            },  
            "recipient": {  
               "id": "id",  
               "name": "name"  
            },  
            "channelData": {  
               "tenant": {  
                  "id": "id"  
               }  
            },  
            "attachments": [  
               // Where is our attachemt file info?  
               {  
                  "content": "\u003cp\u003etext with attachment\u003c/p\u003e",  
                  "contentType": "text/html"  
               }  
            ],  
            "entities": [  
               {  
                  "country": "country",  
                  "locale": "local",  
                  "platform": "Web",  
                  "timezone": "somewhere in earth/somewhere in earth",  
                  "type": "clientInfo"  
               }  
            ],  
            "locale": "somecode-somecountryCode"  
         }  
      }  
   }  

We should get item with the contentType of "application/vnd.microsoft.teams.file.download.info" but we didn't.
The following attachment info is missing

   {  
                  "content": {  
                     "downloadUrl": "downloadUrl?Version=2.0",  
                     "fileType": "png",  
                     "uniqueId": "uniqueId"  
                  },  
                  "contentType": "application/vnd.microsoft.teams.file.download.info",  
                  "contentUrl": "https://xxxxxxx-my.sharepoint.com/personal/xxxxxxxxx/Documents/Microsoft Teams Chat Files/attachments.png",  
                  "name": "attachments.png"  
               },  

This is unexpected case as the formal document described that "Your bot will then receive a message activity notifying you of the user upload. The activity will contain file metadata, such as its name and the content URL. You can directly read from this URL to fetch its binary content."

https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bots-files#message-activity-with-file-attachment-example

Does anyone occurred into this case? Or does anyone knows about the reason why this case could happen?

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
743 questions
Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,033 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,826 questions
{count} votes