Is there a way to implement the countdown feature for the slack message using Slack API?
The message should only be valid for specified amount of time and then it should disappear or stop user interaction with it.
Yes technically this is possible. To display the countdown you need to use two methods, that is chat.postMessage and chat.update. chat.postMessage is for posting the initial message that contains the full counter say 5 minutes. After the initial message is posted you will need to run a loop in you code that updates the initial message with the depreciating value (4 minutes, 3 minutes and so on) using the chat.update method. After the countdown ends you can now delete or update the blocks to remove the interactions (buttons and so on). I hope that provides some insight.
Related
I'm trying to notify a user that a custom action is about to take place. I thought making a story where a simple utterance followed by that action would be enough.
## Story changeModel
* changeModel
- utter_model_changing
- changeModel
I want the previous bot to say goodbye, a wait, then the next bot to say hello. At the moment though, the wait happens immediately after the user message, then the two bot messages come back concatenated.
E.g.
"change the model"
long wait
"
Please wait while I get the new bot online.Hey, New Bot here. What can I help you with?"
I've also tried putting multiple dispatcher.utter_message(msg) statements in my custom action but this has the same result as above.
How can I send a message and have it appear for the user before the long custom action is executed?
How to send Is Typing notification from bot application until bot process another response. I can see currently it is limited to 3 seconds, but I want to extend it until the next response come back from Bot.
Can anyone help me with this? I have seen a couple of approaches where they recommend showing recursively until your task finish its execution but not sure how to Implement this.
Currently, this is not a feature of bot framework. You cannot control the length of time of which the typing indicator is displayed for. Your best bet is to try to resend the typing indicator as many times as needed until you long-running task is completed. This will be a custom solution that there may already be examples of out there.
You can send the typing activity every couple seconds while your processing runs asynchronously. This uses a bit of extra bandwidth, so your call. e.g.
var search = searchclient.Documents.SearchAsync(query);
var typing = turnContext.Activity.CreateReply();
typing.Type = ActivityTypes.Typing;
do {
turnContext.SendActivityAsync(typing);
} while (!search.Wait(2000));
var results = search.Result.Results;
Or set the wait to 4 seconds, or a random number between 2 and 5 seconds, so it looks like the bot is typing a little, thinking, then typing more...
Virtually all chats employ forms of faking the "real time" presence of the typing indicator. You are best to not even try, instead letting it vary randomly at the client side, and heuristically altering to your own logic, and have any end event cancel it. Especially if your API footprint is part of your operating cost.
What happens, if I send multiple ShellToast notifications from background agent at once, for example in ToDo list app I want to notify that 3 tasks should be finished today?
Is it allowed or recommended? Would the user see all three toasts or only the first one?
The scheduled agent only runs once and it's up to you to manage which toast will be shown. In those scenarios you should be using a counter...possibly.
The way I've worked around this sort of thing in the past is just track a time or which toasts have been shown in sort of a queue and just show one every update so you could just rotate through your queue throughout the day until the tasks in app are no longer valid. Or, based on the phone's time, determine what to show (they fire every 30 min or so).
Ultimately, the optimal way is probably having one toast that says "You have 3 tasks to complete" etc etc.
Hope one of those solutions might help!
// Jed
I'm using the autocomplete component from richfaces. (the mode has to be ajax).
I have the following requirement: after the user types something in it the request should no go directly to the server, instead it should wait a period of, lets say 500 ms, before the autocomplete method gets called. This is to prevent ajax flooding (for example if the user types fast 3 chars it will only make one request to the server instead of 3).
Basically I want the autocomplete method to get invoked only if 500 ms have passed from the last keystroke.
Of course this could be solved by using an a4j:queue, the problem is that the suggestions list always appears and the autocomplete method always get invoked regardless of what I use to prevent it (attaching an a4j:queue or setting frequency, eventsQueue & requestDelay attributes).
Any ideas would be greatly appreciated.
The frequency tag you mentioned is the way to do it. It is defined as: Delay (in seconds) before activating the suggestion pop-up. Default value is 400ms.
If you're setting your frequency to 500ms that is still too short: the user can type more than 1 characters in that time period, which is probably causing your ajax flood.
I suggest you set the frequency to 1000 or better yet 2000.
I have a simple, custom rolled chat here: ( http://ninjawars.net - essentially: ajax chat, php backend, javascript listing of chat messages, logged-in user input only ) that suffers from being able to be spammed. What are some simple systems to prevent spamming of a chat?
One thing (lowest level of protection) that I have already implemented:
Ignore consecutive duplicate messages from the same user.
Other ideas that I have:
Add consecutive messages from the same user together, instead of creating a separate message line. (relatively simple to implement, decreases the effect of spam but doesn't prevent it)
Prevent continued messages after a certain number of consecutive messages from one user, for new users. (relatively simple to implement)
Chat moderation by trusted users (complex to implement).
Are there any simple systems/algorithms to prevent chat message spamming that I should know about?
Put an increasing delay on how fast a user can reply. So after each message post store next_reply_time as a timestamp of NOW + 1 second. If they reply before the time has reached, ignore it and give a "Reply too fast" warning and set the next_reply_time to NOW + 2 seconds, and so on. This way if they stack up messages too fast, you'll ignore them for longer periods of time. This delay can of course be based on reputation.