Configuration properties#
A bot needs some parameters to be set to properly work. In this section, you will find all of them, and we will explain you how to load them in the bot.
A bot Property has a section, a name, a type and a default value
(for when the property is not defined by the bot developer).
Loading properties#
You can define your bot properties in 2 different ways:
Using a configuration `.ini` file: It is a file containing all the bot properties. Let’s see an example
config.inifile:
[websocket_platform]
websocket.host = localhost
websocket.port = 8765
streamlit.host = localhost
streamlit.port = 5000
[telegram_platform]
telegram.token = YOUR-BOT-TOKEN
[nlp]
nlp.language = en
nlp.region = US
nlp.timezone = Europe/Madrid
nlp.pre_processing = True
nlp.intent_threshold = 0.4
nlp.openai.api_key = YOUR-API-KEY
nlp.hf.api_key = YOUR-API-KEY
nlp.replicate.api_key = YOUR-API-KEY
[db]
db.monitoring = False
db.monitoring.dialect = postgresql
db.monitoring.host = localhost
db.monitoring.port = 5432
db.monitoring.database = DB-NAME
db.monitoring.username = DB-USERNAME
db.monitoring.password = DB-PASSWORD
Now you have to load the file into the chatbot:
bot = Bot('example_bot')
bot.load_properties('config.ini')
Setting individual properties: You can also set (and get) properties individually from the bot code.
from besser.bot.nlp import NLP_LANGUAGE
...
bot = Bot('example_bot')
bot.set_property(NLP_LANGUAGE, 'es')
...
language = bot.get_property(NLP_LANGUAGE)
Note
When you try to get a property that has not been previously set, it will return its default value.
You can also create your own properties:
from besser.bot.core.property import Property
...
FACEBOOK_PROFILE = Property('facebook', 'facebook.profile', str, 'https://www.facebook.com/foo')
...
bot.set_property(FACEBOOK_PROFILE, 'https://www.facebook.com/john_doe')
Next, let’s see all the built in properties, divided by sections.
NLP#
Definition of the bot properties within the nlp (Natural Language Processing) section
- besser.bot.nlp.HF_API_KEY = <besser.bot.core.property.Property object>#
The HuggingFace (Inference) API key, necessary to use a HuggingFace Inference API LLM.
name:
nlp.hf.api_keytype:
strdefault value:
None
- besser.bot.nlp.NLP_INTENT_THRESHOLD = <besser.bot.core.property.Property object>#
The threshold for the Intent Classification problem. If none of its predictions have a score greater than the threshold, it will be considered that no intent was detected with enough confidence (and therefore, moving to a fallback scenario).
name:
nlp.intent_thresholdtype:
floatdefault value:
0.4
- besser.bot.nlp.NLP_LANGUAGE = <besser.bot.core.property.Property object>#
The chatbot language. This is the expected language the users will talk to the chatbot. Using another language may affect the quality of some NLP processes.
The list of available languages can be found at snowballstemmer. Note that luxembourgish (lb) is also partially supported, as the language can be chosen, yet the stemmer is still a work in progress.
Languages must be written in ISO 639-1 format (e.g., ‘en’ for English)
name:
nlp.languagetype:
strdefault value:
en
- besser.bot.nlp.NLP_PRE_PROCESSING = <besser.bot.core.property.Property object>#
Whether to use text pre-processing or not. Stemming is the process of reducing inflected (or sometimes derived) words to their word stem, base or root form.
Currently, only
SimpleIntentClassifierandSimpleNERuse this property. IfLLMIntentClassifieris used, this property is ignored.For example ‘games’ and ‘gaming’ are stemmed to ‘game’.
It can improve the NLP process by generalizing user inputs.
name:
nlp.pre_processingtype:
booldefault value:
True
- besser.bot.nlp.NLP_REGION = <besser.bot.core.property.Property object>#
The language region. If specified, it can improve some NLP process You can find a list of regions here.
name:
nlp.regiontype:
strdefault value:
US
- besser.bot.nlp.NLP_STT_HF_MODEL = <besser.bot.core.property.Property object>#
The name of the Hugging Face model for the HFSpeech2Text bot component. If none is provided, the component will not be activated.
name:
nlp.speech2text.hf.modeltype:
strdefault value:
None
- besser.bot.nlp.NLP_STT_SR_ENGINE = <besser.bot.core.property.Property object>#
The name of the transcription engine for the Speech Recognition bot component. If none is provided, the component will not be activated.
name:
nlp.speech2text.sr.enginetype:
strdefault value:
None
- besser.bot.nlp.NLP_TIMEZONE = <besser.bot.core.property.Property object>#
The timezone. It is used for datetime-related tasks, e.g., to get the current datetime. A list of timezones can be found here.
name:
nlp.timezonetype:
strdefault value:
Europe/Madrid
- besser.bot.nlp.OPENAI_API_KEY = <besser.bot.core.property.Property object>#
The OpenAI API key, necessary to use an OpenAI LLM.
name:
nlp.openai.api_keytype:
strdefault value:
None
- besser.bot.nlp.REPLICATE_API_KEY = <besser.bot.core.property.Property object>#
The Replicate API key, necessary to use a Replicate LLM.
name:
nlp.replicate.api_keytype:
strdefault value:
None
WebSocket Platform#
Definition of the bot properties within the websocket_platform section:
- besser.bot.platforms.websocket.STREAMLIT_HOST = <besser.bot.core.property.Property object>#
The Streamlit UI host address. If you are using our default UI, you must define its address where you can access and interact with the bot.
name:
streamlit.hosttype:
strdefault value:
localhost
- besser.bot.platforms.websocket.STREAMLIT_PORT = <besser.bot.core.property.Property object>#
The Streamlit UI address port. The Streamlit UI address is composed by a host name and a port
name:
streamlit.porttype:
intdefault value:
5000
- besser.bot.platforms.websocket.WEBSOCKET_HOST = <besser.bot.core.property.Property object>#
The WebSocket host address. A chatbot has a WebSocket server that has to establish connection with a WebSocket client.
name:
websocket.hosttype:
strdefault value:
localhost
- besser.bot.platforms.websocket.WEBSOCKET_MAX_SIZE = <besser.bot.core.property.Property object>#
WebSocket’s maximum size of incoming messages, in bytes.
Nonedisables the limit.name:
websocket.max_sizetype:
intdefault value:
None
- besser.bot.platforms.websocket.WEBSOCKET_PORT = <besser.bot.core.property.Property object>#
The WebSocket address port. The WebSocket address is composed by a host name and a port
name:
websocket.porttype:
intdefault value:
8765
Telegram Platform#
Definition of the bot properties within the telegram_platform section:
- besser.bot.platforms.telegram.TELEGRAM_TOKEN = <besser.bot.core.property.Property object>#
The Telegram Bot token. Used to connect to the Telegram Bot
type:
strdefault value:
None
Database#
Definition of the bot properties within the db (Database) section
- besser.bot.db.DB_MONITORING = <besser.bot.core.property.Property object>#
Whether to use the monitoring database or not. If true, all the
DB_MONITORING_*properties must be properly set.name:
db.monitoringtype:
booldefault value:
False
- besser.bot.db.DB_MONITORING_DATABASE = <besser.bot.core.property.Property object>#
The database name.
name:
db.monitoring.databasetype:
strdefault value:
None
- besser.bot.db.DB_MONITORING_DIALECT = <besser.bot.core.property.Property object>#
The database dialect (e.g.,
postgresql).name:
db.monitoring.dialecttype:
strdefault value:
None
- besser.bot.db.DB_MONITORING_HOST = <besser.bot.core.property.Property object>#
The database host address (e.g.,
localhost).name:
db.monitoring.hosttype:
strdefault value:
None
- besser.bot.db.DB_MONITORING_PASSWORD = <besser.bot.core.property.Property object>#
The database password.
name:
db.monitoring.passwordtype:
strdefault value:
None
- besser.bot.db.DB_MONITORING_PORT = <besser.bot.core.property.Property object>#
The database port (e.g.,
5432).name:
db.monitoring.porttype:
intdefault value:
None
- besser.bot.db.DB_MONITORING_USERNAME = <besser.bot.core.property.Property object>#
The database username.
name:
db.monitoring.usernametype:
strdefault value:
None
API References#
Bot.set_property():
besser.bot.core.bot.Bot.set_property()Bot.get_property():
besser.bot.core.bot.Bot.get_property()Property:
besser.bot.core.property.Property