ThingSpeak Alerts not Working

Ed Jacques on 6 Dec 2023
Latest activity Reply by Ed Jacques on 12 Dec 2023

I have been having problems sending ThingSpeak alerts so I created a simple routine that demonstrates the problem. The code executes successfully but I never receive an email with the alert. What am I doing wrong?
% Set Thingspeak address, alerts API key, and options for the HTTTP call
alertUrl = "https://api.thingspeak.com/alerts/send";
alertApiKey = "TAKxxxxxxxxxxxxxxxx";
options = weboptions("HeaderFields",["ThingSpeak-Alerts-API-Key",alertApiKey]);
% Set content for email subject and body.
alertSubject = "ThingSpeak Alert Subject";
alertBody = "ThingSpeak Alert Body";
% Catch errors so the MATLAB code does not disable a TimeControl if it fails
try
webwrite(alertUrl, "body", alertBody, "subject", alertSubject, options);
catch Exception
fprintf("Failed to send alert: %s\n", Exception.message);
end
Christopher Stapels
Christopher Stapels on 6 Dec 2023 (Edited on 6 Dec 2023)
Are you getting any warnings for the code if you trigger it manually? I just sucessfully tested an alert to me.
And I assume you are using your own alerts API key?
Ed Jacques
Ed Jacques on 7 Dec 2023

I get no warnings when I trigger manually unless I trigger more than two times in a 30 minutes where I get 429s. I am using my alerts API key. I even tried to regenerate the key to no avail. Strange thing is the alerts worked Sunday but stopped working a couple of days later.

Christopher Stapels
Christopher Stapels on 7 Dec 2023

Have you checked your remaining balance?

Ed Jacques
Ed Jacques on 7 Dec 2023

Yes, I have 3,000,000 remaining messages. I am having no problems reporting data to ThingSpeak, just with alerts.

Ed Jacques
Ed Jacques on 7 Dec 2023
Also, I have 722 of 800 remaining alerts available.
Christopher Stapels
Christopher Stapels on 7 Dec 2023
I know ive said a lot of obvious things, but I have to run through them all. any chance a spam blocker or junk folder is cartching the email? Do you see the balance go down when you trigger an alert?
Also try taking the try catch off and see if there is any error reported.
Ed Jacques
Ed Jacques on 7 Dec 2023
Yes, I checked my spam folder and see the Alert count decrement each time I attempt to send an alert. I also removed the try catch and see no errors. I am at the point where I am considering deleting my account and starting over but I don't see a way to delete my account.
Christopher Stapels
Christopher Stapels on 7 Dec 2023
My present guess is that it is something with your email provider. The alerts function is working, since I got alert emails when I tested, and it is sending to your address since, the alert balance is decremented. You cannot delete your ThingSpeak account without deleting your MathWorks account, there is a form for that and its faily complex. In the account settings though, you can change your email address. Would you consider changing your email to a different address, jut for testing?
By they way to you have any odd characters in your email address? It could be a formatiing issue.
Ed Jacques
Ed Jacques on 7 Dec 2023
Great idea. I changed my email address to a gmail account and manually initiated two alerts with no errors indicated. The remaining alerts count decremented by two. No emails were received on the gmail account.
Ed Jacques
Ed Jacques on 7 Dec 2023
It appears my attempt to change my address didn't work because as a Licensed Contact I am required to use an email address associated with my company so please disregard the above message. I will technical support to see if they are blocking emails from ThingSpeak.
Ed Jacques
Ed Jacques on 12 Dec 2023

Problem resolved. The email was being blocked probably due to the use of the mailgun service on your end. Thanks for all of your help.

Christopher Stapels
Christopher Stapels on 11 Dec 2023
Sorry, Im not able to send an email from ThingSpeak domain. but you can generate one by exporting data from a channel (import export tab of channel view) and then immediately reloading the same csv file back. Then you will get an error message from mail.thingspeak.com saying that you have tried to upload repeat data to a channel and the upload failed. Its the same mailserver as the alerts.

Tags