Technical Details
Data Module
The data module of the new Django API app for remote data collection using Twilio for WhatsApp includes four main models: Form, Data, Question, and Answer. These models are used to collect, store, and manage the collected data.
Form Model
The Form model is used to define the structure of the data that will be collected. It includes information such as the name of the form, a description of the form, and the fields that will be included in the form.
Question Model
The children of the Form model is Question model. Each Question includes fields for the ID of the form that the question belongs to, the name of the question, and the type of the question. The type field is defined using the Question Type enumeration, which includes options such as text, number, photo, geo-location, option and multiple-option.
Data Model
The Data model is used to store the collected data. It includes fields for the ID of the form that the data belongs to, the name of the data, and the submitter (phone number), as well as metadata such as the date and time that the data was collected and the location of the data collection.
Answer Model
The Answer model is used to store the answers to the questions in the Form model. It includes fields for the ID of the answer, the ID of the form data, the ID of the question, and the answer itself. The Answer model is also use to store the status of the submitter session. When the submitter completes all the question in the session, the data model should marked as done.
Workflow
The workflow image below illustrates the process.
- At first the Django API APP receives incoming messages and checks if the message
iscontainshello.pre-configuredIfparameteritwhichis,linkedsend the submitterto alistparticularofform,formse.gtowhenchoose.userComplaintype."complain";Therethere will beonly onea form inthe platformwhich will then be initiated for theuser .user. This also initiates a data record and sets status as draft Once the user selects a form and inputs the form number, store their phone number in aData recordwith the statusdraft.- Retrieve the questions for the selected form and start asking the user the questions one by one. Once the user answers a question, validate the answer. If the answer is invalid, notify the user that their answer was wrong and prompt them to answer again. If the answer is valid, store the answer in the Answer model and move on to the next question.
- Once all questions have been answered, the draft status in the Data record changed to completed.
Admin Interface
Still Draft