Auto-message responses

thanks @samuel rapidpro looks good with interactive messaging though we had first opted for the cht-gateway(because of its simplicity compared to rapidpro which comes with its own share of complexities :grinning:) to see if it can help us achieve the sms goals for the app we are seeking to implement with CHT

1 Like

Hi @cliff

Indeed default_responses is not documented.
The start_date is compared against the reported_date property of the SMS message (creation date), so the transition is only applied to messages sent after this date.

The translation keys used are hardcoded: https://github.com/medic/cht-core/blob/master/shared-libs/transitions/src/transitions/default_responses.js#L89 so there’s no need for you to add it.

You also need to enable the transition in the transitions section of app settings.

did set my start date here

"default_responses": {
    "  start_date": "2018-01-01"
  },

as of today and any messages sent or created today will get a similar response message from the server with ... a touched eg Hi will recieve auto Hi.. from he server

I enabled added the transitions

 "transitions": {
    "default_responses": true,
    "update_clinics": true,
    "accept_patient_rdeports": true,
    "conditional_alerts": true,
    "update_sent_by": false,
    "registration": true,
    "update_scheduled_reports": false,
    "multi_report_alerts": false,
    "update_sent_forms": false,
    "generate_patient_id_on_people": true,
    "death_reporting": true,
    "resolve_pending": false,
    "generate_shortcode_on_contacts": true
  },

I then added a new translation key

But the server is not yielding the auto response

It looks like you have some empty spaces there, were those just added when you shared the code here?

thanks @diana

the empty spaces was probably added there when i was sharing the code though i repeated again the process with

"default_responses": {
    "start_date": "2018-01-01"
  },

but still the same no auto response

Hi @cliff

Can you please try with a new message and share what you see on the messages tab when you open this new message? Thanks!

Thanks @cliff.

For reference, this is what I see when sending an sms:

Could you please check your API logs for errors or suspicious entries?
Maybe something like:

Transitions are disabled until the above configuration errors are fixed. Error: Transitions are disabled until the above configuration errors are fixed.

To re-run transitions validations, try making any change to your settings document.

Thanks!

yes @diana i keep seeing

