Answer the question
In order to leave comments, you need to log in
How to organize the architecture of a chat bot with storing answers in 2 languages in a database?
I'm running a telegram chat bot. ( Link to rap )
And I stalled at the moment when I don’t understand how to do it better / more correctly so that there is no heavy load on the database and the chatbot works quickly, and it’s not difficult to expand it.
The bottom line is that the database should store the stages of the dialogue from different branches on which the user is located.
The question is how to organize it all, in the database and how to make it so that there would not be many calls to the database.
Now what I have done - leads me to the fact that either I will access the database a lot of times, or I will write a lot of logic somewhere in the controller classes of each dialog screen, or both.
CREATE TABLE `chat_messages` (
`id` int(11) NOT NULL,
`chat_id` int(11) NOT NULL,
`message_id` int(11) NOT NULL,
`text` text NOT NULL,
`date` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `reply_dictionary` (
`id` int(11) NOT NULL,
`lang` varchar(10) NOT NULL,
`action` varchar(255) NOT NULL,
`screen` varchar(255) NOT NULL,
`message` text NOT NULL,
`image_list` text NOT NULL,
`file_list` text NOT NULL,
`reply_markup` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`telegram_id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`current_screen` varchar(255) NOT NULL,
`lang` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question