Community Health Toolkit

Scheduled messages

Scheduled messages are not sent to recipients.

How To Reproduce The Issue

  1. Add schedules key in app_settings.json file
    “schedules”: [
    {
    “name”: “ANC Visit Reminders”,
    “messages”: [
    {
    “translation_key”: “messages.schedule.registration.followup_anc_pnc”,
    “group”: 1,
    “offset”: “2 minutes”,
    “recipient”: “parent”
    }
    ]
    },

  2. Add translation key to messages-en.properties
    messages.schedule.registration.followup_anc_pnc = Test message here. ANC follow up message

  3. Add registrations key to app_settings.json
    “registrations”: [
    {
    “form”: “pregnancy”,
    “events”: [
    {
    “name”: “on_create”,
    “trigger”: “assign_schedule”,
    “params”: “ANC Visit Reminders”
    }
    ],
    “validations”: {},
    “messages”: []
    }
    ],

  4. Run cht command to update settings
    cht --url=https://:@localhost --accept-self-signed-certs compile-app-settings backup-app-settings upload-app-settings

Expected Behavior
I expected to receive message in parents phone number and have scheduled message on app management section>outgoing message. But nothing happens after I register a pregnancy

Hi @Julius_Karanja

Thanks a lot for reporting.
I’m linking the relevant documentation here, that I will be referring to: .schedules | Community Health Toolkit

It appears that there’s an inconsistency between our documentation and our code, where the code requires that the start_from is defined and does not have a default value.
I’m leaning to think that the documentation is correct, so I’ll file this as a bug.
In the meantime, can you try updating your schedule configuration to include start_from and try again?

"schedules": [
      {
        "name": "ANC Visit Reminders",
        "start_from": "reported_date",
        "messages": [
          {
            "translation_key": "messages.schedule.registration.followup_anc_pnc",
            "group": 1,
            "offset": "2 minutes",
            "recipient": "parent"
          }
        ]
      },
]

You should be able to see your scheduled message both on the report detail page an in the app management → outgoing message → scheduled (or due, in case enough time has passed that it becomes due).

Added the issue: Schedules don't have a default value for `start_from` · Issue #7425 · medic/cht-core · GitHub