Note: if internet-connectivity is available, the simplest option is to opt-in to using the TriKB managed by Loom. Contact Loom Support for more details

When running multiple instances of Sophie (e.g. in different sites), it's recommended to setup a central repository to share Insights and Recommendations.

Step 1 - Install PostgreSQL Server 

To setup the TriKB, first install a PostgreSQL server running version 9.6

Interactive installation instructions can be found on the official website.

Step 2 - Create the Database

On the PostgreSQL server, create a database (e.g. loom ) and run the following script to create the required objects:

CREATE TYPE insight_status AS ENUM (
'PENDING',
'APPROVED');

CREATE TABLE public.insights_keys (
id bigserial NOT NULL,
reference_id text NULL,
service text NOT NULL,
pattern_text text NOT NULL,
metric_notation text NOT NULL DEFAULT ''::text,
CONSTRAINT insights_keys_pkey PRIMARY KEY (id)
);

CREATE TABLE public.insights (
id bigserial NOT NULL,
insight text NOT NULL,
recommendations text[] NULL,
insertion_time timestamp NULL DEFAULT now(),
insight_key_id int8 NULL,
trend text NOT NULL DEFAULT 'NONE'::text,
status insight_status NOT NULL DEFAULT 'APPROVED'::insight_status,
modified_time timestamp NULL DEFAULT now(),
remote_id int8 NULL DEFAULT (-1),
source_type_id int8 NULL,
uuid text NULL,
"version" int8 NOT NULL DEFAULT 1,
modified_locally bool NULL DEFAULT false,
CONSTRAINT insights_pkey PRIMARY KEY (id),
CONSTRAINT insights_insight_key_id_fkey FOREIGN KEY (insight_key_id) REFERENCES insights_keys(id) MATCH FULL
);

CREATE FUNCTION update_insights_modified_time()
RETURNS TRIGGER AS $$
BEGIN
    NEW.modified_time = now();
    RETURN NEW;
END;
$$ language 'plpgsql';

CREATE TRIGGER update_insights_modified_time BEFORE UPDATE ON insights
 FOR EACH ROW EXECUTE PROCEDURE update_insights_modified_time();

Next, create a user & password (change password and db-name as needed):

CREATE USER loom WITH ENCRYPTED PASSWORD 'changeme';
GRANT CONNECT ON DATABASE loom TO loom;
GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA public TO loom;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO loom;

Step 3 - Configure Sophie

Configure Sophie to connect to the TriKB by going to the Settings page and updating all the settings starting with postgres_rds :

Finally, make sure that env.shared_insights is set to true .
Restart Sophie to have the settings apply.

Step 4 (Optional) - Auto-approve Insights

By default, Insights are added to the TriKB as "pending". They need to be manually approved before they are distributed to other sites.
To disable this manual moderation step, go to the Features page (under Administration) and switch-on the AUTO_APPROVE_UPLOADED_INSIGHTS toggle.


That's it! Enjoy seeing your internal TriKB grow 🦉

Did this answer your question?