Kik bot is triggering "TooManyRequests" error in BotFramework - azure

I recently deployed a bot using Azure and BotFramework to Skype, Slack, Telegram and some other platforms.
They all seem to work fine, except in Kik, where the bot will suddenly stop responding. The error message in BotFramework reads:
{"message":"Too many requests for user: 'redacted_user_name'","error":"TooManyRequests"}
The Kik tester is triggering this error through regular use, though when I test it on my (Android) phone, it works just fine.
Any idea what might be causing this?
EDIT:
After contacting Kik, I was told that my Bot was sending more messages than it was recieving, and they only allow a surplus of 20 before a bot becomes banned.
They say the solution is to implement batching, which BotBuilder says is built in. (My bot uses session.send("text") followed by a prompt.) However, Kik does not see my messages as a batch, and every couplet is counting as 2 messages.
I tried adjusting the autoBatchDelay to see if 0 would work better than the default and noticed that it did not make a difference. Furthermore, changing it to 2000 also made no difference, and did not delay 2000ms between messages.
var bot = new builder.UniversalBot(connector, {autoBatchDelay: 0});
Is it possible my bot is not batching properly? What steps could I take to address this?

Batching for Kik is currently on our backlog. In the mean time, is there any reason you can't send your text and prompt in the same message (with carriage returns in between if needed)? That should resolve your issue (as I understand it).
Also worth noting that the Kik rules for recovering from a throttling deficit are somewhat complex.
• In any given send message request, a bot can send up to 25 messages in a single POST request. Within the 25 messages, a bot is allowed to have up to 5 messages directed to a single user.
• Whether you send 1 message or 5 messages, that collection of requests is considered a “batch” of messages to a user.
• A bot is allowed 20 unsolicited batches to a user a day.
• This means you could be sending between 20-100 unsolicited messages to a user a day depending on how many messages you have in a batch. How the bot platform determines unsolicitation works like a debit/credit system that resets at the end of a day. e.g. Julie sends the bot a message, the balance becomes +1. The bot responds with 3 messages in one batch, the balance becomes 0. Julie sends the bot 1 message, the balance becomes +1. The bot responds with 5 messages in separate batches, the balance becomes -4. Julie sends the bot a message, the balance becomes +1. The bot responds with 5 messages in separate batches, the balance becomes -9.
• If this deficit continues to -20, the daily user rate limit will have reached, and the bot will NOT be able to send any more messages to that user. There are different methods to work with this rate limit, e.g. using batches more efficiently or building a UX that encourages more user interactivity.

Related

Telegram cli bot with pyrogram limits

I use the pyrogram library to develop the client robot, I set it up so that the robot connects to 15 phone numbers and sends messages in order with its proxies.
These 15 accounts are members in 300 joint groups! , every 15 accounts will be activated, respectively, and the text they have to send will be sent to these 300 groups.
In the form of the following process :
The first account is responsible for sending messages to the first 20 groups and the second account is responsible for sending messages to the second 20 groups, respectively ....
The question is, are pyrograms or telethons or these libraries restricted by the telegram? And the accounts get baned??
Is there a way to prevent this from happening?
Yes, you will get a flood wait if you try to send too many messages using a account.
Here is code to avoid flood wait https://docs.pyrogram.org/faq/how-to-avoid-flood-waits#how-to-avoid-flood-waits
to prevent flood wait you can add a delay for sending messages
asyncio.sleep(3)
Don't forget to import the asyncio library
Don't use time.sleep() because it is blocking, prefer to use asyncio.sleep() instead.

How long does it take for the app to time out and exit the conversation

