myavana-bot-test-core 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/utils.js CHANGED
@@ -50,10 +50,6 @@ async function getAdditionalInstructions() { // New function to get ALL Bot Inst
50
50
  return [];
51
51
  }
52
52
  }
53
- async function getHairIssuesForUser(userId){
54
- //return empty for now
55
- return []
56
- }
57
53
  async function getProductByName(productName) {
58
54
  try {
59
55
  const result = await pgClient.query('SELECT product_id FROM products WHERE product_name = $1', [productName]);
@@ -81,13 +77,39 @@ async function addProductRecommendation(userId, conversationId, productId, reaso
81
77
  }
82
78
  }
83
79
 
80
+
81
+ async function getTrainingData(limit = 50) {
82
+ try {
83
+ const result = await pgClient.query(
84
+ 'SELECT title, source_type, extracted_text, created_at FROM training_data ORDER BY created_at DESC LIMIT $1',
85
+ [limit]
86
+ );
87
+ return result.rows;
88
+ } catch (error) {
89
+ console.error("Error fetching training data:", error);
90
+ return [];
91
+ }
92
+ }
93
+
94
+ async function getChatbotWelcomeSettings() {
95
+ try {
96
+ const result = await pgClient.query(
97
+ 'SELECT welcome_text, image_urls, flow_data FROM chatbot_welcome_settings WHERE is_active = TRUE ORDER BY created_at DESC LIMIT 1'
98
+ );
99
+ return result.rows[0] || null;
100
+ } catch (error) {
101
+ console.error("Error fetching chatbot welcome settings:", error);
102
+ return null;
103
+ }
104
+ }
84
105
  module.exports = {
85
106
  getAllProducts,
86
107
  getAllFaqs,
87
108
  getAllYoutubeVideos,
88
109
  getAllTestimonials,
89
110
  getAdditionalInstructions,
90
- getHairIssuesForUser,
111
+ getTrainingData,
112
+ getChatbotWelcomeSettings,
91
113
  getProductByName,
92
114
  addProductRecommendation
93
115
  };