finos / spring-bot

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

Teams Cards? #371

Closed nmwael closed 1 year ago

nmwael commented 1 year ago

Hi guys,

How can I use something like (adaptive-card) this:

https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference

Should I just instantiate it and return it in a chat method? Or ?

robmoffat commented 1 year ago

Hi Nino,

All of the example bots will render their forms using adaptive cards. Claim Bot, Broadcast Bot are good ones to look at the code for - just check the examples part of the repo.

Generally, when Spring Bot needs to display a form, it creates one on-the-fly by reflectively examining the object being sent.

Whenever Spring Bot creates an adaptive card form (or any other template) it'll be output at runtime to stdout by default. This is useful because it allows you to capture that template and then load it up in a tool like this one: https://adaptivecards.io/designer/

You can customise the adaptive card template however you want and then save it into the src/main/resources/templates/teams directory of your bot.

Use the @Template annotation on the bean to tell Spring bot to use your template instead of generating one.

A good example of where this is done is the poll-bot in the tools directory. Take a look at Question.java and see how it sets the template up.

Does that help?

nmwael commented 1 year ago

thanks thats right on the spot!