Table of Contents:
Table of Contents | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Overview
Messaging can also be set up to allow users (mobile workers or cases) to initiate interact with the system themselves. This functionality can be setup through SMS Keywords.
A mobile worker or case can message the keyword to an HQ phone number. This will trigger a form to be run for the user.
For example, a mobile worker may want to register a new beneficiary or a beneficiary may need to request a service or report some information.
Some caveats:
Only known phone numbers can use keywords. To allow users to register themselves in the system, see https://dimagi.atlassian.net/wiki/x/SCLKfw.
If a Mobile worker sends in a keyword to initiate a form that normally requires the user to first select a case from the case list, then they will also need to provide the external ID for that case.
For example, if you have keyword "edit" tied to a form that updates a case, the mobile worker will need to send in "edit <external_id>", where <external_id> is the external_id case property of the case they wish to open the form for. This is true for both normal keywords and structured SMS.
Keyword Set-up and Example Keywords
To setup the keyword, choose the Messaging tab, then In the left side bar, select "Keywords". Click the "+Add Keyword" button.
Keyword: SMS Response
When setting up a keyword, you need to specify the following:
Basic Information
Keyword: This is the word that the user will message to initiate the interaction. Keywords need to be unique within a project.
Description: A description for the keyword does.
Respond to Sender
Send: This controls what is sent to the person sending the keyword (a simple message or an SMS survey)
Survey or Message: The survey or message to send
Notify Another Person:
This will let you notify another contact when someone sends a message to the keyword.
Recipient: The person to send the message to, a mobile worker group or the case's owner if the message was sent by a case.
Send: This controls whether to send the person an SMS message or a survey.
Survey or Message: The survey or message to send.
Advanced Options:
Restrict Keyword Initiation: Restrict the type of contact who can use this keyword. Use 'Case Only' if you want to escalate messages to the Case Owner.
Once you've specified the keyword and form, save the keyword.
Keyword: SMS Survey
Advanced Options:
Override open SMS Surveys: Sending in this word will override any existing surveys that the user is currently filling out and trigger this keyword.
Notes:
SMS Surveys can have conditional triggers, for example send a satisfaction survey after a clinic visit.
By creating a keyword, you can simulate that condition, and test an SMS Survey in a reliable way.
Keyword: Structured SMS with Custom Delimiter
If the you choose Structured Keyword, if you want to send in all of your SMS questions at once.
The users are able to send an SMS that looks like <keyword> <answer1> <answer2> <answer3> etc.
The defaults assumes that the user provides answers to each question, separated by spaces. This will work well for most situations.
Custom Delimiter
To setup a custom separation character, check the custom delimiter option and choose the characters you want to use to separate each answer. This could be a "," or "|" or even multiple characters like "||".
This example below uses a period (.) as a custom delimiter.
Custom Delimiter: This is useful if you want to use something else to separate each answer. For example, if any of your answers have spaces, the default separator of a space will not make space.
Keyword: Structured SMS with Named Answers
Named Answers
Named Answers allow users to skip questions or answer questions in a different order. This works by allowing the user to provide an identifier for each answer.
To use named answers, check the named answer option.
Specify the Name that the user enters, and the question (via xpath in the form) that it maps to.
For example, you may want to map two properties
/data/name to "name"
/data/household_size to "members"
By adding a joining character, the name and the value are paired together. The joining character in this example is a semi colon : .
As you build your Named Answers set-up, look at the Example Structured Message to understand how the message should look.
Both of these examples are valid options
visit name:123 members:456
visit members:456 name:123
Setting up an SMS Information Service
To create an SMS information service, you need to define a keyword that the user can text (ex. INFO) and a form (survey) that manages the interaction with the user. For this example, we're going to create a brief form that provides participants in a study with information about the medical trial and content. Users will send in the keyword INFO and will receive a set of options asking them what they need information on.
Form Creation
You need to define a form (or survey) that controls the interaction flow with the user. You can visualize each question or label in the form as an SMS sent and received from the phone. You can use logic in your form to drive how workflow.
Review the instructions here on creating a form for CommCare Messaging (https://dimagi.atlassian.net/wiki/x/DirKfw). Some things to think through when building your form:
SMS Surveys only support text, number, date or choice questions. You can't capture pictures, GPS locations, etc.
Limit your messages to 160 characters or less. Some phones don't handle longer messages (and will have the content split into multiple messages).
Create a form and name it Information Form. Add a question titled "Which information?" with the options titled Medical Contact, Contact Study Staff and Leave Study.
Now we will add labels that provide the right information for each option. The text for the labels is "Please call Dr.Ravi at 19995551432", "Contact us at 18001321234" and "Text LEAVE if you want to stop study".
We also want to each label to only display based on the option chosen. We can do this using Display Conditions. Display conditions control whether a particular question is shown based on the answer to previous questions. Choose a label, go down to the Logic Section and hit the Edit button on Display Condition. You can then drag and drop questions from the left tree to setup the logic. An example is shown below:
Once you've setup the expression, Save and create similar logic conditions for each of the other labels. Once you're done, choose the green Save button in the corner of the form builder.
Keyword interaction
Once you've built your form, you want to set it up to run when the keyword INFO is sent in. This will start sending questions back to the person who sent in the keyword. Once they respond, the next question or label in the form will be sent back to them.
A keyword is managed or created from the Messaging section of the CommCare Messaging site and clicking “Keywords”.
Create a simple keyword called INFO that will simply reply with the form you created to the user. There are some options on the keyword page that are a bit more advanced (will let you send a message to someone else when the keyword is sent in, or collect additional data in the same message as the keyword). These are not needed here. Once you've setup the keyword, hit the Save button at the bottom of the page.
User registration
Users will need to be registered before they can interact with the system. There are two types of users who can interact with the system - contacts who are registered (cases) or mobile workers. Mobile workers are project staff who can use the system via SMS (ex. registering participants). Cases are just contacts registered with the system (ex. study participants). Depending on your use case, you may need to use setup cases, mobile workers or both. Details on how to register users are provided below.
https://dimagi.atlassian.net/wiki/x/tCbKfw - This can be used to register a number of contacts using Excel.
https://dimagi.atlassian.net/wiki/x/SCLKfw - This allows contacts to register for the system on their own.
https://dimagi.atlassian.net/wiki/x/sQLKfw - This allows project staff to register contacts using SMS, a phone or web data entry (https://dimagi.atlassian.net/wiki/x/LCrKfw).
https://dimagi.atlassian.net/wiki/x/-yjKfw - Mobile workers need to be verified before they can send in messages to the system.
SMS Keywords Tutorial
Expand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This tutorial will introduce keywords. Keywords are used in Messaging to allow users to report data or request information from CommCare HQ. They do this by sending a special word in an SMS to a gateway connected to CommCare HQ. This tutorial will build a basic daily activity reporting system. Users will be able to report the number of houses they visited and participants they counselled on a daily basis. Supervisors will be notified if a given user does not report on their activity in a given data. We'll also have a keyword that allows a user to request help from their supervisor, which will send the supervisor an SMS messages stating that the user has requested help. In this tutorial you will learn the following:
Before staring this tutorial, setup a new project space unless you've already done so. Create a Keyword to Report Daily ActivityWe'll now setup a keyword to report the daily activity for each user. To collect data, we first need a form that contains the questions we want to capture. This is similar to an SMS Survey (that is not actually used in any application but is only used by Messaging). Setup the SMS Application We need to add a new application to the existing project. This application will contain all the form that represents the data to be collected by each data collector.
Add the Daily Activity Form We'll add a daily activity form that is used by the data collector to report their work. This form will also contain a last_reported_date hidden value that will be saved to the case. We'll use this date to trigger alert reminders to the supervisor.
Configure the Data Collection Keyword
Setting Up a Case to Report DataThis tutorial requires the use of a two-way SMS gateway. Your project must be on the Pro or higher Software plan to test this out. Follow the instructions at https://dimagi.atlassian.net/wiki/x/hCTKfw to choose a gateway for your project. This gateway should allow you to do two-way messaging. The Twillio gateway supports most countries in the world, but you may have to pay an international messaging fee to use it. Why Use Cases For Reporting Data This tutorial is going to setup a case for each user to report activity data. (That is, each user who reports activity data is going to be a case). This is necessary for a couple of reasons:
Setting Up a Case Registration Application We'll create an application in our project to register these cases that are used to report data.
Create the Registration Form This tutorial assumes you already know how to create a form with hidden values. Rename the Untitled Form to Registration and add questions so that it resembles the following. Some important things to note:
The full definition of the form is listed below:
Save the form and configure the case management to create a new case. Save all the questions as case properties. Its important the contact_phone_number and contact_phone_number_is_verified case properties are named correctly. This form is now setup to create a register a case that will report on their daily activity. The phone number on each case is the phone number of the user who will report data. Setup a Reminder Alert for Missed Data CollectionThis reminder will be configured to go out in the evening if the user does not report data for the day. The reminder will be sent the day after the last_reported_date. Since the last_reported_date is updated whenever daily activity is reported, if the user does not report their activity, this will cause the reminder to be sent out on that day (since last_reported_date will be yesterday).
Our system is now setup, so we can now test the messages and reminders. Setup the HELP KeywordWe'll now setup a basic keyword that data collectors can use to indicate they need some help or support. This will trigger a message that will go to their supervisor indicating that the user needs some help.
We'll now setup a reminder that will go to supervisors (the case owner) if the data collector does not report their activity for a day. Test the Keywords and AlertsNow that our reminders and application is setup, you can use a mobile worker to register a new pregnant mother and view her scheduled reminders on CommCareHQ. Setup a Sample Case
Test a Data Report Use the data collectors phone number to send in a daily activity report (ex. REPORT h23 p86). You should see the report in the Message Log report and a reminder scheduled to go out to the mobile worker who registered the case. This reminder will be for the next day (so if data collector doesn't report data, the message will get sent out). Basic Troubleshooting If your messages are not in the message log, there is some basic troubleshooting that you can do.
Other troubleshooting tips are available here: https://dimagi.atlassian.net/wiki/x/1S-Kfw. |