HANA: An AI Chatbot for Islamic Jurisprudence on Menstruation using SBERT and TF-IDF
DOI:
https://doi.org/10.30871/jaic.v9i3.9449Keywords:
Chatbot, Fiqh Haid, Sentence-BERT, TF-IDF, Telegram BotAbstract
The advancement of Artificial Intelligence (AI), particularly in Natural Language Processing (NLP), has opened new opportunities for religious technological innovation, especially in addressing practical Islamic jurisprudence issues such as menstruation (fiqh haid). This research proposes and implements HANA, an AI chatbot developed for Telegram, utilizing a hybrid approach combining Term Frequency-Inverse Document Frequency (TF-IDF) and Sentence-BERT (SBERT) models. A curated dataset of over 1000 question-answer pairs from classical and contemporary Islamic literature was used, primarily based on the Shafi'i school of thought. The chatbot matches user queries through a two-stage retrieval: initial keyword matching via TF-IDF and deeper semantic matching via SBERT embeddings. Evaluations were conducted by comparing TF-IDF, SBERT, and hybrid approaches using cosine similarity, precision, recall, and F1-score metrics, focused on top-1 retrieval accuracy. HANA achieved an average cosine similarity score of 0.6581 and a semantic relevance rating of 87% based on expert validation, while User Acceptance Testing (UAT) involving 15 respondents indicated 86.7% satisfaction. Although the system is deployed as a proof-of-concept on Google Colab without persistent hosting, it demonstrates the viability of lightweight AI chatbots for Shariah consultation services. Future improvements include multi-turn conversation handling and integration with large language models for better context understanding. This research contributes to expanding NLP applications within techno-dakwah initiatives, providing a scalable approach to enhance women's access to Islamic jurisprudence knowledge.
Downloads
References
[1] M. F. N. Zamri, ’Ainul Mardhiah Zabidi, N. Siamil, and Z. Hussin, “Penerokaan Kaedah Fiqh dalam Perbahasan Fiqh Darah Haid: Kajian Terhadap Buku al-Ibanah wa al-Ifadhah fi Ahkam al-Haid wa al-Nifas wa al-Istihadhah ‘Ala Mazhab al-Imam al-Syafi’i,” J. Muwafaqat, vol. 5, no. 1, pp. 71–87, Apr. 2022, doi: 10.53840/muwafaqat.v5i1.108.
[2] Elvina Afriani, N. S. H, M. Fikry, and M. Affandes, “Aplikasi Tanya Jawab Tentang Fiqih Bersuci Berbasis Web,” Zo. J. Sist. Inf., vol. 6, no. 2, pp. 380–390, 2024, doi: 10.31849/zn.v6i2.19970.
[3] rahayu deny danar dan alvi furwanti Alwie, A. B. Prasetio, R. Andespa, P. N. Lhokseumawe, and K. Pengantar, “Tugas Akhir Tugas Akhir,” J. Ekon. Vol. 18, Nomor 1 Maret201, vol. 2, no. 1, pp. 41–49, 2020.
[4] M. D. Qoyyimah and S. Sulaikho, “Integration of AI and Ṭahārah from Fatḥ Al-Qarīb as a New Strategy for Strengthening Fiqh Studies in Islamic Boarding Schools,” YASIN, vol. 5, no. 1, pp. 587–597, Feb. 2025, doi: 10.58578/yasin.v5i1.4943.
[5] T. L. M. Suryanto, A. P. Wibawa, H. Hariyono, and A. Nafalski, “Evolving Conversations: A Review of Chatbots and Implications in Natural Language Processing for Cultural Heritage Ecosystems,” Int. J. Robot. Control Syst., vol. 3, no. 4, pp. 955–1006, Dec. 2023, doi: 10.31763/ijrcs.v3i4.1195.
[6] R. Hayati, R. Buaton, and S. Ramadani, “Implementation of Chatbot Artificial Intelligence in a Company Website to Improve Customer Service Automatically Using the TF-IDF Method,” J. Artif. Intell. Eng. Appl., vol. 4, no. 1, pp. 131–136, Oct. 2024, doi: 10.59934/jaiea.v4i1.584.
[7] A. P. Ingemarsson, “Engineering Degree Project PDF Parsing , Unveiling the Most Efficient Method,” 2024.
[8] M. Qalimaturrahmah and D. B. Santoso, “Aplikasi Layanan dan Informasi Akademik Berbasis Chatbot Telegram Menggunakan Natural Language Processing,” J. JTIK (Jurnal Teknol. Inf. dan Komunikasi), vol. 8, no. 2, pp. 434–443, Apr. 2024, doi: 10.35870/jtik.v8i2.1887.
[9] K. Adib, M. R. Handayani, W. D. Yuniarti, and K. Umam, “Opini Publik Pasca-Pemilihan Presiden: Eksplorasi Analisis Sentimen Media Sosial X Menggunakan SVM,” SINTECH (Science Inf. Technol. J., vol. 7, no. 2, pp. 80–91, Aug. 2024, doi: 10.31598/sintechjournal.v7i2.1581.
[10] R. Saputra and M. Galih Pradana, “Implementasi Algoritma Cosine Similarity dan TF-IDF dalam Menentukan Rumpun Jabatan,” vol. 12, no. 1, pp. 1–11, 2024, doi: 10.32832/kreatif.v12i1.15470.
[11] Nuzul Hikmah, Dyah Ariyanti, and Ferry Agus Pratama, “Implementasi Chatbot Sebagai Virtual Assistant di Universitas Panca Marga Probolinggo menggunakan Metode TF-IDF,” JTIM J. Teknol. Inf. dan Multimed., vol. 4, no. 2, pp. 133–148, Aug. 2022, doi: 10.35746/jtim.v4i2.225.
[12] Y. Ortakci, “Revolutionary text clustering: Investigating transfer learning capacity of SBERT models through pooling techniques,” Eng. Sci. Technol. an Int. J., vol. 55, p. 101730, Jul. 2024, doi: 10.1016/J.JESTCH.2024.101730.
[13] G. Yunanda, D. Nurjanah, and S. Meliana, “Recommendation System from Microsoft News Data using TF-IDF and Cosine Similarity Methods,” Build. Informatics, Technol. Sci., vol. 4, no. 1, Jun. 2022, doi: 10.47065/bits.v4i1.1670.
[14] A. Babu and S. B. Boddu, “BERT-Based Medical Chatbot: Enhancing Healthcare Communication through Natural Language Understanding,” Explor. Res. Clin. Soc. Pharm., vol. 13, p. 100419, Mar. 2024, doi: 10.1016/J.RCSOP.2024.100419.
[15] B. Devlin and R. Liu, “Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks,” 2014.
[16] G. F. Avisyah, I. J. Putra, and S. S. Hidayat, “Open Artificial Intelligence Analysis using ChatGPT Integrated with Telegram Bot,” J. ELTIKOM, vol. 7, no. 1, pp. 60–66, Jun. 2023, doi: 10.31961/eltikom.v7i1.724.
[17] H. Steck, C. Ekanadham, and N. Kallus, “Is Cosine-Similarity of Embeddings Really About Similarity?,” in Companion Proceedings of the ACM Web Conference 2024, New York, NY, USA: ACM, May 2024, pp. 887–890. doi: 10.1145/3589335.3651526.
[18] I. Afdhal, R. Kurniawan, I. Iskandar, R. Salambue, E. Budianita, and F. Syafria, “Penerapan Algoritma Random Forest Untuk Analisis Sentimen Komentar Di YouTube Tentang Islamofobia,” J. Nas. Komputasi dan Teknol. Inf., vol. 5, no. 1, pp. 122–130, 2022, [Online]. Available: http://ojs.serambimekkah.ac.id/jnkti/article/view/4004/pdf
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2025 Tsaura Rafah Masuzzahra, Khothibul Umam, Hery Mustofa, Maya Rini Handayani

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Authors who publish with this journal agree to the following terms:
- Authors retain copyright and grant the journal right of first publication with the work simultaneously licensed under a Creative Commons Attribution License (Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) ) that allows others to share the work with an acknowledgement of the work's authorship and initial publication in this journal.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgement of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See The Effect of Open Access).








