Simplify Event Planning with Lyzr’s QABot Agent: A Comprehensive Guide
Tags: tutorial, ai, beginners, python
Published: 2024-03-26 12:23:28

Event planning requires meticulous organization and attention to detail, but managing attendee inquiries can be overwhelming. Enter "Event Planner by [Lyzr](lyzr.ai)" – an innovative tool designed to streamline event logistics through the advanced capabilities of Lyzr’s QABot Agent. This article explores how this application revolutionizes event planning, empowering organizers to address attendee questions and concerns efficiently.

## Event Planner with Lyzr’s QABot Agent

Event Planner QnA harnesses the power of Lyzr’s QABot agent to respond promptly and accurately to attendee queries. Attendees can ask about schedules, locations, logistics, and more, ensuring they have the information they need for a seamless event experience.

## Lyzr’s Approach to Application Development

Lyzr offers an agent-centric approach to rapidly developing LLM (Large Language Model) applications with minimal code and time investment. Even if you’re unfamiliar with the GenAI stack, Lyzr empowers you to effortlessly build your AI applications. It serves as the go-to solution for constructing GenAI apps without requiring an in-depth understanding of Generative AI.

---
{% embed https://docs.lyzr.ai/lyzr-sdk/opensource/qa-bot/ %}
---


## Setting up the Project

Clone the "[Event Planning Assistant](https://github.com/PrajjwalLyzr/Event-Planning)" app repository.
Set up a virtual environment:

```python
python3 -m venv venv
source venv/bin/activate
```

Create an environment file named `.env` and add your OpenAI API key:

```python
OPENAI_API_KEY = "Your_OpenAI_API_Key"
```

Install the required dependencies

```python
pip install lyzr streamlit docx2txt
```

## Project Structure

```scss
Event-Planning-Assistant
│
├── utils/
│ ├── __init__.py
│ └── utils.py
│
├── data/
│ ├── __init__.py
│ └── Event Planner Assistance.docx
│
├── app.py
│
├── README.md
│
├── .env
│
├── .gitignore
│
└── requirements.txt
```

## Data Directory

The data directory contains a document file titled [“Event Planner Assistance.docx,”](https://docs.google.com/document/d/1qsOTREyCCcbAWadqdzATBZIpng0s0k8606-dIhNvKJI/edit?usp=sharing) which acts as a template for the event planning application. Users can modify this document to align with the requirements of their events.

## Utility Functions

The `utils.py` file contains essential utility functions for the application, such as `get_files_in_directory` to retrieve file paths within a directory.

```python
import os


def get_files_in_directory(directory):
    files_list = []

    if os.path.exists(directory) and os.path.isdir(directory):
        for filename in os.listdir(directory):
            file_path = os.path.join(directory, filename)
            
            if os.path.isfile(file_path):
                files_list.append(file_path)

    return files_list
```

## Creating an Entry Point for the Application ‘app.py’

The entry point script imports necessary libraries and modules, sets up the environment variables, and initializes the application.

```python
import os
from PIL import Image
import streamlit as st
from pathlib import Path
from utils import utils
from dotenv import load_dotenv; load_dotenv()
from lyzr import QABot
   
# replace this with your openai api key or create an environment variable for storing the key.
os.environ["OPENAI_API_KEY"] = os.getenv('OPENAI_API_KEY')
```

## Event Planning by QABot Agent

The `event_planner_qa` function sets up the Event Planner Question and Answer system using Lyzr’s QABot Agent. It retrieves relevant information from the document file and initializes the QABot agent.

```python
def event_planner_qa():
    path = utils.get_files_in_directory('data')
    planner_qa = QABot.docx_qa(
        input_files=[Path(str(path[1]))]
    )

    return planner_qa
```
file_checker() function is designed to check for files within the ‘data’ directory. This function is useful for verifying the existence and retrieving the paths of files stored in the specified directory.

```python
def file_checker():
    file = []
    for filename in os.listdir('data'):
        file_path = os.path.join('data', filename)
        file.append(file_path)


    return file
```

## Initiating the Application

The application prompts users to ask questions about event planning. Upon submission, it queries the QABot agent and displays the response.

```python
if __name__ == "__main__":
    file = file_checker()
    if file is not None:
        st.subheader('Plan your dream event!')
        question = st.text_input('Write you query')
        if st.button('Submit'):
            if question is not None:
                event_agent = event_planner_qa()
                response = event_agent.query(question)
                st.markdown('---')
                st.subheader('Response')
                st.write(response.response)
            else:
                st.warning("Ask question, don't keep it blank")
```

Event Planner QnA operates by processing uploaded event documents using Lyzr’s powerful QABot agent. This backend automation saves time and ensures consistency in responses, even for complex questions.

## References

For further exploration and engagement, visit Lyzr’s website, book a demo, or join the community channels on Discord and Slack.

- [Event Planning GitHub Repository](https://github.com/your-username/event-planning)
- [Lyzr Website](https://www.lyzr.ai/)
- [Book a Demo](https://www.lyzr.ai/book-demo/)
- Lyzr Community Channels: [Discord](https://discord.gg/nm7zSyEFA2), [Slack](https://join.slack.com/t/genaiforenterprise/shared_invite/zt-2a7fr38f7-_QDOY1W1WSlSiYNAEncLGw)

This article provides a comprehensive guide for leveraging Lyzr’s QABot agent to simplify event planning processes, demonstrating the effectiveness of AI-driven solutions in managing attendee inquiries and optimizing event logistics.