Context_chat Backend not working

We have been attempting to integrate the Context Chat Backend with Nextcloud (version 31.0.2) to enable document-based conversation functionality. The overall architecture involves a Nextcloud instance (running natively) and the Context Chat Backend (running in Docker). While Ollama is running successfully and we are able to generate responses from the AI and chat in general, we are currently unable to perform document-based Q&A.

The Context Chat Backend was installed by following the instructions from the official GitHub repository: https://github.com/nextcloud/context_chat_backend. It was deployed as a Docker container, and due to volume mount issues (read-only file system errors), we manually created a bind mount using mount --bind to expose the Nextcloud data directory (/var/www/nextcloud_backup/data) into the container at /app/files. This allowed the container to access the uploaded documents.

The file Nextcloud Manual.pdf is confirmed to be accessible inside the container at:

/app/files/admin/files/Nextcloud Manual.pdf

We verified that embedding is working correctly by testing with curl directly against the embedding server (Ollama), which is running locally. The embedding model being used is nomic-embed-text:latest.

However, when we invoke the /query API endpoint, the Context Chat Backend responds with {"error":"Invalid signature of the request"}. We confirmed the signature logic is implemented correctly using HMAC SHA256 with the message format:

context_chat_backend:<timestamp>

and HMAC secret.

We tried several values for the HMAC secret including 12345 and abcd1234, and confirmed that the generated signature matches the backend logic. Despite this, the backend always returns an invalid signature error. The logs on Nextcloud also show:

Error	app_api	Invalid signature for ExApp: context_chat_backend and user: null
Error	app_api	ExApp context_chat_backend request to NC validation failed

On inspecting the Context Chat Backend’s config.yaml, we noticed that the app_api_hmac_secret field was missing, likely due to the file being regenerated. We manually edited config.yaml inside the container to include:

app_api_hmac_secret: "12345"

Then we restarted the container.

On the Nextcloud side, we attempted to register the app manually through Settings → Security, but the External apps section does not appear to exist in version 31.0.2. This means we cannot register the external app ID (context_chat_backend) and associate it with the shared secret (12345) as instructed by the Context Chat Backend documentation.

Here is the relevant portion of config.php from our Nextcloud instance:

<?php
$CONFIG = array (
  'instanceid' => 'oc6...',
  'passwordsalt' => '...',
  'secret' => '...',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'scalenowai.com.au',
  ),
  'datadirectory' => '/var/www/nextcloud_backup/data',
  'dbtype' => 'mysql',
  'version' => '31.0.2.1',
  'app_install_overwrite' => 
  array (
    0 => 'context_chat_backend',
  ),
);

We also verified that the file was uploaded via the Nextcloud UI and exists on disk.

Summary of Current Situation

\

The system has been set up, and the main components are running as expected. The context_chat_backend service has been configured and is operational in a Docker container. The embedding module nomic-embed-text:latest is being used, and the Ollama backend is running, allowing text generation capabilities. The connection to Nextcloud and the ability to generate summaries from documents have been tested. The AI component can now generate text based on user queries.

\

The config.php file has been reviewed and is configured to ensure proper functionality, including integration with Nextcloud and the external app context_chat_backend. All components are correctly wired together, and the external app has been configured with the necessary credentials, such as the HMAC secret 12345, to ensure secure communication between Nextcloud and the backend.


What Works Well:

Ollama Text Generation: The AI is successfully generating text based on the provided inputs, with the Ollama backend running as expected.

Embedding Module: The nomic-embed-text:latest embedding module is integrated and functioning.

Backend Configuration: The context_chat_backend Docker container is set up properly and able to interact with Nextcloud using the provided app credentials.

File Access: The document Nextcloud Manual.pdf is accessible and being used as input for processing and summarization.


What Is Not Working:

Conversation with Document: The final functionality where the AI should be able to engage in a conversation with the document is not yet working as intended. This is the main gap remaining in the system’s functionality.

Invalid Signature Error: When making requests to the context_chat_backend, the system is returning an “Invalid signature of the request” error. Despite generating the correct HMAC signature, the system is still unable to authenticate the requests.

Summary:

  • Context Chat Backend is installed and running in Docker with document data bind-mounted using mount --bind.
  • Ollama embedding model nomic-embed-text:latest is working.
  • AI responds to text input and general questions.
  • Document-based Q&A fails due to signature verification.
  • Signature generation logic and shared secret appear correct.
  • Unable to register external app ID in Nextcloud UI (External Apps section missing).

Next Steps:
We need support to determine:

  1. How to manually register or inject the shared secret in Nextcloud if the External Apps UI is missing.
  2. Whether there’s a known limitation in Nextcloud 31.0.2 regarding external app registration.
  3. Any alternative method to bypass or debug the signature check from within the backend or Nextcloud itself.