Chatbot of the Decide Madrid 2019 system. This version was used in the DGO.2022 conference.
This repository contains the fulfillment section described in the article "A Conversational Agent for Argument-driven E-participation", used for the (DGO 2022) 23st Annual International Conference on Digital Government Research Theme: Intelligent Technologies, Governments and Citizens. This is, therefore, Flask Server source code ready to be installed in a Heroku server. It accepts Webhook petitions (JSON formatted POST requests with specific contents) at https://chatbot-tfg-server.herokuapp.com/webhook.
Interaction to this server is automatically managed by a DialogFlow ES conversational agent. Then, an integration via Telegram is used to simplify user access to the chatbot, which can be accessed via this Telegram user link: https://t.me/chat_tfg_coll_bot
This project uses arguments extracted in this repository by Andrés Segura-Tinoco in this organization.
For the experiment, two populations where considered: one with and one without facilities to gather arguments from the proposals or comments.
This separation is considered in this version of the chatbot. The solution to gather these two populations was taking Telegram's permanent chat_id
of each user as a key for each user. Each new chat_id
(each new user interacting with the chatbot) is either asigned a version with arguments or without arguments if the last user had no arguments and viceversa, respectively and that characteristic is annotated in the following interaction "logs", which allowed the experiments to be analyzed. Logs can be seen with this Heroku link
Main folder contains environment variables and other Heroku server deployment files.
Server files and source code is located under /flaskapp
folder.
Server routes file is located here. One endpoint is used (https://chatbot-tfg-server.herokuapp.com/webhook) for all the chatbot interactions, the others being used for maintenance purposes.
The way Dialogflow interactions work is via conversational intents, or conversational situations automatically detected under certain user inputs. That intent information is passed to this server in a webhook petition, which is analyzed and then a python method is called to solve that conversational intent according to other metadata read in the DialogFlow platform (entities, parameters, contexts,...)
More explicitly, in the file intents.py
(here) an IntentManager class is instantiated once for each chat_id
. Then, when a user with a specific chat_id
puts an input to DialogFlow, that platform sends to this server a webhook petition with the detected intent name and analyzed metadata. The server reads the chat_id
and the corresponding IntentManager is invoked. Inside it, a method with name the one of the given intent and a dfr
parameter (where all the metadata is supplied) is called to produce the final webhook answer which is sent back to DialogFlow as an HTTP response.
Database management is used via SQLAlchemy ORM facilities. The structure can be found in the models.py
file.
Other modules are just used to distribute functionality implementation.
- pydialogflow-fulfillment 0.1.4: Apache Software License. Webhook petitions facility
- SQLAlchemy 1.4.21: Python sponsored, MIT license. Database management
- Flask 2.0.1: BSD-3-Clause Source License, Pallets 2010. Server library
- Flask SQLAlchemy 2.5.1
- Gunicorn 20.1.0
- Psycopg2 2.8.6
- Python YAML 6.0
Created on Dec 31, 2021
Created by:
This project is licensed under the terms of the Apache License 2.0.
This work was supported by the Spanish Ministry of Science and Innovation (PID2019-108965GB-I00) and the Centre of Andalusian Studies (PR137/19). The authors thank to all people who participated in the reported study.