This project is an initiative to create a tool that converts any webpage URL into a shareable presentation link using Alai's platform. The tool leverages the Firecrawl API to scrape webpage content and processes it through Alai's undocumented API (reverse-engineered via Chrome's network tab) to generate a professional 5-slide presentation. To optimize the output, I designed a structured slide schema, comprising a title slide with a concise headline, content slides with hierarchically organized text extracted from the webpage, and a conclusion slide summarizing key points, all styled with a professional business tone. Additionally, I implemented an image extraction and resizing pipeline, selecting one relevant image per slide from the webpage, and embedding it to enhance visual coherence and presentation polish.
Clone this repository to your local machine:
git clone https://github.com/Mayankrai449/ALAI_Presentation-backend-.git
cd ALAI_Presentation-backend-Install the required Python packages listed in requirements.txt:
pip install -r requirements.txtCreate a .env file in the project root and add the following variables with your credentials:
FIRE_CRAWL_API_KEY=your_fire_crawl_api_key_here
ALAI_API_KEY=your_alai_api_key_here
ALAI_EMAIL=your_alai_email_here
ALAI_PASSWORD=your_alai_password_here
Refer .env.example for a template. Make sure to replace the placeholders with your actual API keys and credentials.
- FIRE_CRAWL_API_KEY: Get this by signing up at Firecrawl.
- ALAI_API_KEY, ALAI_EMAIL, ALAI_PASSWORD: Obtain these by creating an account at getalai.com.
Run the script from the terminal, providing a URL as an argument: Example:
python3 script.py https://en.wikipedia.org/wiki/CatReplace https://en.wikipedia.org/wiki/Cat with any webpage URL you want to convert into a presentation.
The script will output a shareable link (e.g., https://app.getalai.com/view/[share-code]) if successful.
Example: https://app.getalai.com/view/4bNmEBCOSsmzWnxgULdh8w
While scraping data, the script creates a scraped_data directory with two subcomponents:
scraped_data/: Stores the cleaned text content from the webpage as a .txt file.scraped_data/images/: Saves up to 10 images extracted from the webpage (e.g., .jpg, .png).
- Scraping: The script uses the Firecrawl API to scrape markdown text and images from the input URL, saving them in scraped_data/.
- Authentication: It authenticates with Alai's API using a token (stored in AUTH_TOKEN), which expires every 30 minutes to 2 hours.
- Presentation Creation: It creates a new Alai presentation with a unique ID, then generates 5 slides using WebSocket endpoints:
- Create new presentation with unique id.
- Get presentation and its questions.
- Generate slide outlines using websockets.
- Image Integration: Up to 5 scraped images are uploaded and added to slides, sized at ~1/4th of the slide area.
- Output: A shareable link is generated and logged, with all API responses saved in a JSON file for debugging.
See requirements.txt for the full list of dependencies, including requests, websocket-client, beautifulsoup4, Pillow, and python-dotenv.
- Ensure your API keys are valid and the
.envfile is correctly configured. - The script logs progress to
presentation_generator.logand saves responses in a timestamped JSON file (e.g.,presentation_responses_YYYYMMDD_HHMMSS.json).