0RbBpaeZmaUmp5LntAcQ0cLi5gk0ztUwyMjVPxqYvCwAmWJ57&limit=25 HTTP/1.0
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[32mINFOESC[39m: Loading transition "update_clinics" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[33mWARNESC[39m: Disabled transition "self_report" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[32mINFOESC[39m: Loading transition "registration" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[33mWARNESC[39m: Disabled transition "accept_patient_reports" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[33mWARNESC[39m: Disabled transition "accept_case_reports" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[32mINFOESC[39m: Loading transition "generate_shortcode_on_contacts" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[32mINFOESC[39m: Skipping asynchronous transition "generate_shortcode_on_contacts" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[32mINFOESC[39m: Loading transition "generate_patient_id_on_people" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[32mINFOESC[39m: Skipping asynchronous transition "generate_patient_id_on_people" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[32mINFOESC[39m: Loading transition "default_responses" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[33mWARNESC[39m: Disabled transition "update_sent_by" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[33mWARNESC[39m: Disabled transition "update_sent_forms" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[32mINFOESC[39m: Loading transition "death_reporting" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[32mINFOESC[39m: Loading transition "conditional_alerts" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[33mWARNESC[39m: Disabled transition "multi_report_alerts" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[33mWARNESC[39m: Disabled transition "update_notifications" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[33mWARNESC[39m: Disabled transition "update_scheduled_reports" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[33mWARNESC[39m: Disabled transition "resolve_pending" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[33mWARNESC[39m: Disabled transition "muting" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[33mWARNESC[39m: Disabled transition "mark_for_outbound" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[31mERRORESC[39m: Unknown transition "accept_patient_rdeports" 
[2022-01-19 20:15:36] 2022-01-19 20:15:36 ESC[31mERRORESC[39m: Transitions are disabled until the above configuration errors are fixed. Error: Transitions are disabled until the above configuration errors are fixed.
[2022-01-19 20:15:36]     at Object.loadTransitions (/srv/software/medic-api/md5-O3yLnjz8HcvO7g+wuf0kiw==/node_modules/@medic/transitions/src/transitions/index.js:168:11)
[2022-01-19 20:15:36]     at initTransitionLib (/srv/software/medic-api/md5-O3yLnjz8HcvO7g+wuf0kiw==/src/config.js:72:20)
[2022-01-19 20:15:36]     at loadTranslations.then (/srv/software/medic-api/md5-O3yLnjz8HcvO7g+wuf0kiw==/src/config.js:177:48)

made some changes in the transitions by enabling some of them and run
cht --url=https://medic:password@192-168-124-70.my.local-ip.co upload-app-settings

It looks like you have a typo, this should be accept_patient_reports.

thanks @diana ,wondering how i hadn’t seen that :disguised_face:
Works fine now

hello @diana

Can i be bale to schedule a message to be sent out to a contact ? eg Hello Cliff has patient visited the clinic today for ANC ?

I am looking at the schedules configurations though they seem to be heavily linked to SMS forms in registration, my intetion is just to configure aschedule in the settings document to roll out a message to the clinic ie the primary contact linked to a contact number am using …

Added this object in the schedules of my settings files

{
      "name": "Test Reminders",
      "summary": "",
      "description": "",
      "start_from": "reported_date",
      "start_mid_group": false,
      "messages": [
        {
          "translation_key": "messages.schedule.registration",
          "group": 1,
          "offset": "3 minutes",
          "send_day": "thursday",
          "send_time": "",
          "recipient": "clinic"
        }
      ]
    },

The SMS reminders also look to be linked to forms

Hi @cliff

I think you can use SMS Reminders. The way reminders work is that the reminder is not sent if the form in the config has been already sent. If you create a reminder with a form that nobody submits, it should work as you desire.
Schedules only work in association the registrations.

1 Like

thanks @diana

i have used fires on the 0th, 10th, 20th, 30th, 40th, and 50th min of every hour text_expression in the reminders below

 "reminders": [
    {
      "form": "C",
      "translation_key": "sms.reminder.c",
      "text_expression": "fires on the 0th, 10th, 20th, 30th, 40th, and 50th min of every hour",
      "contact_types": [ "health_center", "hospital","person" ]
    }
  ],

Am using C form configured in the settings file though not yet used to send a text report plus the respective translation in the messages-en.properties file sms.reminder.c = PLease be reminded
Not yet sure why the reminder hasn’t been sent to the contact person in the system

Hi @cliff

I don’t think reminders will get sent to all persons, they get sent to the primary contacts of places.
So you should make sure that:

  1. the contact types you add in your list exist
  2. your places of that type have a contact with a valid phone number
  3. your text_expression is valid. “fires at” should not be part of your expression. Your expressions should be changed like on the 0th, 10th, 20th, 30th, 40th, 50th minute
1 Like

thanks @diana

i do have a contact type of person who is also a primary Contact in the work area with a valid phine number as seen below


Having set person as one of the contact type to recieve the reminder

"reminders": [
    {
      "form": "C",
      "translation_key": "sms.reminder.c",
      "text_expression": "on the 0th, 10th, 20th, 30th, 40th, and 50th min of every hour",
      "contact_types": [ "health_center", "hospital","person" ]
    }
  ],

I thought the primary contact of type person to receive the reminder on their phone number

Hi @cliff

Persons types don’t have a primary contact. Place types do.
So you should set your reminder to be sent to the place same type as “cliffe’s area”.

Can you please check your sentinel logs to see if you see something suspicious. Sentinel will try to create reminders every 5 minutes.

1 Like

i added "contact_types": [ "health_center", "hospital","person" ,"cliffe’s area"]

i see

 2022-01-19 12:51:00] 2022-01-19 12:51:00 ESC[33mWARNESC[39m: Reminder configuration invalid: { form: '',
[2022-01-19 12:51:00]   text_expression: '',
[2022-01-19 12:51:00]   cron: '',
[2022-01-19 12:51:00]   mute_after_form_for: '',
[2022-01-19 12:51:00]   message: '' } 
[2022-01-19 12:51:00] 2022-01-19 12:51:00 ESC[32mINFOESC[39m: checking schedule again in 5 minutes 
[2022-01-19 12:56:00] 2022-01-19 12:56:00 ESC[33mWARNESC[39m: Reminder configuration invalid: { form: '',
:

though i have in settings file for my deployed project

"reminders": [
    {
      "form": "C",
      "translation_key": "sms.reminder.c",
      "text_expression": "on the 0th, 10th, 20th, 30th, 40th, and 50th min of every hour",
      "contact_types": [ "health_center", "hospital","person" ,"cliffe’s area"]
    }
  ],

And for CHT-core i have

"reminders": [
    {
      "form": "",
      "text_expression": "",
      "cron": "",
      "mute_after_form_for": "",
      "message": ""
    }
  ],

Could it be tracking the reminders config in the app-settings of core instead ?

I’m not sure what you mean by “settings” file. Do you mean the app_settings.json file? Please have a look at how app_settings should be structured: app_settings.json | Community Health Toolkit

yes @diana

thanks,i have been looking at it and looking more into its structure