简体   繁体   中英

equivalent for Suggested actions in Microsoft Teams

Suggested actions are not supported in teams, I get that. People are suggesting to use cards. I get that too. Now let's be more specific. I want to make a card that will behave in the same way that suggested actions behave, specifically:

  1. it would not have the stupid formatting (line on top)
  2. it would disappear or at least hide the buttons after the user makes a selection
  3. it would send the value of a pressed button to the server, and display it in the chat window.

Here is what I have so far, and it doesn't seem to be doing the trick:

  actions = []
  for button in buttons:
    actions.append(
      CardAction(
        #type=ActionTypes.message_back,
        type=ActionTypes.im_back,
        value=button,
        title=button,
        text=button,
      )
    )
  
  #     card = CardFactory.adaptive_card(
  # {
  #   {
  #     "type": "Action.Submit",
  #     "title": "Click me for imBack",
  #     "data": "Text to reply in chat"
  #   }
  # }
  #     )

  card = HeroCard(buttons=actions)
  await self.global_tc.send_activity(MessageFactory.attachment(CardFactory.hero_card(card)))

在此处输入图像描述

It's been possible for a long time to update the content of an existing message that a bot has sent already, by passing the Action Id back as part of your payload, but there's another option more recently as well in the form of Universal Actions, which let you modify the state of the 'form' after an action has been taken. They only apply to Adaptive Cards, not Hero cards, but what you're doing in your screenshot is more applicable to Adaptive Cards anyway.

Please see here for more info: https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/universal-actions-for-adaptive-cards/overview?tabs=mobile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM