Backfill Analytics Data

Get Started

Context supports one-time backfilling of transcripts from files or other data sources. To backfill your data, create a script to iterate over your conversations, using our SDKs to log transcripts as normal.

Correcting Timestamps will by default attribute a transcript's occurrence time (the time at which the interaction between the user and the LLM took place) to the ingestion time (the moment at which the transcript was ingested to

When backfilling your data from a static data source, you may wish to override the occurrence time with a timestamp from your dataset.

To override the attribution timestamp, set the event_timestamp field within one of the sub-message objects:

  "messages": [
      "role": "system",
      "message": "You are a LLM providing information about a local football club.",
  "metadata": { ... }


Import from CSV

import csv
import getcontext
from getcontext.generated.models import Conversation, Message, MessageRole, Rating
from getcontext.token import Credential
from dateutil.parser import parse

def main():
    token = "<insert context token here>"
    c = getcontext.ContextAPI(credential=Credential(token))
    with open("data/my_csv.csv") as csvfile:
        my_csv = csv.DictReader(csvfile)
        for row in my_csv:
            # Ensure that at least one message sets a correct event_timestamp.
            messages = get_messages_from_row(row)
            metadata = get_metadata_from_row(row)
                    "conversation": Conversation(

Last updated