DiabeticFoodBot: Food and Water Intake Recommender System for
Diabetics
Irwan Reza Firmansyah
1
, Z. K. A. Baizal
1
, and Ramanti Dharayani
1
1
School of Computing, Telkom University, Bandung, Indonesia
Keywords:
Food and Water Intake, System for Diabetics.
Abstract:
Diabetes is a non-communicable disease which is one of the highest causes of death in the world. Diabetics
need to arrange the schedule, amount and type of food and water consumed every day from a nutritionist to
regulate blood sugar levels so that complications do not occur. A recommender system for food and water
intake that has been validated by nutritionists is needed to assist diabetics in determining the nutrients con-
sume. In this study we develop Artificial Intelligence (AI) telegram chatbot called as DiabeticFoodBot. This
system can provide food recommendations and water intake for diabetics. There are many previous works that
developed recommender systems for diabetics. However, this study has not considered the amount of water
intake for diabetics. In addition, our research uses household size in presenting the results of recommendations
to make it easier for users to determine serving sizes without using a scale. We develop our system using on-
tologies with Semantic Web Rule Language (SWRL) because they are considered capable of providing better
performance. The DiabeticFoodBot validation result of 94.7 percent shows that our system can provide good
recommendation results for users.
1 INTRODUCTION
Diabetes is a non-communicable disease that causes
1.5 million deaths every year and affects 422 million
people worldwide. Most of people with diabetes live
in low to middle income countries (W.H.O., 2022).
In Indonesia, the highest mortality from chronic dis-
ease is caused by diabetes mellitus (Office, 2022).
Diabetes is divided into four types, including IDDM
(Insuline Dependent Diabetes Mellitus) or type 1 di-
abetes caused by autoimmune Langerhans beta cell
damage, NIDDM (Non Insuline Dependent Diabetes
Mellitus) or type 2 diabetes caused by relative failure
of Langerhans beta cells and resistance insulin, gesta-
tional diabetes occurring during pregnancy, and spe-
cific diabetes (Rahman et al., 2018; Hardianto, 2020).
Diabetes can strike anyone regardless of age or race.
and more common in obese people. Diabetes can
cause complications in the heart, nerves, kidneys and
eyes (Ministry, 2013).
To help control the blood sugar and minimize
complications, diabetics must maintain the amount,
type, and schedule of meals every day (Jahidin, 2019).
Face-to-face consultation with a nutritionist is needed
to get food recommendations that is suitable for dia-
betics is not possible to do every day. Although now
telemedicine has developed which can help diabetics
get consultation with a nutritionist online, this is not
effective and efficient if done every day and costs a lot
(Simatupang, 2020). Therefore, diabetics need to de-
velop a food recommender system that has been vali-
dated by a nutritionist and can provide recommenda-
tions automatically to manage their daily meal menu.
We found a lot of research that built a food rec-
ommender system for diabetics. However, these stud-
ies have not considered the water intake for diabet-
ics. Even though we found research in India that
applied hydrotherapy as a therapy to regulate blood
sugar for diabetics. Water is also a medium for de-
livering nutrients and other substances into the body’s
cells and removing toxic substances so that the water
consumed will affect the patient’s blood sugar (Lim
et al., 2011). Therefore, we are considering building
a recommender system that also regulates the amount
of water intake of users.
Ontology is used as a knowledge domain to rep-
resent various types of food and the amount of min-
eral water served for users. The Semantic Web Rule
Language (SWRL) search method is an option in in-
ducing food menus and mineral water intake to users
because it can provide more expressiveness compared
to using a relational database which cannot produce
314
Firmansyah, I., Baizal, Z. and Dharayani, R.
DiabeticFoodBot: Food and Water Intake Recommender System for Diabetics.
DOI: 10.5220/0012639000003848
Paper published under CC license (CC BY-NC-ND 4.0)
In Proceedings of the 3rd International Conference on Advanced Information Scientific Development (ICAISD 2023), pages 314-320
ISBN: 978-989-758-678-1
Proceedings Copyright © 2024 by SCITEPRESS Science and Technology Publications, Lda.
output if the data sought is not found. Several stud-
ies have also used ontology and SWRL to recommend
food menus (Cahn, 2017).
There is study that uses conversational systems to
interact with users. However, the flexibility in conver-
sional systems that use chatbots is better, so it needs
to be considered (Baizal et al., 2020). Chatbots have
the ability to interact with users without the need for
a third person to provide feedback by utilizing Arti-
ficial Intelligence (AI). Chatbot through Telegram so-
cial media is used to make it easier for users to interact
with the system through applications that are world-
wide and familiar to users and can be downloaded for
free on their smartphones (Editor, 2019; Arjun and
Baizal, 2022; Nurani et al., 2022). Based on the prob-
lems discussed in this study, we developed Diabet-
icFoodBot using the Telegram Chatbot based ontol-
ogy and SWRL. This system was developed to make
it easier for diabetics to determine the amount, type
and time of food consumption based on the valida-
tion results of nutritionists. This recommender system
provides information regarding the amount of water
consumption required by the user. Our research also
uses matrix unit serving sizes and household measure-
ments in presenting recommendations to make it eas-
ier for users to determine food portions.
1.1 Related Work
Several researchers have conducted study related to
determining the diet for diabetics. The goal of their
study is to automatically provide dietary recommen-
dations for diabetics using ontology. At the testing
stage, the researchers collected data from diabetics.
The data obtained is used as a query object. The re-
sults displayed are in the form of a food menu ar-
rangement with units of calories or weight units in
grams (Mckensy-Sambola et al., 2021; Arwan et al.,
2013; Farman Ali et al., 2017; Rachman and Nurjan-
nah, 2019).
Research using ontology design has problems in
displaying results that must be in accordance with the
database. If the database does not contain the infor-
mation the user wants, then the recommender system
cannot display the results. This problem is answered
in a research article that optimizes the recommender
system application using SWRL. SWRL is still able
to provide the information the user wants if similar
results are not found in the database by reviewing the
available database similarities. The results of the ac-
curacy of these studies can still be improved (Baizal
et al., 2020; Nurani et al., 2022; Arwan et al., 2013).
The use of chatbots in a food recommender sys-
tem for diabetics has also been used in Thailand and
has received a positive response to the user experience
due to its attractive appearance, easy use, fast per-
formance, and clear content. However, this research
only uses the Google Sheet system as a database
(Thongyoo et al., 2020). The use of Google Sheets
as a database has drawbacks such as error-prone in
data input, slow loading speed, limited data types that
can be stored, limited number of record storage, less
structured, and less speed in searching for data (Weir
et al., 2010). The use of chatbots with SWRL anal-
ysis on telegrams is also used in film recommender
systems, but does not apply ontologies (Nurani et al.,
2022).
Based on previous research studies, the develop-
ment of a food recommender system for diabetics can
be optimized by representing ontology and SWRL us-
ing a telegram chatbot. The addition of a mineral wa-
ter intake recommendation feature was also added in
this study to maximize the user’s blood sugar control.
1.2 Related Theory
The total daily calorie requirement is determined us-
ing the Basal Metabolic Rate (BMR) formula mul-
tiplied by the Activity Factor (AF) in daily activity.
BMR is the calories needed by the body to perform
basic functions (Sihombing, 2017; Harris and Bene-
dict, 1918).
Male BMR = 88, 362 + (13, 397weight [kg])+
(4, 799 x height [cm])
(5, 677 x age[years]
(1)
Female BMR = 447, 593 + (9, 247weight [kg])+
((3, 098 x height [cm])
(4, 330 x age [years]
(2)
The user’s daily caloric needs are calculated using
the Body Mass Index (BMI), Basal Metabolic Rate
(BMR), and input data regarding the user’s daily ac-
tivity intensity. BMI is used to interpret the user’s
weight status. While the user’s activity intensity is
used as a supporting factor to determine daily caloric
needs (Harris and Benedict, 1918).
BMI =
Mass(kg)
Height(m)
2
(3)
BMI interpretation Table is used to determine the
user’s weight status (Indonesia, 2018).
Users’ daily activity intensity Table 2 is little or
no exercise, light, moderate, and vigorous exercise
(Mawartika and Guntur, 2021).
DiabeticFoodBot: Food and Water Intake Recommender System for Diabetics
315
Table 1: Body mass index.
BMI Weight Status
< 18.5 Underweight
18.5-22.9 Normal (Ideal)
23-24.9 overweight (Overweight)
25-29,9 Obesity I
> 30 Obesity II
Table 2: Daily activity and activity Factor.
Daily Activity Activity Factor (AF)
Man Woman
Little or no exercise
(Only light daily activi-
ties)
1.30 1.30
Light exercise (1-3 days
a week or light daily ac-
tivities)
1.56 1.55
Moderate exercise (3-5
days a week or moderate
daily activity)
1.76 1.70
Vigorous exercise (6-7
days a week or doing
strenuous daily activi-
ties)
2,10 2.00
The recommended formula for daily calorie needs
uses:
Daily Calories = BMR x AF ± Calories BMI (4)
BMI calories for the normal level are increased by
0 calories, the underweight level is increased by 500
calories, the overweight level is reduced by 300 calo-
ries, and the obese levels 1 and 2 are reduced by 500
calories. This calculation is used to improve the ac-
curacy of the calculation based on the intensity of the
activities carried out and considering the user’s BMI
level.
The calculation of the mineral water intake needed
by the user is (Gunardi, 2022):
Water Intake =
Weight(kg)x30
1000
(5)
The unit used in this calculation is liters. Calcula-
tion of daily nutritional needs is obtained through the
formula Percent Daily Value.
%DV =
NutritiononFood(g)
Daily Value
x100 (6)
The author uses the FDA-approved 2022 Daily
value Table 3 to calculate the user’s daily requirement
(F.D.A., 2020).
Meal portions each day are divided into 25% of
daily calories for breakfast, 25% of daily calories for
Table 3: Daily value.
Nutrition Daily Values
Carbohydrate 300g
Proteins 50g
Fat 78g
lunch, 20% of daily calories for dinner, and 30% of
daily calories for snacks according to what has been
agreed upon by a nutritionist.
2 METHODOLOGY
2.1 System flow
In this research, we developed a chatbot on the Tele-
gram platform that can be accessed by users via lap-
tops, mobile phones or computers. The system re-
ceives input from the user in the form of user informa-
tion such as height, weight, daily activity, age, gender,
and user’s allergy history. This information is sent
to the handler to be changed in the form of a query.
Based on this query, the system performs reasoning
on system knowledge (Ontology and SWRL Rules)
to be able to provide recommendations. The recom-
mendation results are sent to the user via the chatbot
interface. This flow is shown in Figure 1.
Figure 1: Chatbot system flow.
2.2 System development
2.2.1 Knowledge development (Ontology and
SWRL)
There are four main classes that will be applied to the
ontology design. The main class is BMI, User, Al-
ICAISD 2023 - International Conference on Advanced Information Scientific Development
316
lergy, and Menu. The main ontology shown in Figure
2.
Figure 2: Chatbot system flow.
BMI class hierarchy is classification based on
calculated values from user input using height and
weight as parameters. The subclasses of the BMI
class are obesityI, obesityII, overweight, normal and
underweight Figure 3.
Figure 3: The hierarchy of BMI class.
The User class stores user characteristic informa-
tion. Meanwhile, the Menu Class stores information
regarding the types of drinks and food. The sub-
classes of the Menu class are Drink, Snack, and Food.
The Food subclass stores data about fruits, carbohy-
drates, proteins, and vegetables Figure 4.
Figure 4: The hierarchy of Menu class.
The snack subclass stores data about snack such
as chips and cake. The Allergy class will store the
various types of allergies considered such as, nuts, di-
ary, oats, chicken, and seafood. Rule development
is adjusted to the calculation of the necessary needs.
An example of this calculation is the determination of
BMI and BMR values.
2.2.2 Information Retrieval
Information retrieval is the initial stage to obtain in-
formation from users. This process is carried out by
requesting data input from the user in the form of
functional requirements that act as properties in the
class, including information about the user’s height,
weight, daily activity, age, gender, and allergy history,
which is stored in the User Class.
2.2.3 Knowledge Validation
The validation process in this study was carried out
by nutritionists. Nutritionists validate datasets for on-
tology development. They also validate SWRL.
3 RESULTS
3.1 Implementation of Ontology and
SWRL
We use prot
´
eg
´
e version 5.5.0 for composing the on-
tology. We use the top-down (tree) technique which
is defined by forming classes, continuing into sub-
classes and ending with instances. The hierarchy of
class is shown in Figure 5.
Figure 5: The hierarchy of class in ontology.
Each class in the ontology has a data property.
This Data Property serves to complete the information
of each class. In addition to data properties, object
properties are also defined to link between instances
of each class through semantic relations. Figure 6
shows the data properties and object properties that
DiabeticFoodBot: Food and Water Intake Recommender System for Diabetics
317
are used to create hierarchies and conceptual relation-
ships between instances.
Figure 6: Data properties and object properties.
The User class has a data property:
hasBMI: the property that store the BMI calcula-
tion result data.
User (?p)
h
asweight(?p, ?w)
h
asheight(?p, ?h)
s
wrlb :
mul tiply(?wh, ?w, 10000)
s
wrlb :
mul tiply(?hm, ?h, ?h)
s
wrlb :
divide(?bmi, ?wh, ?hm) > hasBMI(?p, ?bmi)
BMI calculation will be obtained to classify user
level BMI. For example, if the user’s BMI is less
than 18.5, it is considered underweight.
User (?p)
h
asBMI(?p, ?bmi)
s
wrlb :
greaterT han(18.5, ?bmi) > underweight(?p)
Recommendations are given to users in the form
of 5 menus (Figure 5), that are breakfast menu,
morning snack, lunch, afternoon snack and din-
ner. The process is built using object properties
as can be seen in figure 5. LevelNutrient is a
property used to see whether the food is included
in the appropriate nutritional category to be rec-
ommended to users based on the nutrients in the
food. The calculation is obtained based on the
daily value with the SWRL rule example as fol-
lows:
High fat
Menu(? f )
h
asNutrientFat(? f , ?n)
s
wrlb :
divide(?h, ?n, 78)
s
wrlb :
mul tiply(?DV, ?h, 100)
s
wrlb :
greaterT hanOrEqual(?DV, 20) >
LevelNutrient(? f , HighFats)
Low Carb
Menu(? f )
h
asNutrientCarbo(? f , ?n)
s
wrlb :
divide(?h, ?n, 300)
s
wrlb :
mul tiply(?DV, ?h, 100)
s
wrlb :
greaterT hanOrEqual(5, ?DV ) >
LevelNutrient(? f , LowCarbo)
The Menu class has a data property:
hasServingSize: the property that will define the
food in terms of serving size measures. Described
in string form.
hasWater: property to store the recommended
amount of mineral water intake. The following is
the SWRL rule formula for hasWater:
User (?p)
h
asweight(?p, ?w)
s
wrlb :
mul tiply(?wt, ?w, 30)
s
wrlb :
divide(?water, ?wt, 1000) >
hasWater(?p,?water)
3.2 DiabeticFoodBot Prototype
The recommender system provides a recommenda-
tion menu according to user information. The chatbot
development process is carried out using the Python
language. For database development and queries, we
use sqlite3. Furthermore, to connect the program to
Telegram, we use the provided Telegram API. The
system receives input in the form of user informa-
tion, that is gender, age, activity intensity, weight,
height, temporary blood sugar, diabetes symptoms,
diabetes complications, and allergies. The system rec-
ommends food menus and mineral water intake, in-
cluding information about nutrition and when to con-
sume food. The conversation flow process is shown
in Figure 7.
Figure 7: The hierarchy of BMI class.
The language used in this chatbot is Indonesian.
An example of a chatbot conversation is shown in Fig-
ure 8.
Figure 8: Interaction between user and DiabeticFoodBot on
telegram.
3.3 DiabeticFoodBot Testing
There are two steps to the testing process, that is test-
ing during training and system testing. Testing dur-
ICAISD 2023 - International Conference on Advanced Information Scientific Development
318
ing the training process is carried out by testing the
phrases on the system and checking the response sys-
tem. If the answer is incorrect, then additional train-
ing testing is required. After the system development
is complete, system testing is carried out. Simulation
by trying to provide input in the form of user infor-
mation, for example by looking at whether the BMI
results are true or false based on user information. If
the testing system is appropriate, the researcher con-
tinues to enter the final stage, that is testing the results
of recommendations to nutritionists.
4 EXPERIMENT
The testing process of the recommendations by Dia-
beticFoodBot involves nutritionists. The nutritionist
validates the food list from the results of our recom-
mender system in Spreadsheet. Nutritionist validation
results are used to obtain true positive, false positive,
and false negative values. Based on these values, F-
Score, precision, and recall calculations can be per-
formed to see the accuracy of the recommended re-
sults.
Sample user data for the validation process were
obtained from diabetics who filled out a Google form
with a minimum age limit of 12 years. The num-
ber of sample user data obtained is 60 samples, but
three sample cannot be included because the user is
a diabetic with complications. Therefore, the total
samples used for validation were 57 user samples and
produced 285 samples of food recommendations and
mineral water intake. Of the 285 food samples and
mineral water intake approved by nutritionists, there
were 31 food samples that were inappropriate.
Precision =
T P
T P + FP
=
285
285 + 31
= 0.901 (7)
Recall =
T P
T P + FN
=
285
285 + 0
= 1 (8)
Recall is the ability of the system to retrieve the
appropriate document, while precision is used to mea-
sure the effectiveness of a system to find information.
If the recall and precision values are close to 1 then
the results are good.
Precision and Recall are used to obtain the F-
Score, which is the average value of precision and
recall. This value can be obtained by the following
equation:
F Score = 2x
PrecisionxRecall
Precision + Recall
=
2x
0.901x1
0.901 + 1
= 94.7%
(9)
Table 4: Information of confusion matrix.
Information
TP (True
Positive)
The total results of food rec-
ommendations that are in ac-
cordance with the recommenda-
tions of nutritionists
FP (False
Positive)
The total results of food rec-
ommendations that are recom-
mended by the system but not
recommended by nutritionists
FN (False
Nega-
tives)
The results of food recommen-
dations that are not recom-
mended by the system and not
recommended by nutritionists
F-1 Score illustrates the comparison of the average
precision and recall listed. The level of accuracy is
shown from the F-1 Score presentation which is close
to 100%.
5 CONCLUSIONS
DiabeticFoodBot is a chatbot that recommends food
menus and mineral water intake for diabetics without
complications. Based on the validation that has been
carried out, the results obtained that the accuracy level
of this chatbot is 94,7 percent so that this chatbot is
able to provide food and mineral water recommen-
dations according to the user’s nutritional needs and
can be used as a solution to assist users in implement-
ing good eating and drinking patterns for sufferer di-
abetes.
The limitation of this research is the limit on the
server and database which hinders the speed perfor-
mance in displaying output results to users. In ad-
dition, researchers have also not assessed user opin-
ions regarding the displayed chatbot features. This
chatbot also cannot be used for diabetics who have
certain complications because diabetics with compli-
cations have different food and mineral water intake
rules, depending on the type of complications they are
suffering from.
REFERENCES
Arjun, A. R. and Baizal, Z. (2022). Chatbot-based movie
recommender system with latent semantic analysis on
telegram platform using dialog flow. Journal of Com-
puter System and Informatic, 3(4).
Arwan, A., Sidiq, M., Priyambadha, B., Kristianto, H., and
Sarno, R. (2013). Ontology and semantic matching for
diabetic food recommendations. Int. Conf. ICITEE,
pages 170–175,.
DiabeticFoodBot: Food and Water Intake Recommender System for Diabetics
319
Baizal, Z., Widyantoro, D., and Maulidevi, N. (2020). Com-
putational model for generating interactions in conver-
sational recommender system based on product func-
tional requirements. Elsevier Vol.128.
Cahn, J. (2017). CHATBOT : Architecture, Design, De-
velopment. Thesis University of Pennsylvania School
of Engineering and Applied Science Department of
Computer and Information Science, Apr.
Editor (2019). Bmr calculator.
https://www.diabetes.co.uk/bmr-calculator.html,
Accessed Apr 28, 2022.
Farman Ali, S. I., Kwak, D., Khan, P., Ullah, N., and Sang-
jo Yoo, K. (2017). Type-2 fuzzy ontology-aided rec-
ommender systems for iot-based healthcare. Elsevier,
pages 138–155,. .
F.D.A. (2020). Daily Value and Percent Daily Value :
Changes on the New Nutrition and Supplement Facts
Labels. Department of Health Human Services USA.
Gunardi, A. J. (2022). Must know, water needs can be
seen from body size, you know! Online Website,
page – – – – – –. .https://www.klikdokter.com/info-
sehat/kesehatan-umum/wajib-tahu, accessed April 20,
2022.
Hardianto, D. (2020). A comprehensive review of diabetes
mellitus: Classification, symptoms, diagnosis, preven-
tion, and treatment,”indonesian. Journal of Biology
Biosciences (JBBI, pages 304–317,.
Harris, J. and Benedict, F. G. (1918). A biometric study
of human basal metabolism. Biological Sciences,
4(12):370–373,.
Indonesia, K. K. R. (2018). Klasifikasi obesitas setelah pen-
gukuran imt. Accessed Apr 28, 2022).
Jahidin, A. (2019). Therapeutic effect of drinking water on
reducing blood sugar levels (gds) in type ii diabetes
mellitus patients”. Journal of Health. Generation De-
velopment, 11(1):87,.
Lim, J., Chan, M. M., Alsagoff, F. Z., and Ha, D. (2011).
Innovations in Non-communicable Disease Manage-
ment in ASEAN : A Case Series. Taylor Francis On-
line.
Mawartika, Y. E. B. and Guntur, M. (2021). Application
expert system for food selection based on nutritional
needs using forward chaining. Cogito Smart Journal
Vol.7, (1):96–110,.
Mckensy-Sambola, D., Garcia-Sanchez, M. A. R.-G. F.,
and Valencia-Garcia, R. (2021). Ontology-based
nutritional recommender system. Appl. Sci Vol.12,
(1):143,.
Ministry, M. O. H. o. t. R. o. I. (2013). Di-
abetes mellitus is the number 6 cause
of death in the world. Online Website.
https://www.kemkes.go.id/article/view/2383/diabetes-
melitus-pembebab-kematian-nomor-6-di-dunia-
kemenkes-tawarkan-solusi-cerdik-melalui-
posbindu.html, Accessed March 26, 2022.
Nurani, S., Baizal, Z., and Ikhsan, N. (2022). Sellybot :
Conversational recommender system based on func-
tional requirements. In 2022 International Conference
on Data Science and Its Applications (ICoDSA, pages
315–319,. IEEE.
Office, W. K. P. H. (2022). Diabetes causes the
highest mortality in indonesia, overcome it
quickly before it’s too late. Online Website.
https://dinkes.kalbarprov.go.id/diabetes-sebabkan-
kematian-tertinggi-di-indonesia-atas secepatnya-
before-late/.(accessed December 20, 2022.
Rachman, D. D. and Nurjannah, D. (2019). Ontology
model-based recommender system in providing food
diet recommendations for diabetics. Telkom Univer-
sity e-Proceeding of Engineering, 6(2):9569,.
Rahman, A. Z., Soesanto, I., and Wahyunggoro, O. (2018).
Review on the food recommender system for diabetes
mellitus. IEEE. int. Conf. ISRITI, pages 627–632,.
Sihombing, M. (2017). Factors associated with hyper-
tension among diabetes mellitus people of indonesia
(basic health research 2013,”indonesian. Bulletin of
Health Research, 45(1):53–64,.
Simatupang, R. (2020). Dietary guidelines for people with
diabetes mellitus.
Thongyoo, P., Anantapanya, P., Jamsri, P., and Chotipant,
S. (2020). A useralized food recommendation chatbot
system for diabetes patients. Int. Conf. on Cooperative
Design, Visualization and Engineering, pages 19–28,.
Weir, R., Timms, G. P., Smith, K. A., Koury, R., and Pan, D.
(2010). Innovative Practices in Electronic Resources
and Acquisition Management. Purdue University.
W.H.O. (2022). Diabetes. https://www.who.int/news-
room/fact-sheets/detail/diabetes, accessed December
20, 2022.
ICAISD 2023 - International Conference on Advanced Information Scientific Development
320