Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Configuration

Tyler Samples edited this page Dec 24, 2018 · 4 revisions

Multiple components of Courtbot are configurable. Ideally all modifications a brigade would like to make can be done via configuration. If you do not find a solution to your problem via the configuration guide, please create a issue!

Importer Configuration

Import mapping is a required set of configuration

Importer

importer: %{
  file: "../test/data/boise.csv",
  type:
    {:csv,
     [
       {:has_headers, true},
       {:headers,
        [
          {:date, "%-m/%e/%Y"},
          nil,
          nil,
          nil,
          {:time, "%k:%M:%S"},
          :case_number,
          nil,
          nil,
          nil
        ]},
     ]}
}
  • file or url
  • type
    • has_headers
    • headers: Is a keyword with :headers as the key and an list of mappings to your CSV data.
      • date and time: Syntax for defining formats can be found here.

Types

Case types are a tailor Courtbot responses based upon the case type. Case types can also help when there are duplicates of case id's by allowing you to differentiate between them.

types: %{
  :criminal => ~r//,
},

:criminal can be any atom as long as each is unique. Each case type is determined on import by matching it's regex with the :case_number. The ~r is required and an example full regex string would be ~r/^[A-Z]{2}\d{0,2}?-\d{2,4}-\d{2,}/

Locales

Locales are a require configuration. Locales configuration tells Courtbot what locale it should respond to a specific message with. It also how Courtbot knows which number to use when sending reminder notifications.

locales: %{
  "en" => "12083144089"
}

Miscellaneous

Court Details

Some additional details can be added to messages if they are set in configuration. A good example of this, is in telling the user how they can find more details. If the court_url is set then it will be included in the response.

court_url: "https://mycourts.idaho.gov/"

Scheduled Times

Courtbot Supports scheduling import and notification times within Elixir without depending on a systems cron. The benefits to using Elixir to do this is simply a single place to look if the import or notification process fails. It is recommended to use the functionality.

NOTE: This functionality does not work on Heroku due to it's sleep and wake functionality.

import_time: "0 9 * * *",
notify_time: "0 13 * * *"

import_time and notify_time require a valid crontab string.

Examples

Boise (Heroku)

The complete importer configuration for Boise's i.e. the file contents for config/courtbot.exs looks like this:

use Mix.Config

# Courtbot config.
config :courtbot, Courtbot,
  locales: %{
    "en" => "12083144089"
  },
  court_url: "https://mycourts.idaho.gov/",
  importer: %{
    file: "/tmp/boise.csv",
    type:
      {:csv,
       [
         {:has_headers, true},
         {:headers,
          [
            :case_number,
            :last_name,
            :first_name,
            nil,
            nil,
            nil,
            {:date, "%-m/%e/%Y"},
            {:time, "%k:%M"},
            nil,
            :county
          ]}
       ]}
  }