How long does it take for the google assistant agent to timeout and end/leave the conversation?
I configured a chat bot with actions-on-google where
The GA would ask user to choose which product to buy from a List.
Then the user locked the phone's screen
After a few minutes, the user reactivates google assistant again
User selects one of the product from the list by scrolling up the history
The transaction proceeds
I expected the app to exit the conversation after a certain duration, which then start a new session.
The session stays alive for 10 minutes. So, if you resume conversation within 10 minutes then it will continue in the same session.
As per my testing on Google Assistant and Simulator, if the conversation is paused for more than 10 minutes then the conversation ends and app exits.
5 seconds.
Source: Google's documentation
("Your response must occur within about 5 seconds or the Assistant assumes your fulfillment has timed out and ends your conversation.")
If there is a 5 second limit to receive the response, is there a limit to how long the response can be? We want to access longer form responses and then (hopefully) process the text response
It's actually 10 seconds or that's what this says.
I don't know if it's the same time for legacy actions or conversational actions.

How to get message info by ID [Telegram API]

I'm writing bot for telegram to gather some stats from group chat. I need to get info about every message (from the beginning of chat). I know how can i do it, but it's a quite bad idea. I can use forwardMessage method, but i need second acc for it and i'm getting timeouted when i'm sending messages too fast (for one hour), so it's a bit long way to collect stats for conversation that has over 2 million messages ;s I tried to set limit on 10 messages per second but i'm still getting timeouted, so idk how it works.
There must be other way to get JUST message info by id without forwarding it ;v I can't find it in API.
There has no API to do this at this time, you can suggest this idea to #BotSupport, before them added this feature, I am doing same thing like you.
According to Bot FAQ, Telegram API rate limit 1/s pre chat, and global limit is 30/s.
There is no way to do this with Telegram bot api, you can use ReadHistory Method of MadelineProto without the necessity to use forward message method

Azure Service Bus delayed (scheduled) message on Topic is lost when used with Duplicate Detection

We are facing a problem with Service Bus.
We have a topic, with two subscriptions.
We have enabled Duplicate Detection on those, with 1 minutes window (tried with 2 seconds first). We are using Duplicate Detection to avoid multiple messages processed in short interval (to maintain the interval between the messages)
We are using the message scheduling (ScheduledEnqueueTimeUtc) to repeat the messages to appear after 5 minutes, with same message ID (every time a new message is created with schedule, and old message is completed)
The workflow is as follows (problem):
First time a message is published (without scheduling)
This message is immediately consumed by the message pump, and a new message with same details and a schedule time of 5 minutes is send to the topic (UTC), expecting it to appear after 5 minutes
The message is not appearing in the subscription
When debugged, this issue doesn’t come up
When we send the First message with at least 30 second delay (scheduled), then it is working fine
If we recreate the topic and subscription with Duplicate Detection turned off, we are able to get the message using the above workflow
Since we have no clue on what is happening to the published message, we need help to identify the root cause of the issue.
This is an expected behavior of the ASB.
When a message is scheduled, it's actually enqueued on the broker with delayed appearance. ASB on the server side de-duplicates messages upon arrival and uses message ID for de-dup.
In your case, if you delay dispatch of the second message and the original message is processed, there will be nothing to de-dup and the second message will be enqueued. If you don't delay, then the broker will see an identical ID to the previously sent message that has not been completed or DLQed yet, and it will be de-duped.
Possible way to go about is not reuse the same transport message ID (ID used for the BrokeredMessage). In case you need to associate messages, you can use Properties for that.

Pusher API - Messages Per Minute

I implemented Pusher API in a live chat recently.
I launched a Startup package of Pusher yesterday. After 4 hours of being live, I receive an email that my account is reaching the cap on usage.
I logged in and looked at the stats, to discover that the Messages per Minute were between 5,000 and 20,000.
I don't understand how this is possible. I have around 100-150 connections open.
Why is the message count so high?
Armin
Found the answer myself! :)
Here is the link for anyone who may have the same problem:
https://pusher.tenderapp.com/kb/accountsbillingplanspricing/how-is-my-message-count-calculated
Basically, if you have 100 users subscribed into a channel, and 1 message is sent, it counts are 100 messages being sent since each user would have to be notified.
Bottom line is to properly filter your channels.

Resources