Reading in data from RapidPro API into R.
rapidpror is a package in R to import chatbot data from RapidPro into R.
You can install the development version of rapidpror from GitHub with:
# install.packages("devtools")
devtools::install_github("IDEMSInternational/rapidpror")
rapidpror is a package in R to import data from RapidPro into R for analysis. This section outlines the functions used to import into R. These functions are divided into three parts: Identifying Information, Flow and User Data, and Archived Data.
In RapidPro, each website is associated with a unique token or “key.” To simplify data retrieval and avoid repetitive key entry, we’ve designed the following functions to be defined in the package environment:
set_rapidpro_key()
sets the rapidpro key.set_rapidpro_site()
sets the rapidpro website.
Once the key and site are defined, you can use the corresponding get
functions to access them from other rapidpror
functions effortlessly:
get_rapidpro_key()
gets the rapidpro key.get_rapidpro_site()
gets the rapidpro website.
In this package, we retrive two types of data from RapidPro: user data and flow data. Each type requires its own functions due to unique characteristics:
get_data_from_rapidpro_api()
A general function that automatically fetches the key and site from the package environment, along with other specified parameters, such as dates for filtering. An essential feature is thecall_type
parameter, which determines the type of data to download. This function provides flexibility for various call types that users may have.get_user_data()
A wrapper ofget_data_from_rapidpro_api()
, this function retrieves user data with the relevantcall_type
, such as"contacts.json?group=joined"
.get_flow_data()
A wrapper ofget_data_from_rapidpro_api()
, this function fetches data from a specific flow (or “run”) usingcall_type = "runs.json?flow="
.get_flow_names()
This function gets the names of different flows
Data in RapidPro gets archived after a specific period. To access archived data, we provide the following functions:
get_archived_data()
Allows retrieval of archived data.update_archived_data()
Resaves the archived data with newer data, saving time and computing power during retrieval.
We aim to add some examples here in using the functions in rapidpror
.