"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.
Related
Can we add & delete input fields dynamically in an Adaptive Card?
We need to have button called as "Add New", as user clicks on button it should keep adding input fields along with a delete button next to it.
We are using composer based bot with .Net SDK for bot development.
I don't think there is anyway to do exactly what you are seeking. But perhaps some combination of ShowCard and ToggleVisibility?
Either way, it will be done via the adaptive card. No way to do this in the bot framework side (unless you are using a channel that supports updating/replacing an entire activity in which you would just send a whole new card).
How to read choiceset values in Bot that are selected in Bot Adaptive Card, I am using Bot Composer to develop the Bot. I need multi select, so used Adaptive card and used send response in bot composer dialog to display the adaptive card. But not able to read the value in subsequent actions in the dialog. Amy samples/ references based out of Bot Composer.
More details are needed as mentioned.
You should review the response from the user in Botframework Emulator, and then inspect to see what the return values look like.
You can then retrieve it in the bot with something similar to =turn.activity.value._answer_ (answer here was just a sample of what that may be. Your data will be different of course).
I think you are trying to save the user selection from adaptive card.
You can use Ask a question --> Text template, instead of using send response.
In Prompt for text section you can use HeroCard/AdaptiveCard. In User Input section declare a variable that will store the user selection coming from HeroCard/AdaptiveCard. Depending on the variable scope you can reuse the stored data in the variable later in the conversation.
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
My scenario is: I send card attachments each with an AcceptButton to users. When 1 user clicks on that button, ideally I want to disable all similar buttons (of the same offer) for all users. I am storing conversation details of each user, and I know the ActivityId of each message-with-said-button (it follows a certain string format).
My issue is similar to this and this but for WebChat not Teams.
I did try those solutions but I got the error "Method not allowed" for both UpdateActivityAsync() and DeleteActivityAsync(). Then I read here that UpdateActivity is not supported in WebChat. (But might be available in the future?)
I would like any visual indication that the offer is no longer available. (Right now, they receive an "Offer was already accepted by {UserX}" which would still be in place on top of changing the card/message.)
Is there a way to do this via backChannel? I can trigger an event and pass the ActivityId (tested by showing a simple alert()) but how do I apply changes to that specific activity?
Per this comment in Web Chat's source code and this open issue in the Web Chat repository for adding support for deleteActivity and updateActivity, Update Activity events are not currently supported in Web Chat. Unfortunately, there is currently no way to really update an activity in Web Chat.
Hope this helps!
I read through this https://learn.microsoft.com/en-us/azure/bot-service/dotnet/bot-builder-dotnet-state about saving state data. I have some questions regarding the same:-
Lets take a bot exposed through the browser channel as an example here:-
What is the lifetime of the data stored? For instance when the bot saves data using context.ConversationData.SetValue(..) Is the data purged when the session is over(when the user refreshes the page)?
The From object from Activity has Id and Name. Are these generated by the channel each time a chat session begins? For instance, if I was chatting with bot then refresh the web page, now will my Id and Name have changed?
Same question about conversation. If I refresh the page and begin the conversation again, do I get a new conversation ID?
I read in some blog that if you use dialogs, the dialog stack state is automatically saved in whichever storage you have configured. Is this correct? If so, why? Say I refresh the page, will I be able to retrieve the state of the dialog stack and resume the conversation from there?
If you are giving code samples, request you to give C# samples if possible
Thanks very much in advance!
Hi, I hope below answer will find useful to you :
1.
What is the lifetime of the data stored? For instance when the bot saves data using context.ConversationData.SetValue(..) Is the data
purged when the session is over(when the user refreshes the page)?
ANS:->
As per the guidelines by Bot Framework, State API is in the state of depreciation. you will have to use your own state management service to maintain the state of your Bot. Ref: https://learn.microsoft.com/en-us/azure/bot-service/dotnet/bot-builder-dotnet-state
So assuming you are using Table Storage or SQL Database for storing your bot in this case the data will persist as long as your storage account and database available.
2.
The From object from Activity has Id and Name. Are these generated
by the channel each time a chat session begins? For instance, if I
was chatting with bot then refresh the web page, now will my Id and
Name have changed?
ANS:->
This depends on how you initialize the chat. for instance, if you are using
Web chat : It will be empty id.
Skype : It will be skype id and user name
DirectLine : you can define your own id and name as per your need.
3.
Same question about the conversation. If I refresh the page and begin the conversation again, do I get a new conversation ID?
ANS:->
Yes. Every time you refresh your webpage you will be assigned new conversationId but in case of DirectLine you can use the previous conversation id to maintain the history of your conversation. you can store the conversation id in local storage or in browser's cookies and read whenever you feel to load the chat history. If you don't need history to be preserved then I suggest let webchannel handle its own ids.
4.
I read in some blog that if you use dialogs, the dialog stack state is automatically saved in whichever storage you have configured. Is this correct?
ANS:->
Yes.
5.
If so, why? Say I refresh the page, will I be able to retrieve the state of the dialog stack and resume the conversation from there?
ANS:->
As hinted earlier, you will need to migrate your bot to use DirectLine API instead of webchat channel. As webchat doesn't support history so DirectLine.
Please refer the guidelines provided by Microsoft and Samples provided on GitHub.
https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-concepts
Quick answers:
As far as I know, there is no purge. And you can check the implementations of Azure DocumentDbBotDataStore or TableBotDataStore here. Based on my implementations, I saw there is a Timestamp column in the stored data so you could do cleanup based in that.
Generation of Id and Name fields (for From, but also for Recipient given the message origin / destination): yes they depend on the channel. I made a detailed answer about on SO: Bot Framework User Identification
Yes in the webchat's case
Yes, the dialog stack state is saved so that you can continue your conversation. "Say I refresh the page, will I be able to retrieve the state of the dialog stack and resume the conversation from there?": if you have the same details (channelId + conversationId, userId) you should yes. The exception is the webchat / directLine where you have to implement the fact that you keep the same IDs. For other channels like Slack, Facebook Messenger etc, these items remains the same and the dialog can continue where it stops on the previous messages exchange