DEV Community

Kumar Deepanshu
Kumar Deepanshu

Posted on • Originally published at lumbox.co

LlamaIndex + Lumbox: Treat Your Inbox as a Queryable Knowledge Source

Originally published at lumbox.co

LlamaIndex made RAG something you can ship in an afternoon. Load docs into an index, attach an LLM, query. The gap most teams hit isn't the framework — it's finding a good data source. Your agent's own Lumbox inbox is a better source than most.

Why the inbox is good RAG fodder

  • It's high-signal, low-noise (it's already filtered by being sent to you).
  • It's structured — sender, date, subject, thread ID are all fields.
  • It grows organically as the agent does its work.

Wiring it up

from llama_index.core import VectorStoreIndex, Document
from lumbox import Lumbox

lumbox = Lumbox(api_key=os.environ["LUMBOX_API_KEY"])

def load_inbox_as_documents(inbox_id: str) -> list[Document]:
    messages = lumbox.inboxes.list_messages(inbox_id=inbox_id, limit=500)
    return [
        Document(
            text=m.text,
            metadata={
                "from": m.from_address,
                "subject": m.subject,
                "date": m.received_at,
                "thread_id": m.thread_id,
            },
        )
        for m in messages
    ]

docs = load_inbox_as_documents(my_inbox_id)
index = VectorStoreIndex.from_documents(docs)
query_engine = index.as_query_engine()
print(query_engine.query("What did Acme say about the Q3 timeline?"))
Enter fullscreen mode Exit fullscreen mode

Keep it fresh with webhooks

Subscribe to Lumbox's email.received webhook and incrementally upsert new messages into the index. No re-indexing, no polling. lumbox.co.

Top comments (0)