DocBot: The Google Docs Chatbot

 from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from fastapi import Request
import uvicorn
from google_docs_reader import get_google_docs_content
from abilities import llm_prompt

app = FastAPI()

@app.get("/", response_class=HTMLResponse)
async def read_root():
    with open('templates/index.html', 'r') as file:
async def ask_question(request: Request):
    body = await request.json()
    doc_urls = body.get("doc_url").split(',')
    question = body.get("question")
    doc_contents = []
    for url in doc_urls:
        content = get_google_docs_content(url.strip())
        if not content.startswith("Failed"):

About this template

An app for analyzing team documents, providing answers to questions, and displaying important information about its capabilities and restrictions.

Introduction to the DocBot: The Google Docs Chatbot Template

Welcome to the DocBot template! This template allows you to create an application that can read content from Google Docs and answer questions based on that content. It's perfect for analyzing team documents and providing quick answers without the need to read through the entire document. This step-by-step guide will walk you through how to use this template on the Lazy platform.

Getting Started

To begin using the DocBot template, simply click on Start with this Template on the Lazy platform. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy or paste any code manually.

Initial Setup

Before testing the application, ensure that you have the URLs of the Google Docs you want to analyze. These documents must be "published to the web" to be accessible by the app. Follow the steps provided in the template's code to publish your Google Docs.

Test: Pressing the Test Button

Once you're ready, press the Test button on the Lazy platform. This will deploy your application and launch the Lazy CLI. The Lazy CLI will prompt you for any required user input.

Entering Input

After pressing the Test button, if the application requires user input, the Lazy App's CLI interface will appear. You will be prompted to provide the necessary input there. For this template, you will need to input the URLs of the Google Docs you want to analyze and the questions you want to ask.

Using the App

Once the app is running, you will be provided with a dedicated server link to interact with the app. If you're using the FastAPI framework, you will also receive a link to the API documentation. Use these links to send requests to your application and receive answers to your questions based on the content of the Google Docs.

Integrating the App

If you need to integrate this app into another service or frontend, you can use the server link provided by the Lazy builder CLI. For example, you can add the API endpoints to an external tool or use the server link to send requests from a custom frontend interface.

Here is a sample request you might send to the app:

POST /ask/ HTTP/1.1
Host: [your-server-link]
Content-Type: application/json

    "doc_url": "",
    "question": "What is the main topic of the document?"

And here is a sample response you might receive:

    "answer": "The main topic of the document is..."

Remember, the Lazy platform handles all the deployment details, so you don't need to worry about setting up your environment or installing libraries. Just follow the steps above to get your DocBot application up and running!

If you encounter any issues or have questions about the template, refer to the documentation links provided in the code for additional guidance.

Last published
April 7, 2024

More templates like this

DocBot: The Google Docs Chatbot