get_message_data: Retrieve Message Data from RapidPro API

View source: R/get_message_data.R

get_message_dataR Documentation

Retrieve Message Data from RapidPro API

Description

Fetches message data from the RapidPro API, allowing filtering based on different criteria such as folder, contact, label, or broadcast.

Usage

get_message_data(
  rapidpro_site = get_rapidpro_site(),
  token = get_rapidpro_key(),
  call_type = "messages.json",
  filter_variable = "folder",
  filter_variable_value = "flows",
  flatten = FALSE,
  date_from = NULL,
  date_to = NULL,
  format_date = "%Y-%m-%d",
  tzone_date = "UTC"
)

Arguments

rapidpro_site

A character string specifying the base URL of the RapidPro instance. Defaults to get_rapidpro_site().

token

A character string specifying the API token for authentication. Defaults to get_rapidpro_key().

call_type

A character string indicating the type of API call. Default is "messages.json".

filter_variable

A character string specifying the filtering criterion. Must be one of "folder", "contact", "label", or "broadcast". Default is "folder".

filter_variable_value

A character string specifying the value for the filter variable. If filter_variable = "folder", the allowed values are "inbox", "flows", "archived", "outbox", "sent", or "failed". Default is "flows".

flatten

A logical value indicating whether to flatten the retrieved data. Default is FALSE.

date_from

A character string specifying the start date for filtering messages (in the format specified by format_date). Default is NULL, meaning no filtering by start date.

date_to

A character string specifying the end date for filtering messages (in the format specified by format_date). Default is NULL, meaning no filtering by end date.

format_date

A character string specifying the date format used for filtering. Default is "%Y-%m-%d".

tzone_date

A character string specifying the time zone for date filtering. Default is "UTC".

Details

  • Only one filter can be applied at a time.

  • The function removes messages with missing UUIDs to ensure data consistency.

Value

A tibble containing the retrieved message data, filtered according to the provided criteria.

Examples

# Retrieve messages from the "flows" folder
#get_message_data(filter_variable = "folder", filter_variable_value = "flows")

# Retrieve messages from a specific contact
#get_message_data(filter_variable = "contact", filter_variable_value = "12345")

# Retrieve messages with a specific label
#get_message_data(filter_variable = "label", filter_variable_value = "survey_responses")

# Retrieve messages from a broadcast
#get_message_data(filter_variable = "broadcast", filter_variable_value = "98765")


lilyclements/Rapidreadr documentation built on April 17, 2025, 6:10 p.m.