Okay
  Public Ticket #2619767
Notifications not sending
Closed

Comments

  • Concierge started the conversation

    I’ve got the cron script setup but for some reason my notifications are still not going out. I’ve tried manually hitting that URL as well and it says successfully sent but the data portion of the JSON response is always null (not sure if this is expected). It’s ticked to send reminders in the backend, can you help with anything I might have missed/next steps to diagnose the issue? Many thanks. 

  • [deleted] replied

    Hello,

    This depends of your server you will need to have separate settings on your hosting provide (cPanel for settings this up)

    Scheduled notifications require a bit of additional configuration with your server cron scheduler. The command that has to be added can be found on the “Notifications” page when notification that requires scheduling is active. You can recognize these notifications by the clock icon next to the notification name. Copy command and paste it in the cron file. The command looks like this:

    */15 * * * * https://yourwebsite.com/wp-admin/admin-ajax.php?action=wpamelia_api&call=/notifications/scheduled/send

    You can see the more detailed tutorial how to set up cron at this link.

    If you are not familiar with this you can use plugin WP Crontrol for creating cronjob.

    In the Tools -> Cron Events admin panel, 

    5870820090.png

    click on the “Add PHP Cron Event” tab underneath the cron event table. 

    2764191073.png

    In the form that appears, enter the schedule and next run time in the boxes. The event schedule is how often your event will be executed. In the “PHP code” area, enter the PHP code that should be run when your cron event is executed. Please insert this:

    file_get_contents("https://yourwebsite.com/wp-admin/admin-ajax.php?action=wpamelia_api&call=/notifications/scheduled/send");

    You don’t need to provide the PHP opening tag (<?php).

    6717743478.png

    Please replace "https://yourwebsite.com" with your real web address.

    If you don’t see a good interval, then add one in the Settings -> Cron Schedules admin panel or click on link "Manage Cron Schedules". You will find example how you can make custom interval inserting:

    • Interval name
    • Interval(in seconds)
    • Display name
    6861925456.png

    and click "Add Cron Schedules" and it will be added.

    6847038953.png

    When you made custom interval you need to go back to  Tools -> Cron Events admin panel and click on the “Add PHP Cron Event” tab underneath the cron event table where you will insert that custom interval and all other field that are described above. After clicking on "Add PHP Cron Event" it will be added on Event table and you are done.

    8850513929.png

    If you have any confusion about this feel free to ask us, and we will help you.

    Best regards.

  • Concierge replied

    Thanks, Den. It's not a cron issue. I've set up a log to view the output and it's successfully hitting the URL and coming back every time with the following:

    {"message":"Scheduled email notifications successfully sent","data":null}

    I've even set it to go every minute as I'm not sure on the criteria for sending. Which of the crons would trigger an alert? Is it one exactly 24 hours beforehand? Does it poll several and do them at once? If it fires at 6.24pm and the following day's appointment is 6.25pm is this going to send or does is have to be exactly 24 hours before? What is the tolerance?

    With a bit more info on how it works I may be able to do a bit of error detection on my end. Thanks.


  • [deleted] replied

    Hello,

    Are only scheduled notifications affected, or are no notifications being sent? If no notifications are being sent, it's got nothing to do with the cron event. That could be caused by bad credentials in Amelia's Notification settings; the server may be blocking 3rd party SMTP settings; if using Gmail, "Allow less secure apps" needs to be turned on; or the PHP version is below 7 on the server.

    If only cron isn't working, it could be the cron event itself, but it could also be the server blocking the cron.

    Here's how it works:

    1. You choose a time when a scheduled notification is going to be sent in the upper right corner of a scheduled notification in Amelia (Appointment next day reminder, for example).

    2. When the cron event is created, you choose the recurring cycle. So, if you set it to be one minute, the cron will run every minute; and if it's set to 15 minutes, it's going to run every 15 minutes. Here's an example - You set the time when notifications are going to be sent to 12:00. There's an appointment booked for tomorrow. Your cron is set to run every 15 minutes. It runs (for example) at 11:44, so it checks if there are any scheduled notifications to be sent. Since you have the time set to 12:00, there are no notifications, and the cron does nothing. Then it runs 15 minutes later, at 11:59, but there are still no notifications to be sent, so it does nothing. At 12:14 it sees there's a notification that should've been sent at 12:00, so it sends a notification.

    If you simply copy the command (without */15**** so just the URL) and paste it in a browser's address bar, it runs the cron regardless of its recurring cycle. So if cron ran at 11:59, and you paste that command at 12:01, it's going to run the cron and it's going to see there is a notification scheduled to send at 12:00, so the notification will be sent.

    If the cron is set up correctly, you will see a message you provided before:

    {"message":"Scheduled email notifications successfully sent","data":null}

    So, it's successfully executed, but since the command itself doesn't include any data, it says "null". So, the cron runs on the server, and the notification is sent.

    If your appointment is scheduled for 00:05 (5 minutes after midnight), and your scheduled notification is set to run at 23:55, and cron runs at 23:59, it is still considered "next day", so the notification should be sent.

    When there's an appointment for tomorrow, and the time scheduled in Amelia/Notifications/Appointment next day reminder has passed; when you paste the command in the address bar, if nothing is blocking the cron (and if notifications work), it should send a reminder email.


  •  3
    Klemen Teran replied

    Had the same issue. This is what worked for me https://tmsplugins.ticksy.com/ticket/2661673/

    br k