The LTI endpoint is a nodeJS app. It uses the open source ltijs library: https://github.com/Cvmcosta/ltijs
These instructions assume that you are using a *nix (linux or OSx) environment.
NOTE - inside the app folder there are two rsa key files: app/rs256.rsa app/rs256.rsa.pub It is recommended that on a production environment, these files are regenerated by running keygen.js
You will need to make sure that the chatbot tool (bfh-chatbot-bot) has a copy of the newly generated rs256.rsa.pub file in its root.
The RSA keys are used for authentication between the LTI endpoint (this app) and the chainlit chatbot.
Copy example.env to .env Change the variables of the .env file to fit your requirements.
Create a zip file to be uploaded to a docker host by running ./makezip.sh from within the root of this project Upload and extract this zip file to your docker host
From the cli, run: docker compose up -f docker-compose.yml -d
NOTE - if you would like to create multiple instances of the LTI endpoint app to go behind a load balancer, it is advised to instead run: docker compose up -f docker-compose-node-only -d
You will then need to create a separate mongo DB instance for all the node app instances to use.
It is critical that you secure this endpoint. The recommended method for this is to use a reverse proxy. The docker container will map the node app to port 5002. Here is an example of an nginx SSL virtual host which proxies 5002 to 443 with SSL:
# SSL config
server {
server_name lti.citri.city;
# SSL configuration
#
listen 443 ssl default_server;
ssl_certificate /etc/letsencrypt/live/lti.citri.city/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/lti.citri.city/privkey.pem;
access_log /var/log/nginx/nginx.vhost.access.log;
error_log /var/log/nginx/nginx.vhost.error.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:5002;
proxy_read_timeout 90;
proxy_redirect http://localhost:5002 https://lti.citri.city;
}
}
Once you have the LTI endpoint app running and available via https you can configure it in Moodle. Log in to Moodle as an admin user. Go to the external tools config page:
[yourmoodleurl]/mod/lti/toolconfigure.php
In the Tool URL field, enter the URL for the LTI endpoint app with /register at the end - e.g https://lti.citri.city/register
Click "Add LTI advantage"
After a while you should see the tool appear as a card under the "Tools" heading. Click "Activate" on this tool.
The LTI tool is now configured.
Open any course Turn editing on Click the add "Activity / Resource" button Select "External Tool" Enter an activity name - e.g "Chatbot" In the preconfigured tool selectbox, select the LTI tool you created in the previous steps The other fields can be left untouched Click "Save and display" Click on the tool instance You should now see the chainlit chatbot (providing the chainlit chatbot has been installed and configured correctly)