1
votes

We have integrated the NodeJs bot application with the bot framework for interacting with bot in the Microsoft teams.

Based on the user input we are sending the adaptive cards respectively. Currently user can get the adaptive card today and can update the card later that day or after few days.

Is there any way to make the card expire after specific amount of time which make the card disabled.

Thank You

3
This is a cool question, definitely not something I've tried before! I've put a suggested answer below - Hilton Giesenow
You might consider suggesting this as a feature for my cards library: github.com/BotBuilderCommunity/botbuilder-community-dotnet/… - Kyle Delaney

3 Answers

3
votes

I have an idea how you could do this, but just an fyi that I've not done exactly this before, so there's no guarantee it will work. Basically, you'd be combining the ability to Update a message like discussed here with sending (or in this case 'updating') a pro-active message - see more here on that.

Because this is an existing conversation with the user, you'll have access from any existing message the user sends to get the parameters you need to start your proactive conversation (you need serviceurl, conversationid, tenantid, etc.). Do note that you can send a proactive message from OUTSIDE your bot (the code can be hosted somewhere else, and doesn't need to actually live IN your bot, even though to the user it will appear as if a proactive message was sent from your bot). I mention this because you could have this "expire card" message live in a separate process to your bot.

2
votes

In case if you are still looking for an answer, I recently tried this approach:

In the card's response data, I set the expiry date and so now when the user submits the card, you can validate the data in the response and then update the card accordingly.

I had to use this approach because we have a very high user base and updating the card for all users proactively took much longer.

Cons: The card will remain will remain active, unless and until the user takes some action on it.

1
votes

First of all, no this is nothing that is already implemented anywhere and you completely have to build that yourself.

One way to do this is this:

  1. You need to store the activity / message ID for all cards you send. If you have the ID, you can always at any time go back and update the message (ie update your card)
  2. Now that said, what i would suggest is this:
    • Sent a card to the user and store the id
    • Store the ID together with creation date and expiration date somewhere on your end
    • Have some scheduled process that scans for expired cards
    • If a card is expired, update the message with a new card saying "sorry this card is expired"

We did that for our MS Teams Bot and its working quite well this way.