What does cache_time do in telegram's answerCallbackquery API? - caching

The explaination in the official docs is given as -
cache_time - Integer Optional. The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14.
Defaults to 0.
So if someone clicks on the callback button what does sending cache_timein answerCallbackquery do? I didn't understand the official docs explaination.
Official docs- https://core.telegram.org/bots/api#answercallbackquery

For example a user has already clicked on an inline button and your bot responded with a message, if that user clicks on the button again within cache_time, telegram may show the same message without bothering your server for cache_timeseconds.
In your last question about limiting user clicks on inline buttons, you can also set cache time to avoid telegram sending callback_query to your server.

Related

Slack API: Interactivity components not do not work posting message as real user

I'm trying to include block kit interactive components such as textboxes and buttons in a slack message that is sent via the API.
The buttons work perfectly when the message is sent by the bot and not impersonates a real user. But when posting as a user (I.E. Setting set_user as true when calling the chat.postMessage API endpoint), the buttons show up but do not work.
It seems that slack does not make an HTTP request to the "Interactivity request URL" specified in the Slack App's configuration.
Has anyone managed to get it to work?
Thanks
Do you mean to say the interactivity is not working when you use the as_user parameter on chat.postMessage? If that's the case then the issue is that this parameter, as_user is not supported for newer apps. In other words it's a legacy parameter that shouldn't be used. If you want your app to post as another user you will have to add the chat:write.customize scope. See the documentation about authorship.

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.

Dialog Event that First on Bot Response

BotFramework documentation refers to handling user interruption via OnContinueDialogAsync event, which first when user sends a response but before it hits the dialog.
I was wondering if there is an event that fires when Dialog completes a step but before it is returned to the user. Reason I ask is because I need to sanitize the response to the user through an additional layer, and want it to fire for all bot responses.
Middleware was designed, and can be used, for exactly this scenario.

How to update an existing activity in WebChat

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!

How can i ignore user messages in MS Bot framework using direct line channel

I have created a bot in one scenario it will call an API and it will take same time to get the output from that API, if in between user type anything it will start working on the text which user sent recently. I want till API output is not received, if user sent any messages it will get ignored.
If your bot is integrated into some app then you can actually disable the send button until you receive an answer for the previous question.
I am setting one session when user is requesting to talk with Live Agent, Then i am checking if that session is in progress and any new message is coming from user then i am just ignoring them.

Resources