What could be causing incessant calls to my Telegram webhook? - telegram

I have a simple PHP script (using Botman) called by my Telegram bot via a webhook. It's supposed to respond on receiving a keyword. This works, sending response messages to my phone.
Randomly however it repeats the messages, without any input. Though random, its so frequent I would estimate it does this at least 10 times per minute.
Thinking this could be due to some web bots calling my URL, I modified the script to check the presence (and value of) and query parameter and all random messages stopped. The web bots wouldn't know this secret parameter, right?
As expected, once I updated the PHP script (without updating Telegram with the modified webhook), the messages stopped. So far so good.
Next, updated the Telegram with the webhook containing the secret query parameter, then waited 5 minutes. No messages: still looking good.
Alas, once I send my keyword, it gives the expected response but then keeps repeating endlessly again.
Where do I look to fix this?
Ps. To test, the script also returns general info of the user. I can see it keeps returning my info in the repeated message, as if I made each request. Could this be a bug with Telegram?

According to your description, it seems that your webhook architecture it still looking for the most recent updates returned by Telegram getUpdates method: if your script repeats answering to the same exact message, it means that it's receiving the same exact update object more than one time.
A good solution to solve this problem could be have a look at the webhook working of, how it communicates with Telegram servers in order to understand how does it handle updates received from the Telegram Chatbot itself.

Related

Azure Service Bus - Renew message lock automatically when using ServiceBusReceiver

Having spent long hours trying to find documentation and help around this resulting in nothing, I have decided to reach out to the community.
I would like to read messages from a topic subscription. Using the message, a UI is populated for a human to work on it. The time it approximately takes to process each message is 15 minutes and each client can work on only one message. At the end of processing the message, the client can either decide to stop processing messages or request a new message.
With the max lock time set at 5 minutes on the subscription, I need to be able to automatically renew my lock for up to 15 minutes.
The first attempted approach was to use CreateReceiver and fetch the message, read it and Complete message when done. The issue with this is I have not been able to figure out how to automatically renew the lock for 15 minutes. I see the RenewLockAsync function but would like for this to be automatic and not have to run a background timer to keep track of the expiring lock.
The second attempted approach was to try using ServiceBusClient.CreateProcessor() with options to set the AutoLockRenewal timespan. The issue faced here is with the processor itself running based on events in the background. Since I need to populated a UI, I need to be able to stop the processor after the message has been read, return the callback and once the human interaction is done, complete the message. I have been unable to find a way to do this.
What would be a good approach to achieve this? The subscription acts as a workqueue that multiple people pull items from and individually work them. Any help in a proposing an approach to this is appreciated.

Webhooks randomly stopped working. Integromat servers responding with 400 code. Custom Integromat app

I was developing Instant triggers for my Integromat app. I finished 2 of them, and when I started the third one, all webhooks stopped working.
I wrote a mail to the support of about the situation and received the answer:
We can see in logs that webhooks fired from our end but your system
returned us error 400 - it means that webhook works on our side but
was not properly received on your servers side.
So why Integromat can answer 400 code? Is it a bug or my mistake? From that moment, I have tried with the new account, but the issue is still there.
Any suggestions?
Judging by the response you received from the 3rd-party tech support, there's an error somewhere in your webhook code.
The first thing I'd check is of course the code directly inside your webhook's Communication tab, but also, if this code is calling any IML functions you wrote, you'll need to double-check that the IML code is not failing as well.
You could create an IML test using the Integromat Apps SDK VS Code plugin to simulate the function call with incoming JSON data (according to the documentation of the service you are implementing) and see if this call results in some kind of an unexpected error.

How to stop Telegram bot webhook from polling the server?

I set up up a webhook using the official API and everything worked fine, up until this point. I'm using Firebase Cloud Functions as a backend and I got my daily quota exceeded:
Error: quota exceeded (CPU allocation in function invocations)
However, because this is some sort of status code 500 and no actual response back (I suppose), the bot tries to further call the webhook. Yet, this creates a vicious loop, as the webhook won't stop, causing the daily quota to never become available.
I had to manually deactivate it. Is there another workaround? Some setting?
In my bot, there may have 500 server errors sometime, so I don't let TG know about all errors 😃
Just close HTTP connection before all the other code, for instance, fastcgi_finish_connection() for me.

Application Insights removing telemetry after it has been logged

I've had Application Insights set up on my ASP.NET project for a couple months with no issues. I use Custom Events for logging certain events.
Recently, I tried to add a Custom Event after a user has authenticated in order to track the login behavior. My custom event DOES log to application insights debug session. I know this because I can see it in the telemetry when paused on a breakpoint just after the event.
However, when I continue running the application, my custom event no longer shows up the telemetry. It just disappears.
I cannot understand what the issue is. Does anyone familiar have any (application) insights? I couldn't help myself ;)
There are some things to check:
are you logging to one resource (iKey) and searching on another? (a lot of people send data to one resource in dev/debug and a different resource in release/prod environments. so make sure you're sending to the place you expect, and searching the place you expect.
is the data actually going out successfully? you may need to use fiddler or some other tool to watch your outbound http for calls to dc.services.visualstudio.com. It could somehow be the case that there's something wrong with the data you're sending, or maybe you're getting capped or throttled by the service. If that's the case, the outbound requests will have responses other than 200, and will generally tell you the reason it didn't accept any items that it rejected.
if the data is getting successfully sent and is going where you expect it to go, there might just be a delay in backend processing. you can always check aka.ms/aistatus to see if there are any current issues with the service.
I am confused, however, by what you mean when you say
However, when I continue running the application, my custom event no longer shows up the telemetry. It just disappears.
What do you mean "it just disappears" ? if you see it in the output window, then the SDK saw it, and it will get sent, precluding any of the above 3 items. Where is it "disappearing" from? unless you clear the output window, it's never gone from there. If you're talking about the VS search tools that show data sent by the AI SDK during debug, that tool currently has a cap of the most recent 250 items that have occurred during the debug session.

Personalized push notification TopicLimitExceeded

I want to have personalized push notification for each user in my app, for example, when someone sends a user a message, he (and only him) get a notification that someone sends him a message.
I was able to achieve this by using SNS, and create a topic for each user. However, now that I have > 100000 users, I got TopicLimitExceeded error.
Is there a way to achieve this without running into this error?
It depends on what type of limitation you are exceeding.
Sometimes aws puts limitation on number of calls per second.
I recently ran into some trouble for downloading RDS logs. There was limit on number of calls that i can make for second
One way to solve such rate limit exceed issue is to use sleep method.
For eg:
sleep(5) # sleep for 5 second
# Continue with you program execution
Hope it helps !!
I contacted AWS support and they simply increased my number of Topic limit.

Resources