@xuda.io/ai_module 1.1.4647 → 1.1.4648
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/index.mjs +96 -213
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4220,14 +4220,28 @@ export const create_conversation = async function (req, job_id, headers) {
|
|
|
4220
4220
|
|
|
4221
4221
|
let category_info = {};
|
|
4222
4222
|
switch (conversation_type) {
|
|
4223
|
-
case '
|
|
4223
|
+
case 'ai': {
|
|
4224
|
+
category_info = await categorize_ai_prompt(uid, prompt, account_profile_info);
|
|
4225
|
+
break;
|
|
4226
|
+
}
|
|
4227
|
+
|
|
4228
|
+
case 'email': {
|
|
4224
4229
|
category_info = await categorize_email_subject(uid, prompt, account_profile_info);
|
|
4225
4230
|
break;
|
|
4226
4231
|
}
|
|
4227
4232
|
|
|
4233
|
+
case 'chat': {
|
|
4234
|
+
category_info = await categorize_text_message(uid, prompt, account_profile_info);
|
|
4235
|
+
break;
|
|
4236
|
+
}
|
|
4237
|
+
|
|
4228
4238
|
default:
|
|
4229
4239
|
break;
|
|
4230
4240
|
}
|
|
4241
|
+
|
|
4242
|
+
conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
|
|
4243
|
+
await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
4244
|
+
|
|
4231
4245
|
if (perform_ai_execution) {
|
|
4232
4246
|
// await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
|
|
4233
4247
|
}
|
|
@@ -7760,8 +7774,7 @@ function getDomainFromCategory(category) {
|
|
|
7760
7774
|
}
|
|
7761
7775
|
return 'General';
|
|
7762
7776
|
}
|
|
7763
|
-
|
|
7764
|
-
export const categorize_text_message = async function (uid, message_text, contact_info, metadata = {}) {
|
|
7777
|
+
export const categorize_text_message = async function (uid, text_message, account_profile_info) {
|
|
7765
7778
|
const text_message_categories = [
|
|
7766
7779
|
// Personal Communication (1-20)
|
|
7767
7780
|
'Casual Conversation',
|
|
@@ -7784,7 +7797,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7784
7797
|
'Forgiveness Request',
|
|
7785
7798
|
'Miss You Message',
|
|
7786
7799
|
'Thinking of You',
|
|
7787
|
-
|
|
7800
|
+
|
|
7788
7801
|
// Practical & Logistics (21-40)
|
|
7789
7802
|
'Meeting Coordination',
|
|
7790
7803
|
'Plans Making',
|
|
@@ -7806,7 +7819,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7806
7819
|
'Follow-up Request',
|
|
7807
7820
|
'Confirmation Needed',
|
|
7808
7821
|
'Status Update',
|
|
7809
|
-
|
|
7822
|
+
|
|
7810
7823
|
// Information Exchange (41-60)
|
|
7811
7824
|
'Question Asking',
|
|
7812
7825
|
'Information Request',
|
|
@@ -7828,7 +7841,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7828
7841
|
'Book/Movie Recommendation',
|
|
7829
7842
|
'Music Recommendation',
|
|
7830
7843
|
'Restaurant Suggestion',
|
|
7831
|
-
|
|
7844
|
+
|
|
7832
7845
|
// Work & Business (61-75)
|
|
7833
7846
|
'Work Discussion',
|
|
7834
7847
|
'Project Update',
|
|
@@ -7845,7 +7858,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7845
7858
|
'Partnership Discussion',
|
|
7846
7859
|
'Contract Details',
|
|
7847
7860
|
'Payment Discussion',
|
|
7848
|
-
|
|
7861
|
+
|
|
7849
7862
|
// Urgent & Emergency (76-85)
|
|
7850
7863
|
'Emergency Alert',
|
|
7851
7864
|
'Help Request',
|
|
@@ -7857,7 +7870,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7857
7870
|
'Security Concern',
|
|
7858
7871
|
'Immediate Response Needed',
|
|
7859
7872
|
'Critical Update',
|
|
7860
|
-
|
|
7873
|
+
|
|
7861
7874
|
// Social & Invitations (86-95)
|
|
7862
7875
|
'Event Invitation',
|
|
7863
7876
|
'Party Invite',
|
|
@@ -7869,7 +7882,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7869
7882
|
'Hangout Request',
|
|
7870
7883
|
'Social Media Tag',
|
|
7871
7884
|
'Group Chat Add',
|
|
7872
|
-
|
|
7885
|
+
|
|
7873
7886
|
// Shopping & Commerce (96-105)
|
|
7874
7887
|
'Purchase Inquiry',
|
|
7875
7888
|
'Product Question',
|
|
@@ -7881,7 +7894,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7881
7894
|
'Payment Request',
|
|
7882
7895
|
'Bill Splitting',
|
|
7883
7896
|
'Money Transfer',
|
|
7884
|
-
|
|
7897
|
+
|
|
7885
7898
|
// Health & Wellness (106-115)
|
|
7886
7899
|
'Health Update',
|
|
7887
7900
|
'Doctor Appointment',
|
|
@@ -7893,7 +7906,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7893
7906
|
'Self-care Reminder',
|
|
7894
7907
|
'Recovery Update',
|
|
7895
7908
|
'Health Advice',
|
|
7896
|
-
|
|
7909
|
+
|
|
7897
7910
|
// Household & Family (116-125)
|
|
7898
7911
|
'Family Planning',
|
|
7899
7912
|
'Childcare Coordination',
|
|
@@ -7905,7 +7918,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7905
7918
|
'Property Discussion',
|
|
7906
7919
|
'Neighbor Communication',
|
|
7907
7920
|
'Community Update',
|
|
7908
|
-
|
|
7921
|
+
|
|
7909
7922
|
// Education & Learning (126-135)
|
|
7910
7923
|
'Homework Help',
|
|
7911
7924
|
'Study Group',
|
|
@@ -7917,7 +7930,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7917
7930
|
'Educational Resource',
|
|
7918
7931
|
'Learning Progress',
|
|
7919
7932
|
'Academic Achievement',
|
|
7920
|
-
|
|
7933
|
+
|
|
7921
7934
|
// Entertainment & Leisure (136-145)
|
|
7922
7935
|
'Game Invitation',
|
|
7923
7936
|
'Streaming Watch Party',
|
|
@@ -7929,7 +7942,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7929
7942
|
'Adventure Plan',
|
|
7930
7943
|
'Outdoor Activity',
|
|
7931
7944
|
'Cultural Event',
|
|
7932
|
-
|
|
7945
|
+
|
|
7933
7946
|
// Technology & Digital (146-155)
|
|
7934
7947
|
'Tech Support',
|
|
7935
7948
|
'App Recommendation',
|
|
@@ -7941,21 +7954,21 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7941
7954
|
'Social Media Tagging',
|
|
7942
7955
|
'Online Purchase',
|
|
7943
7956
|
'Digital Content Share',
|
|
7944
|
-
|
|
7957
|
+
|
|
7945
7958
|
// Legal & Official (156-160)
|
|
7946
7959
|
'Legal Advice',
|
|
7947
7960
|
'Document Request',
|
|
7948
7961
|
'Official Notification',
|
|
7949
7962
|
'Government Matter',
|
|
7950
7963
|
'Compliance Issue',
|
|
7951
|
-
|
|
7964
|
+
|
|
7952
7965
|
// Spiritual & Religious (161-165)
|
|
7953
7966
|
'Prayer Request',
|
|
7954
7967
|
'Religious Event',
|
|
7955
7968
|
'Spiritual Guidance',
|
|
7956
7969
|
'Meditation Group',
|
|
7957
7970
|
'Faith Discussion',
|
|
7958
|
-
|
|
7971
|
+
|
|
7959
7972
|
// Miscellaneous (166-175)
|
|
7960
7973
|
'Random Thought',
|
|
7961
7974
|
'Philosophical Question',
|
|
@@ -7967,7 +7980,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7967
7980
|
'Goal Setting',
|
|
7968
7981
|
'Life Update',
|
|
7969
7982
|
'General Chat',
|
|
7970
|
-
|
|
7983
|
+
|
|
7971
7984
|
// Signal & Meta Communication (176-185)
|
|
7972
7985
|
'Read Receipt',
|
|
7973
7986
|
'Typing Indicator',
|
|
@@ -7979,7 +7992,7 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7979
7992
|
'Network Issue',
|
|
7980
7993
|
'Delivery Failure',
|
|
7981
7994
|
'Message Forward',
|
|
7982
|
-
|
|
7995
|
+
|
|
7983
7996
|
// Relationship Dynamics (186-195)
|
|
7984
7997
|
'Conflict Resolution',
|
|
7985
7998
|
'Relationship Discussion',
|
|
@@ -7991,45 +8004,31 @@ export const categorize_text_message = async function (uid, message_text, contac
|
|
|
7991
8004
|
'Meeting Planning',
|
|
7992
8005
|
'Relationship Milestone',
|
|
7993
8006
|
'Breakup Discussion',
|
|
7994
|
-
|
|
8007
|
+
|
|
7995
8008
|
// Quick & Brief (196-200)
|
|
7996
8009
|
'One-word Response',
|
|
7997
8010
|
'Emoji Message',
|
|
7998
8011
|
'Sticker/GIF Send',
|
|
7999
8012
|
'Quick Reply',
|
|
8000
|
-
'Acknowledgment Only'
|
|
8001
|
-
];
|
|
8002
|
-
const prompt = `Categorize the text message into one of these exact categories:
|
|
8003
|
-
|
|
8004
|
-
Text Message: "${message_text.substring(0, 300)}${message_text.length > 300 ? '...' : ''}"
|
|
8013
|
+
'Acknowledgment Only'
|
|
8014
|
+
] as const;
|
|
8005
8015
|
|
|
8006
|
-
|
|
8007
|
-
- Relationship: ${contact_info?.relationship || 'Unknown'}
|
|
8008
|
-
- Frequency: ${metadata?.message_frequency || 'Unknown'}
|
|
8009
|
-
- Time of Day: ${new Date().getHours()}h
|
|
8010
|
-
- Previous Context: ${metadata?.previous_topic || 'Not provided'}
|
|
8016
|
+
const prompt = `Categorize this text message into one of the 200 message categories based only on the message content.
|
|
8011
8017
|
|
|
8012
|
-
|
|
8013
|
-
${text_message_categories
|
|
8014
|
-
.slice(0, 25)
|
|
8015
|
-
.map((cat, index) => `${index + 1}. ${cat}`)
|
|
8016
|
-
.join('\n')}
|
|
8017
|
-
[Full list of 200 categories available to the system]
|
|
8018
|
+
Text Message: "${text_message}"
|
|
8018
8019
|
|
|
8019
|
-
|
|
8020
|
-
1. Analyze the message content
|
|
8021
|
-
2.
|
|
8022
|
-
3.
|
|
8023
|
-
4.
|
|
8024
|
-
5.
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
7. If unsure, consider the most common interpretation
|
|
8032
|
-
8. For ambiguous messages, choose based on typical usage patterns
|
|
8020
|
+
INSTRUCTIONS:
|
|
8021
|
+
1. Analyze ONLY the message content - no external context
|
|
8022
|
+
2. Choose ONE category that best fits the message's primary intent
|
|
8023
|
+
3. Consider: What is the sender trying to achieve?
|
|
8024
|
+
4. Return the exact category name from the list
|
|
8025
|
+
5. If truly ambiguous, choose "General Chat"
|
|
8026
|
+
|
|
8027
|
+
Think step by step:
|
|
8028
|
+
1. What is the main purpose of this message?
|
|
8029
|
+
2. Is it informational, social, practical, emotional, or urgent?
|
|
8030
|
+
3. What action or response is expected?
|
|
8031
|
+
4. What is the tone and style?
|
|
8033
8032
|
|
|
8034
8033
|
Category:`;
|
|
8035
8034
|
|
|
@@ -8037,75 +8036,74 @@ Category:`;
|
|
|
8037
8036
|
const message_category_ret = await submit_chat_gpt_prompt({
|
|
8038
8037
|
uid,
|
|
8039
8038
|
prompt: prompt,
|
|
8040
|
-
model: 'gpt-4o-mini',
|
|
8039
|
+
model: 'gpt-4o-mini',
|
|
8041
8040
|
response_format: z.object({
|
|
8042
8041
|
message_category: z.enum(text_message_categories),
|
|
8043
8042
|
confidence_score: z.number().min(0).max(100),
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
relationship_dynamics: z.string().max(100).optional(),
|
|
8043
|
+
primary_intent: z.string(),
|
|
8044
|
+
emotional_tone: z.enum(['Positive', 'Neutral', 'Negative', 'Urgent', 'Playful', 'Formal', 'Casual', 'Mixed']),
|
|
8045
|
+
urgency_level: z.enum(['None', 'Low', 'Medium', 'High', 'Emergency']),
|
|
8048
8046
|
}),
|
|
8049
|
-
metadata: {
|
|
8050
|
-
func: 'categorize_text_message',
|
|
8051
|
-
message_length:
|
|
8052
|
-
|
|
8053
|
-
contact_relationship: contact_info?.relationship,
|
|
8054
|
-
time_sent: new Date().toISOString(),
|
|
8055
|
-
platform: metadata?.platform || 'Unknown',
|
|
8056
|
-
is_group_chat: metadata?.is_group_chat || false,
|
|
8047
|
+
metadata: {
|
|
8048
|
+
func: 'categorize_text_message',
|
|
8049
|
+
message_length: text_message.length,
|
|
8050
|
+
timestamp: new Date().toISOString()
|
|
8057
8051
|
},
|
|
8058
|
-
account_profile_info,
|
|
8052
|
+
account_profile_info, // Still passed to submit_chat_gpt_prompt but not used for context
|
|
8059
8053
|
});
|
|
8060
8054
|
|
|
8061
8055
|
if (message_category_ret && message_category_ret.code > -1) {
|
|
8062
|
-
const data = typeof message_category_ret.data === 'string'
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8056
|
+
const data = typeof message_category_ret.data === 'string'
|
|
8057
|
+
? JSON.parse(message_category_ret.data)
|
|
8058
|
+
: message_category_ret.data;
|
|
8059
|
+
|
|
8060
|
+
// Simple local analysis
|
|
8061
|
+
const message_analysis = {
|
|
8062
|
+
word_count: text_message.split(/\s+/).filter(w => w.length > 0).length,
|
|
8063
|
+
char_count: text_message.length,
|
|
8064
|
+
has_question: /[?]|(can you|could you|would you|how|what|when|where|why|who)/i.test(text_message),
|
|
8065
|
+
has_request: /(please|can you|could you|would you|help|need|want)/i.test(text_message),
|
|
8066
|
+
has_urgency: /(urgent|asap|emergency|immediately|now|quick)/i.test(text_message),
|
|
8067
|
+
};
|
|
8066
8068
|
|
|
8067
|
-
// Determine priority
|
|
8068
|
-
|
|
8069
|
+
// Determine priority based on urgency and category
|
|
8070
|
+
let priority = 3;
|
|
8071
|
+
if (data.urgency_level === 'Emergency' || data.message_category.includes('Emergency')) priority = 1;
|
|
8072
|
+
else if (data.urgency_level === 'High') priority = 2;
|
|
8073
|
+
else if (data.urgency_level === 'Low') priority = 4;
|
|
8074
|
+
else if (data.message_category.includes('Casual') || data.message_category.includes('General')) priority = 5;
|
|
8069
8075
|
|
|
8070
8076
|
return {
|
|
8071
8077
|
success: true,
|
|
8072
8078
|
category: data.message_category,
|
|
8073
8079
|
confidence: data.confidence_score,
|
|
8080
|
+
primary_intent: data.primary_intent,
|
|
8074
8081
|
emotional_tone: data.emotional_tone,
|
|
8075
8082
|
urgency: data.urgency_level,
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
// Analysis results
|
|
8083
|
+
priority: priority,
|
|
8084
|
+
|
|
8085
|
+
// Basic message analysis
|
|
8081
8086
|
word_count: message_analysis.word_count,
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
// Context
|
|
8087
|
-
relationship: contact_info?.relationship || 'Unknown',
|
|
8088
|
-
typical_response_time: estimateResponseTime(data.message_category, contact_info?.relationship),
|
|
8089
|
-
|
|
8087
|
+
char_count: message_analysis.char_count,
|
|
8088
|
+
has_question: message_analysis.has_question,
|
|
8089
|
+
has_request: message_analysis.has_request,
|
|
8090
|
+
|
|
8090
8091
|
// Metadata
|
|
8091
|
-
message_preview: message_text.substring(0, 150),
|
|
8092
8092
|
timestamp: new Date().toISOString(),
|
|
8093
|
-
|
|
8094
|
-
// Suggestions
|
|
8095
|
-
auto_reply_suggestion: generateAutoReplySuggestion(data.message_category, data.emotional_tone),
|
|
8096
|
-
follow_up_reminder: shouldScheduleFollowUp(data.message_category, data.urgency_level),
|
|
8093
|
+
message_preview: text_message.substring(0, 100) + (text_message.length > 100 ? '...' : ''),
|
|
8097
8094
|
};
|
|
8098
8095
|
} else {
|
|
8099
8096
|
return {
|
|
8100
8097
|
success: false,
|
|
8101
8098
|
category: 'General Chat',
|
|
8102
8099
|
confidence: 0,
|
|
8100
|
+
primary_intent: 'Unknown',
|
|
8103
8101
|
emotional_tone: 'Neutral',
|
|
8104
|
-
urgency: '
|
|
8105
|
-
priority:
|
|
8106
|
-
message_preview:
|
|
8102
|
+
urgency: 'None',
|
|
8103
|
+
priority: 5,
|
|
8104
|
+
message_preview: text_message.substring(0, 100),
|
|
8107
8105
|
error: message_category_ret?.message || 'API call failed',
|
|
8108
|
-
timestamp: new Date().toISOString()
|
|
8106
|
+
timestamp: new Date().toISOString()
|
|
8109
8107
|
};
|
|
8110
8108
|
}
|
|
8111
8109
|
} catch (error) {
|
|
@@ -8114,128 +8112,13 @@ Category:`;
|
|
|
8114
8112
|
success: false,
|
|
8115
8113
|
category: 'General Chat',
|
|
8116
8114
|
confidence: 0,
|
|
8115
|
+
primary_intent: 'Error',
|
|
8117
8116
|
emotional_tone: 'Neutral',
|
|
8118
|
-
urgency: '
|
|
8119
|
-
priority:
|
|
8120
|
-
message_preview:
|
|
8117
|
+
urgency: 'None',
|
|
8118
|
+
priority: 5,
|
|
8119
|
+
message_preview: text_message.substring(0, 100),
|
|
8121
8120
|
error: error.message,
|
|
8122
|
-
timestamp: new Date().toISOString()
|
|
8121
|
+
timestamp: new Date().toISOString()
|
|
8123
8122
|
};
|
|
8124
8123
|
}
|
|
8125
|
-
};
|
|
8126
|
-
|
|
8127
|
-
// Helper functions
|
|
8128
|
-
function analyzeMessageCharacteristics(message, category) {
|
|
8129
|
-
const wordCount = message.split(/\s+/).length;
|
|
8130
|
-
const charCount = message.length;
|
|
8131
|
-
const containsQuestions = /[\?]|(can you|could you|would you|will you|do you|are you|is there|how|what|when|where|why|who)/i.test(message);
|
|
8132
|
-
const containsRequests = /(please|can you|could you|would you|need you|want you|help me|assist)/i.test(message);
|
|
8133
|
-
const containsUrgency = /(urgent|asap|immediately|right now|emergency|quick|fast|hurry)/i.test(message);
|
|
8134
|
-
const containsTimeReferences = /\b(today|tomorrow|now|soon|later|tonight|morning|afternoon|evening)\b/i.test(message);
|
|
8135
|
-
const containsEmoticons = /[:;][\-]?[\)\(DP]|<\/?3|\([^\)]*\)|[\u{1F600}-\u{1F64F}]/gu.test(message);
|
|
8136
|
-
|
|
8137
|
-
return {
|
|
8138
|
-
word_count: wordCount,
|
|
8139
|
-
char_count: charCount,
|
|
8140
|
-
contains_questions: containsQuestions,
|
|
8141
|
-
contains_requests: containsRequests,
|
|
8142
|
-
time_sensitive: containsTimeReferences || containsUrgency,
|
|
8143
|
-
has_emoticons: containsEmoticons,
|
|
8144
|
-
message_type: charCount < 50 ? 'Short' : charCount < 200 ? 'Medium' : 'Long',
|
|
8145
|
-
};
|
|
8146
|
-
}
|
|
8147
|
-
|
|
8148
|
-
function calculateMessagePriority(urgency, category, relationship) {
|
|
8149
|
-
let priority = 3; // Default medium priority
|
|
8150
|
-
|
|
8151
|
-
// Emergency categories get highest priority
|
|
8152
|
-
if (urgency === 'Emergency' || category.includes('Emergency')) {
|
|
8153
|
-
return 1;
|
|
8154
|
-
}
|
|
8155
|
-
|
|
8156
|
-
// High urgency
|
|
8157
|
-
if (urgency === 'High' || category.includes('Urgent')) {
|
|
8158
|
-
priority = 2;
|
|
8159
|
-
}
|
|
8160
|
-
|
|
8161
|
-
// Low urgency or casual messages
|
|
8162
|
-
if (urgency === 'Low' || category.includes('Casual') || category.includes('General Chat') || category.includes('Random Thought')) {
|
|
8163
|
-
priority = 4;
|
|
8164
|
-
}
|
|
8165
|
-
|
|
8166
|
-
// Adjust based on relationship
|
|
8167
|
-
if (relationship === 'Family' || relationship === 'Spouse' || relationship === 'Close Friend') {
|
|
8168
|
-
priority = Math.max(1, priority - 1); // Higher priority for close relations
|
|
8169
|
-
}
|
|
8170
|
-
|
|
8171
|
-
return Math.min(Math.max(priority, 1), 5); // Ensure 1-5 scale
|
|
8172
|
-
}
|
|
8173
|
-
|
|
8174
|
-
function estimateResponseTime(category, relationship) {
|
|
8175
|
-
const baseTimes = {
|
|
8176
|
-
'Emergency Alert': 'Immediately',
|
|
8177
|
-
'Urgent Assistance': 'Within minutes',
|
|
8178
|
-
'Help Request': 'Within 30 minutes',
|
|
8179
|
-
'Question Asking': 'Within hours',
|
|
8180
|
-
'Meeting Coordination': 'Within 2 hours',
|
|
8181
|
-
'Casual Conversation': 'Within 24 hours',
|
|
8182
|
-
'General Chat': 'Within 48 hours',
|
|
8183
|
-
};
|
|
8184
|
-
|
|
8185
|
-
// Find matching base time
|
|
8186
|
-
for (const [key, time] of Object.entries(baseTimes)) {
|
|
8187
|
-
if (category.includes(key) || key.includes(category.split(' ')[0])) {
|
|
8188
|
-
return time;
|
|
8189
|
-
}
|
|
8190
|
-
}
|
|
8191
|
-
|
|
8192
|
-
// Default based on relationship
|
|
8193
|
-
switch (relationship) {
|
|
8194
|
-
case 'Close Friend':
|
|
8195
|
-
case 'Family':
|
|
8196
|
-
case 'Spouse':
|
|
8197
|
-
return 'Within 12 hours';
|
|
8198
|
-
case 'Colleague':
|
|
8199
|
-
case 'Professional':
|
|
8200
|
-
return 'Within business hours';
|
|
8201
|
-
case 'Acquaintance':
|
|
8202
|
-
return 'Within 2 days';
|
|
8203
|
-
default:
|
|
8204
|
-
return 'Within 24 hours';
|
|
8205
|
-
}
|
|
8206
|
-
}
|
|
8207
|
-
|
|
8208
|
-
function generateAutoReplySuggestion(category, tone) {
|
|
8209
|
-
const suggestions = {
|
|
8210
|
-
'Meeting Coordination': "Got it! I'll be there.",
|
|
8211
|
-
'Question Asking': 'Let me check and get back to you.',
|
|
8212
|
-
'Urgent Assistance': 'On it! Getting help now.',
|
|
8213
|
-
'Casual Conversation': 'Hey! Good to hear from you.',
|
|
8214
|
-
'Thank You Message': "You're welcome! 😊",
|
|
8215
|
-
'Birthday Wishes': 'Thank you so much! 🎉',
|
|
8216
|
-
};
|
|
8217
|
-
|
|
8218
|
-
for (const [key, reply] of Object.entries(suggestions)) {
|
|
8219
|
-
if (category.includes(key)) {
|
|
8220
|
-
return reply;
|
|
8221
|
-
}
|
|
8222
|
-
}
|
|
8223
|
-
|
|
8224
|
-
// Generic suggestions based on tone
|
|
8225
|
-
switch (tone) {
|
|
8226
|
-
case 'Positive':
|
|
8227
|
-
return 'Great! Thanks for sharing!';
|
|
8228
|
-
case 'Negative':
|
|
8229
|
-
return 'I understand. Let me know if I can help.';
|
|
8230
|
-
case 'Urgent':
|
|
8231
|
-
return 'Received. Looking into this now.';
|
|
8232
|
-
default:
|
|
8233
|
-
return 'Got your message. Talk soon!';
|
|
8234
|
-
}
|
|
8235
|
-
}
|
|
8236
|
-
|
|
8237
|
-
function shouldScheduleFollowUp(category, urgency) {
|
|
8238
|
-
const followUpCategories = ['Question Asking', 'Information Request', 'Meeting Coordination', 'Help Request', 'Task Assignment', 'Deadline Reminder'];
|
|
8239
|
-
|
|
8240
|
-
return followUpCategories.some((fc) => category.includes(fc)) && (urgency === 'Medium' || urgency === 'High');
|
|
8241
|
-
}
|
|
8124
|
+
};
|