AntiSLAPP is an open source legal defender that can assist an individual with putting together a defence against a defamation lawsuit in Canadian jurisdiction.
Antislapp runs as a guided conversation, asking the user questions. When the questions have been answered, the AI provides the user with two documents:
- A statement of defence for you, the user. This is to serve as a starting point for the user's defence.
- A supplemental document explaining the steps involved in a civil suit.
It is currently live at https://antislapp.ca
The dev branch is live at https://antislapp.ca/dev, but is not guaranteed to be up to date or bug-free.
To run your own copy of AntiSLAPP you need a public-facing webserver serving https requests, and an account (A Google account) on dialogflow.com. The architecture is Browser-->Chat Server-->Dialogflow.com-->Fulfillment Server.
The Chat Server portion can be run on localhost provided you have exported an environment variable called "CLIENT_ACCESS_TOKEN" with the matching value from your Dialogflow agent settings. The Fulfillment Server needs to be able to serve public secure requests from Dialogflow.com.
- Create a new agent. Lets call it MyAgent.
- Go to the agent setup page, and the "Export and Import" tab.
- This repo includes a zip file at the top level. Download that zip file.
- Choose "RESTORE FROM ZIP" and follow the instructions to upload the zip file you just downloaded into DialogFlow.
- On the "General" tab of the agent setup page, there is a field labeled "Client access token" You will need this later.
- Using the page navigation on DialogFlow, go to the Fulfillment page.
- Replace the URL field with your website address and the /fulfill page.
- Example: https://mysite.com/fulfill
- You're good to go on the dialogflow side!
The server side needs to serve the python files. Several options are available such as apache with mod-wsgi or nginx and fast-cgi. This readme will describe setting up nginx on a clean ubuntu image. Some of these steps may be unnecessary for you.
- Install nginx server:
sudo apt install nginx
- Install pip (for python packages)
sudo apt install python-pip
sudo pip install --upgrade pip
- Install python package flup (allows fast-cgi to work with python wsgi)
sudo pip install flup
- Install fcgi (fast-cgi for nginx)
sudo apt install spawn-fcgi
- Your webserver should show the NGINX default page now on http. You may need to start the services or reboot.
- Install AntiSLAPP repo
cd /var/www
sudo git clone https://github.com/riolet/antislapp.git
chown -R www-data: /var/www/antislapp
sudo pip install -r /var/www/antislapp/requirements.txt
- Configure your website. Https is necessary but full site configuration is beyond the scope of these instructions. Make sure your site includes the following:
- Note the CLIENT_ACCESS_TOKEN parameter below. You will need to replace that with your own token, from your dialogflow agent settings.
location / {
root /var/www/antislapp/antislapp;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param CLIENT_ACCESS_TOKEN "<your token here>";
fastcgi_pass 127.0.0.1:9002;
}
location /static/ {
root /var/www/antislapp/antislapp;
if (-f $request_filename) {
rewrite ^/static/(.*)$ /static/$1 break;
}
}
- Reload nginx and start up fcgi
sudo nginx -s reload
To enable your sitespawn-fcgi -d /var/www/antislapp/antislapp -f /var/www/antislapp/antislapp/index.py -a 127.0.0.1 -p 9002
To enable fcgi to run your python scripts- It would be wise to incorporate this command into a startup script. This depends on your system is also outside the scope of these instructions.
- Your website should be good to go now. Make sure it works if you connect at https://<your-site>.com
The fulfillment server needs to be able to respond to secure public requests, but the chat server (the page the user sees) can be run locally
This is useful for developing the website quickly and bypassing the requirements of being a public secure server.
- Clone the repository to a local folder
- Enter the repository folder (/antislapp)
- (optional) install a virtual environment for python packages
virtualenv env
(this command may be different for you)source env/bin/activate
(this command may be different for you)
- Install the required packages
pip install -r requirements
- Using the "Client Access Token" from your dialogflow agent settings, add it to your environment variables
export CLIENT_ACCESS_TOKEN=a1b2c3d4e5f6g7h8ij9
- Enter the inner antislapp folder and run the webserver
cd antislapp
python index.py
- Navigate your browser to http://localhost:8080