Teams Chatbot,Adaptive Card text clears on Teams Page Refresh - botframework

Working on a chatbot with botframework on teams, while testing we noticed the Adaptive card input texts clears,when teams chat is refreshed(i.e if we scroll up or if we switch to some other chat in the window and switch back) before submitting the card.
I guess this probably has something to do with page refresh,Could there be any workaround for this?
Note:-Earlier faced a diff type of issue where after clicking submit on adaptive card the text vanishes but that was resolved via replacing the card with the values/Text with update activity.
Since this is totally teams UI end,Any possible solutions?

Text from Adaptive card is cleared out on Submit. This is the default behaviour. However, all the values you send from the card will be shown up under turnContext.activity.value

Teams clears out the data from Adaptive Cards on submit, that is inbuilt. However you can work around this by instead updating/re-populating the card with the user input.
See this answer to know how to repopulate cards

Related

Mark an Adaptive card posted via Incoming webhook in MS Teams as done

We get messages/tasks from an external PHP-server via incoming webhook in a Teams channel. They are posted in the Adaptive Card format using the 'message with attachments' method.
I would like to find a possibility to mark these messages as done.
My idea would be that the message has a button, that turns green and maybe changes the text when clicked. This has to be permanent. Also the text of the card should be hidden.
I tried to implement a button that toggles the visibility of the card, but it turns out the toggle is not persistent but gets reset every time the channel is opened.
As a workaround we are using reactions at the moment, but I would like to find a more obvious way.
Obviously an incoming webhook does not support the use of Action.Submit (as stated in the link above). So I cannot obviously update the card with this method.
I was thinking to use the Post adaptive card and await answer -method from Flow, but it cannot post an answer to a post, but only post a new card, so the context is missing, which of the posts in the channel you ant to mark as done.
A Power automate Flow could achieve this, if it could be told to alter the posted message.
I realize that it is actually a Task I want to post, not necessarily a message/card in a Teams channel. But there seems no way to post a new task directly to a Tasks tab in a Teams channel via an incoming webhook?
Has anybody an idea what technique could be used to achieve my goal?
This is possible using Actions with O365 connector card format, and is not a currently supported feature in Adaptive cards,
Ref Doc: ⁠Create and send messages - Teams | Microsoft Docs
Could you please raise an User Voice

How do I change the Adaptive card once the user input is submitted?

Though there were few questions regarding the similar, I don't see any working solution.
I am working on a BOT for a feedback. Currently the user is able to send multiple responses by clicking on the options provided in the adaptive card. I am trying to replace the adaptive card with a plain adaptive card that just has some plain text like , "You have chosen option 3".
The following from the link provided in above comments by subbu helps in resolving the same.
var activity = MessageFactory.Attachment(card.ToAttachment());
activity.Id = turnContext.Activity.ReplyToId;
await turnContext.UpdateActivityAsync(activity, cancellationToken);
We went with just deleting the card & sending a default response once user submits as that was enough.

How to create MS Teams Survey App Messaging Extension

I am currently creating a survey app for ms teams similar to Polly.ai/survey monkey
The flow would be
User installs app,
app appears as messaging extension on the chat window,
user clicks app to opens page to create survey,
on submit an adaptive card is generated,
the same is responded back to teams,
The new card appears on the message Hi,
I am currently creating a survey app for ms teams similar to Polly.ai/survey monkey
The flow would be
User installs app,
app appears as messaging extension on the chat window,
user clicks app to opens page to create survey,
on submit an adaptive card is generated=>
the same is responded back to teams =>
The new card appears on the message create pane,
User hits enter to post the survey to the group,
All the group members respond to the survey ,
The same is logged
Can anyone help me in providing some links from where I can start.
Or maybe throw some light on what should be my approach.
My progress so far.
Created a teams bot,
On messaging extension invoke returned url that contains HTML for survey creation which is created in vue.js. Used msteams js to submit the json for created survey back to the bot,
Generated an adaptive card with json received and the a new survey created in db,
Sent the card back to teams as message attachment,
The card is displayed in message create pane,
User hits enter to post the card in the group,
Caught the action.submit event from adaptive card on bot framework.
Also, please note while I am generating the card I don’t have user email in the turncontext as well.
Please throw some light on this
Thanks
Please have a look at App templates available. I think for your case Poll and Survey are the best app template available.
Thanks

Data is getting wiped out once submit action taken on adaptive card

"adaptivecards": "^1.2.6",
We are using adaptivecards package with bot framework in spfx solution.
Reference link: https://github.com/pnp/sp-dev-fx-webparts/tree/master/samples/react-adaptivecards
Details
Data is getting wiped out once submit action taken on adaptive card. We are using below adaptive card package:
"adaptivecards": "^1.2.6",
Issue
a. When a user provides inputs to cards all data are seen whatever user has provided as input.
b. As soon as a user submits an action button on that, a request is submitted to bot with all user input data.
c. An issue is all user input data are wiped out.
Before Submiting Card:
After submit card get reset
This isn't a thing that happens in Web Chat. It used to be a thing that happens in Teams, but it seems like they changed the Teams behavior a while ago. The only reason this could happen in Web Chat is if you wrote custom code to make it happen in Web Chat. Out of the box, Web Chat simply doesn't have this problem.
My recommendation is to remove the code that's resetting your input fields. Failing that, you can write new code to set the input fields based on the submitted data.

Chat history Persistence in MicroSoft Botframework WebChat window

I have a requirement of maintaining chat history and loading them back in a window after a page refresh or close and opening of the window.
ISSUE : Buttons/carousel/Adaptive cards/Hero Cards events/ properties are not loading (ie; when I click on button or any event, actions are not happening).
DESCRIPTION:
In order to achieve the requirement i had 2 options.
BotFramework _ Directline JS
I guess using this we can only get conversation history and where we couldn't load back the conversation history in chat window.
Though we can get the conversation history we have to send all the messages to bot again.
So i had opted 2nd one.
Store the html controls and Load it in the bot div: When sending or receiving message action is happening from bot am storing the html controls(i.e; controls under wc-message-groups class in local storage) and binding back to the div on page load if data exists.
This works for me to show conversation history in a chat window. But I am not able to get the events/actions for buttons.
Can we do this with Directline JS or is there any option to load properties/events to controls?
Please help me with this issue.
Thanks in Advance
I would start by taking a look at this thread out the Webchat GitHub repo. There is a good discussion going on about how this may be accomplished.
I also created this project in C# using webchat which will provide chat history in the webchat control. The project uses this pull request branch which you would also need to use. Hope this helps, good luck.

Resources