How to get attachements attached to a chat done with azure-bot

Maayan Hope 21 Reputation points
2022-10-06T13:57:29.207+00:00

Hi
We have an application connected to a BOT using azure bot service
The Bot is connected to MS-Teams

We have configured the "endpoint" of the bot to our server, meaning that when a user tags the Bot we get notified in our server about this actions.
This is all working fine

Now, the user may also upload an image and send it to the bot (tag the bot)

we are expecting to get the "URL" of the attachments in the "Activity" notification
But we "attachments" member does not contain this

this is how it appears in the activity class:
@JsonProperty("attachments")
@JsonInclude(Include.NON_EMPTY)
private List<Attachment> attachments;

this is the dependency we use

<dependency>
<groupId>com.microsoft.bot</groupId>
<artifactId>bot-integration-spring</artifactId>
<version>4.14.0</version>
</dependency>

Any ideas? maybe issue with permissions?

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
841 questions
Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,302 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.
3,334 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Prasad-MSFT 6,876 Reputation points Microsoft Vendor
    2022-10-07T08:05:25.587+00:00

    When a user sends a file to your bot, the file is first uploaded to the user's OneDrive for Business storage. 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.
    Ref:
    https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bots-files#message-activity-with-file-attachment-example

    Thanks,

    Prasad Das


    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.

    1 person found this answer helpful.
    0 comments No comments

  2. Maayan Hope 21 Reputation points
    2022-10-09T14:55:19.147+00:00

    Thank you for your answer
    Do I need to set some special permission to get this activity, since we print all the incoming activities in the log and we do not see such activity coming in

    Thanks


  3. Maayan Hope 21 Reputation points
    2022-10-11T09:38:51.397+00:00

    Hi

    from what I read now in the note in the "Using the Teams Bot APIs" section
    "This method works only in the personal context. It does not work in the channel or groupchat context."

    So , when tagging the bot in a channel or group chat, Is there a way to get the files that were attached?

    Our bot must have these scopes: : "personal","groupchat","team"
    we should get information about attachments also in the "groupchat" and "team" scopes, and we get it only when in "personal" scope

    Is there a way to get notified about attachments also when tagging the bot inside a group chat?

    Thanks


  4. Maayan Hope 21 Reputation points
    2022-10-24T07:11:13.447+00:00

    Hi @ Prasad-MSFT
    From the help page you have sent we see that using "Microsoft Graph APIs" we should be able to get attached files also for channel and groupchat
    Do you know how it is done?

    Can I list using the "Microsoft Graph APIs" all the messages in a chat? or only the last message?

    If yes, I will be able to list new messages when I get notified about new messages in the chat (Activity hook)

    Or do you think that there is other way ?

    Do I need to use "teams-protected-apis" ?
    https://learn.microsoft.com/en-us/graph/teams-protected-apis

    Thanks


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.