This tutorial will describe how to setup an SMS survey for your project. This builds on the application already developed in the Messaging Beginner Tutorial, so please complete that tutorial before continuing. We will add an SMS survey to that application that will check with the mother if she has visited the clinic. Panel |
---|
panelIconId | atlassian-info |
---|
panelIcon | :info: |
---|
bgColor | #EAE6FF |
---|
| Learning Objectives for SMS Survey TutorialIn this tutorial, you will learn the following: |
Creating an SMS SurveyAn SMS Survey is just another form in CommCareHQ. You can have the same logic you have in forms (display logic, validation logic). You can also use the survey to update cases as you can with regular CommCareHQ forms. The only limitation on SMS surveys is that only some question types will work over SMS (text, label, numbers and single and multiple choice). Setup the SMS ApplicationWe need to add a new application to the existing project created for the Messaging Beginner Tutorial. This application will contain all the SMS surveys so they don't appear in the existing health worker application. Add a new application to the project by going to the Applications tab and choosing New Application -> Blank Application.
Update the first module and set the name to Pregnancy Surveys.
And then set the case type to pregnancy. This module will contain all surveys related to pregnant women.
Add the Clinic Attendance SurveyThis tutorial assumes you already know how to create a form with hidden values. Rename the Untitled Form to Clinic Attendance Survey and add questions so that it resembles the following.
The following calculations and display logic is used in the form: Question ID or Choice Value | Type | Label | Required | Display Logic | Calculation |
---|
attend_clinic | Single Answer | Did you attend the clinic today? | Yes | | | yes | Choice | Yes | | | | no | Choice | No | | | | visited_clinic_label | Label | Great! Speak to your health worker about the results. | | /data/attend_clinic = 'yes' | | no_visit | Label | Its important you visit the clinic. Please try visit next week. | | /data/attend_clinic = 'no' | | send_clinic_visit_reminder | Hidden Value | | | | if(/data/attend_clinic = 'yes', 'no', 'yes') |
Panel |
---|
panelIconId | atlassian-info |
---|
panelIcon | :info: |
---|
bgColor | #EAE6FF |
---|
| Concept:Its important to keep label text short! SMS messages are limited to 144 characters and longer messages can be split up into multiple messages. These messages are sometimes not delivered in the correct order, confusing users. |
Save the form and configure the case management for the form. The form will be setup to update or close cases. We'll only save send_clinic_visit_reminder. This will then affect the reminders that are based on this case property.
Now that our survey is setup, we can setup a reminder to send it to pregnant mothers. Setup an SMS Survey ReminderWe'll now setup a reminder so that the survey will only be sent to mothers who have been flagged by the CHW as needing to visit the clinic. This messages will also be setup to repeat on a weekly basis until either the CHW or mother indicates she has visited the clinic. We'll schedule the message to send on Tuesdays in the evening (so that the mother can respond after visiting the clinic). Add another reminder to the project (go to the Messaging tab, then choose Reminders and then click on the + Reminder button). We'll now configure which pregnant mothers will receive this reminder. Give the reminder a name (ex. Clinic Visit Check) then scroll to the Start Section.
Send for Case Type: We want to choose pregnancy from this list as the message will be sent to pregnant mothers. Send Reminder For: This will control which cases receive the reminder. We want to choose Only Cases in the Following State. Then set the reminder to send when the case property send_clinic_visit_reminder equals yes. Day of Reminder and Time of Reminder: This controls what day and time of day that the mother will begin to receive this reminder. Our clinic day occurs on Tuesdays. So we want to send the mother a reminder on Tuesday evening to check if she visited the clinic. For Day of Reminder choose Specific Day of the Week and Tuesday. This option will send the message on the next upcoming Tuesday after the pregnant mother is flagged for a clinic visit. For Time of Day choose at a Specific Time and 18:00.
The next step is to choose who will receive the reminder. We want this reminder to go to the health worker who registered the case (the case owner), so choose Case Owner.
In the Message Content section, instead of sending an SMS Message, we want to send an
SMS Survey, We can now choose which form we want to send as the survey. Use the dropdown to choose Clinic Attendance Survey.
We will also configure to reminder to Repeat every week until the mother visits the clinic. Choose the
Indefinitely option and specify that the reminder should repeat every 7 days. Remember, the reminder will stop sending as soon as the Start condition becomes false (i.e. if send_clinic_visit_reminder is not equal to yes).
We can also look at and update some Advanced options for this reminder.
Stop Condition: This provides another way to stop the reminder. Since we are just changing the start condition to stop the reminder, we can leave this as it is. Timeouts: With SMS Surveys, sometimes the user may not respond to a particular question. We can use timeouts to re-send the question if the user does not respond after a certain amount of time. We can specify a set of time intervals on which the survey will be sent out again. The last number represents when we will close the survey (and stop allowing responses). For example, specifying 30, 60, 120 will resend a question at 30 minutes and 60 minutes after initially sent, and close it at 120. Set the timeout to 30, 60, 120. Submit Partial Forms: If a survey is partially filled out (user only responded to some of the questions), this controls whether we will save those partial answers. For now, we can leave this off for this reminder.
Our reminder is now setup so we can click on Create Reminder.
We can now view the scheduled reminder in the calendar and test out how it works. Test and Verify the SurveyNow that our reminder is setup, we can test it using our phones and view it in the reminder calendar. Setup a Sample CaseSimilar to how was done in the Messaging Beginner Tutorial, use the existing registered pregnancy or create a new pregnancy case and flag that case for high risk symptoms. Please make sure the phone number you enter is unique - that is, it is not used by any other case or mobile worker in the system. Panel |
---|
panelIconId | atlassian-info |
---|
panelIcon | :info: |
---|
bgColor | #EAE6FF |
---|
| Concept:Duplicate Phone Numbers: Each phone number used for two-way (SMS Survey or Keyword) communication must be unique within and across projects. This is because CommCareHQ uses the phone number to determine which case or mobile worker an incoming message is associated with. If your phone number is not unique, you won't be able to verify the phone number for a mobile worker (https://dimagi.atlassian.net/wiki/x/-yjKfw), and CommCareHQ won't send out any surveys for that case or mobile worker. If a survey is not sent out due to a duplicate phone number, this will appear in the Reminders In Error report, which is in the Messaging tab. |
View Surveys in the Reminder CalendarOnce you've registered a case, the reminder should appear in the Reminder Calendar (available in the Messaging tab). Testing a Survey Using a BroadcastSince reminders are scheduled in the future, its sometimes hard to test how they behave immediately after creating them. To test a survey immediately after we create it, we can use a Broadcast, that will send that survey to a mobile worker. The survey won't behave exactly as it should (it won't be associated with a case), but will still be testable. First create a mobile worker (https://dimagi.atlassian.net/wiki/spaces/commcarepublic/pages/2143954052/Messaging+Beginner+Tutorial#Setup-a-Mobile-Worker-for-Messaging) and make sure you verify the mobile worker's phone number. This is necessary for two way surveys. We now need to put the mobile worker in a Group Go to the Users tab and choose Groups on the left pane. Then type a group name (ex. Test Group), then click on the Create Button.
Add you test mobile worker (the one with the verified phone number) to the group and click on Update.
Go to the Messaging tab and choose Broadcast Messages in the left pane. Click on + New Broadcast to create a new broadcast.
Setup the broadcast to send to Test Group immediately as shown below. Choose the Clinic Visit Check survey to be sent.
Your test mobile worker should now receive the survey shortly. To respond to multiple choice questions, you can respond with a number (ex. 1) representing the answer in the list. Note: This survey won't affect any existing cases and is just a way to test the questions. If your survey is not sent out, check the Reminder Calendar. If it doesn't appear on the reminder calendar, check the Reminder in Error report to see if there was an issue with the survey. Viewing Surveys in ReportsBy default, surveys filled in by cases will not display in the Submit History report. In the Groups and Users filter, click and make sure you also include [Unknown Users]. Congratulations, you've completed the SMS Survey tutorial! Use the https://dimagi.atlassian.net/wiki/x/XCrKfw page to read more about messaging and other functionality. |