finos / spring-bot

Spring Boot + Java Integration for Symphony/Teams Chat Platform Bots and Apps
https://springbot.finos.org
Apache License 2.0
61 stars 35 forks source link

Spring bot support file upload feature in MS Teams app #445

Open vaibhav-db opened 1 month ago

vaibhav-db commented 1 month ago

Support file upload feature in MS Teams app

Description of Problem:

User can upload files in MS Teams with App.

Potential Solutions:

Our goal is to land this upload file in @ChatReuest controller method

In framework we need to modify complete flow. like MessageActivityHandler --> ActionConsumer --> ChatHandlerMapping --> @chatRequest

vaibhav-db commented 1 month ago

@robmoffat we will discuss on today meeting. I had also sent detail over mail, as i was not able to attached the images here.

robmoffat commented 1 month ago

image003

robmoffat commented 1 month ago

How to get attachments into SimpleMessageAction:

  1. SimpleMessageAction would need to have attachments as another property.
  2. For Symphony, we'd add the attachments to SimpleMessageAction in PresentationMLHandler
  3. In Teams, MessageActivityHandler does the same job. So we need to exclude the HTML attachment (which is the message) and add the others to the SimpleMessageAction attachments property from (1)
robmoffat commented 1 month ago

How to get from SimpleMessageAction to controller parameters:

  1. You need a new Resolver factory, copy FormDataArgumentWorkflowResolverFactory for an example.
  2. You need match on the parameters, so we need to decide what type the controller will use to indicate an attachment. Might be best to create a class:
interface IncomingAttachment {

  String getName()

  InputStream getContents()

}
  1. In the controller, you'd have a method like:
respondToAttachments(IncomingAttachment one, IncomingAttachment two) 

-or-

respondToAttachments(List<IncomingAttachment> one) 
  1. The new resolver factory would match to this IncomingAttachment type, and create objects from the SimpleMessageAction to fill out the parameters.