This repository contains a FastAPI service that acts as a chatbot for integration with Nextcloud. The service listens for webhook events from Nextcloud and processes them accordingly. The setup involves running the FastAPI application locally and connecting it to Nextcloud, which runs in a Docker container.
- Webhook Integration: Listens for and processes incoming webhook requests from Nextcloud.
- FastAPI Framework: Utilizes FastAPI for creating the web service.
- Python 3.8+: Ensure you have Python 3.8 or newer installed.
- FastAPI: Install FastAPI and
uvicorn
for running the app. - Nextcloud: Running in a Docker container.
- Docker (for Nextcloud): Ensure Docker is installed if using Docker for Nextcloud.
git clone https://github.com/yourusername/your-repo-name.git
cd your-repo-name
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements.txt
fastapi
uvicorn
httpx
# .env file
NEXTCLOUD_BOT_SECRET=
NEXTCLOUD_URL=http:
# In Development
uvicorn main:app --host <IPv4 Address> --port 8000
This command starts the FastAPI server locally at http://<IPv4_Address>:8000/.
Ensure the Nextcloud instance is running and reachable.
Use the following command to install and configure the bot:
# Replace <> with your actual details.
php /var/www/html/occ talk:bot:install --feature bots-v1 <BOT_NAME> <BOT_SECRET> <BOT_SERVICE_URL/webhook> <DESCRIPTION>
See full documntation here: OCC documentation
Send a test message from Nextcloud and ensure that your FastAPI service logs or processes the message as expected. If communication fails, ensure that Nextcloud can reach the bot address.
- optional: Create new chat in Talk app and give it a name eg: Bot
- Enable bot in chat setting.
- send any message.
- Run the FastAPI Application: uvicorn main:app --reload
- Install Python Dependencies: pip install -r requirements.txt
- Activate Virtual Environment: source venv/bin/activate (Windows: venv\Scripts\activate)
- Connection Issues: If you receive errors like Failed to connect, ensure that the FastAPI service is running and accessible from the Nextcloud Docker container. You may need to adjust Docker networking settings or use the IP address of the host machine instead of localhost.
- Dependency Errors: Make sure all dependencies are installed and correctly listed in requirements.txt.
- FastAPI
- Nextcloud