@xuda.io/ai_module 1.1.4641 → 1.1.4643
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 +490 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4217,8 +4217,18 @@ export const create_conversation = async function (req, job_id, headers) {
|
|
|
4217
4217
|
await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
4218
4218
|
}
|
|
4219
4219
|
}
|
|
4220
|
+
|
|
4221
|
+
switch (conversation_type) {
|
|
4222
|
+
case 'email': {
|
|
4223
|
+
break;
|
|
4224
|
+
}
|
|
4225
|
+
|
|
4226
|
+
default:
|
|
4227
|
+
break;
|
|
4228
|
+
}
|
|
4229
|
+
|
|
4220
4230
|
if (perform_ai_execution) {
|
|
4221
|
-
await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
|
|
4231
|
+
// await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
|
|
4222
4232
|
}
|
|
4223
4233
|
if (conversation_doc.reference_type === 'contacts') {
|
|
4224
4234
|
if (recipient_uid) {
|
|
@@ -7749,3 +7759,482 @@ function getDomainFromCategory(category) {
|
|
|
7749
7759
|
}
|
|
7750
7760
|
return 'General';
|
|
7751
7761
|
}
|
|
7762
|
+
|
|
7763
|
+
export const categorize_text_message = async function (uid, message_text, contact_info, metadata = {}) {
|
|
7764
|
+
const text_message_categories = [
|
|
7765
|
+
// Personal Communication (1-20)
|
|
7766
|
+
'Casual Conversation',
|
|
7767
|
+
'Catching Up',
|
|
7768
|
+
'Daily Check-in',
|
|
7769
|
+
'Family Update',
|
|
7770
|
+
'Friend Chat',
|
|
7771
|
+
'Romantic Message',
|
|
7772
|
+
'Flirting / Dating',
|
|
7773
|
+
'Expressing Feelings',
|
|
7774
|
+
'Emotional Support',
|
|
7775
|
+
'Comfort / Consolation',
|
|
7776
|
+
'Congratulations',
|
|
7777
|
+
'Sympathy / Condolences',
|
|
7778
|
+
'Birthday Wishes',
|
|
7779
|
+
'Holiday Greetings',
|
|
7780
|
+
'Anniversary Message',
|
|
7781
|
+
'Thank You Message',
|
|
7782
|
+
'Apology Message',
|
|
7783
|
+
'Forgiveness Request',
|
|
7784
|
+
'Miss You Message',
|
|
7785
|
+
'Thinking of You',
|
|
7786
|
+
|
|
7787
|
+
// Practical & Logistics (21-40)
|
|
7788
|
+
'Meeting Coordination',
|
|
7789
|
+
'Plans Making',
|
|
7790
|
+
'Schedule Coordination',
|
|
7791
|
+
'Time Confirmation',
|
|
7792
|
+
'Location Sharing',
|
|
7793
|
+
'Address Request',
|
|
7794
|
+
'Directions Request',
|
|
7795
|
+
'Ride Coordination',
|
|
7796
|
+
'Pickup Request',
|
|
7797
|
+
'Drop-off Arrangement',
|
|
7798
|
+
'Event Details',
|
|
7799
|
+
'Reservation Confirmation',
|
|
7800
|
+
'Travel Coordination',
|
|
7801
|
+
'Running Late Notification',
|
|
7802
|
+
'Change of Plans',
|
|
7803
|
+
'Cancellation Notice',
|
|
7804
|
+
'Reminder Sent',
|
|
7805
|
+
'Follow-up Request',
|
|
7806
|
+
'Confirmation Needed',
|
|
7807
|
+
'Status Update',
|
|
7808
|
+
|
|
7809
|
+
// Information Exchange (41-60)
|
|
7810
|
+
'Question Asking',
|
|
7811
|
+
'Information Request',
|
|
7812
|
+
'Advice Seeking',
|
|
7813
|
+
'Opinion Request',
|
|
7814
|
+
'Recommendation Ask',
|
|
7815
|
+
'Resource Sharing',
|
|
7816
|
+
'Link Sharing',
|
|
7817
|
+
'Photo Sharing',
|
|
7818
|
+
'Video Sharing',
|
|
7819
|
+
'Document Sharing',
|
|
7820
|
+
'News Sharing',
|
|
7821
|
+
'Article Forwarding',
|
|
7822
|
+
'Meme Sharing',
|
|
7823
|
+
'Joke Sharing',
|
|
7824
|
+
'Interesting Fact',
|
|
7825
|
+
'Tip Sharing',
|
|
7826
|
+
'Recipe Sharing',
|
|
7827
|
+
'Book/Movie Recommendation',
|
|
7828
|
+
'Music Recommendation',
|
|
7829
|
+
'Restaurant Suggestion',
|
|
7830
|
+
|
|
7831
|
+
// Work & Business (61-75)
|
|
7832
|
+
'Work Discussion',
|
|
7833
|
+
'Project Update',
|
|
7834
|
+
'Task Assignment',
|
|
7835
|
+
'Deadline Reminder',
|
|
7836
|
+
'Client Communication',
|
|
7837
|
+
'Colleague Coordination',
|
|
7838
|
+
'Team Collaboration',
|
|
7839
|
+
'Business Inquiry',
|
|
7840
|
+
'Professional Networking',
|
|
7841
|
+
'Interview Coordination',
|
|
7842
|
+
'Job Opportunity',
|
|
7843
|
+
'Business Idea',
|
|
7844
|
+
'Partnership Discussion',
|
|
7845
|
+
'Contract Details',
|
|
7846
|
+
'Payment Discussion',
|
|
7847
|
+
|
|
7848
|
+
// Urgent & Emergency (76-85)
|
|
7849
|
+
'Emergency Alert',
|
|
7850
|
+
'Help Request',
|
|
7851
|
+
'Urgent Assistance',
|
|
7852
|
+
'Safety Check',
|
|
7853
|
+
'Medical Emergency',
|
|
7854
|
+
'Accident Report',
|
|
7855
|
+
'Lost Item Report',
|
|
7856
|
+
'Security Concern',
|
|
7857
|
+
'Immediate Response Needed',
|
|
7858
|
+
'Critical Update',
|
|
7859
|
+
|
|
7860
|
+
// Social & Invitations (86-95)
|
|
7861
|
+
'Event Invitation',
|
|
7862
|
+
'Party Invite',
|
|
7863
|
+
'Gathering Plan',
|
|
7864
|
+
'Dinner Invitation',
|
|
7865
|
+
'Movie Night Plan',
|
|
7866
|
+
'Game Night',
|
|
7867
|
+
'Weekend Plans',
|
|
7868
|
+
'Hangout Request',
|
|
7869
|
+
'Social Media Tag',
|
|
7870
|
+
'Group Chat Add',
|
|
7871
|
+
|
|
7872
|
+
// Shopping & Commerce (96-105)
|
|
7873
|
+
'Purchase Inquiry',
|
|
7874
|
+
'Product Question',
|
|
7875
|
+
'Price Check',
|
|
7876
|
+
'Shopping Coordination',
|
|
7877
|
+
'Gift Idea',
|
|
7878
|
+
'Order Status',
|
|
7879
|
+
'Delivery Update',
|
|
7880
|
+
'Payment Request',
|
|
7881
|
+
'Bill Splitting',
|
|
7882
|
+
'Money Transfer',
|
|
7883
|
+
|
|
7884
|
+
// Health & Wellness (106-115)
|
|
7885
|
+
'Health Update',
|
|
7886
|
+
'Doctor Appointment',
|
|
7887
|
+
'Medication Reminder',
|
|
7888
|
+
'Wellness Check',
|
|
7889
|
+
'Exercise Plan',
|
|
7890
|
+
'Diet Discussion',
|
|
7891
|
+
'Mental Health Check',
|
|
7892
|
+
'Self-care Reminder',
|
|
7893
|
+
'Recovery Update',
|
|
7894
|
+
'Health Advice',
|
|
7895
|
+
|
|
7896
|
+
// Household & Family (116-125)
|
|
7897
|
+
'Family Planning',
|
|
7898
|
+
'Childcare Coordination',
|
|
7899
|
+
'Pet Care',
|
|
7900
|
+
'Home Maintenance',
|
|
7901
|
+
'Grocery List',
|
|
7902
|
+
'Chore Assignment',
|
|
7903
|
+
'Household Decision',
|
|
7904
|
+
'Property Discussion',
|
|
7905
|
+
'Neighbor Communication',
|
|
7906
|
+
'Community Update',
|
|
7907
|
+
|
|
7908
|
+
// Education & Learning (126-135)
|
|
7909
|
+
'Homework Help',
|
|
7910
|
+
'Study Group',
|
|
7911
|
+
'Class Discussion',
|
|
7912
|
+
'Assignment Reminder',
|
|
7913
|
+
'School Update',
|
|
7914
|
+
'Teacher Communication',
|
|
7915
|
+
'Tutoring Request',
|
|
7916
|
+
'Educational Resource',
|
|
7917
|
+
'Learning Progress',
|
|
7918
|
+
'Academic Achievement',
|
|
7919
|
+
|
|
7920
|
+
// Entertainment & Leisure (136-145)
|
|
7921
|
+
'Game Invitation',
|
|
7922
|
+
'Streaming Watch Party',
|
|
7923
|
+
'Concert Plans',
|
|
7924
|
+
'Sports Discussion',
|
|
7925
|
+
'Hobby Sharing',
|
|
7926
|
+
'Vacation Planning',
|
|
7927
|
+
'Weekend Getaway',
|
|
7928
|
+
'Adventure Plan',
|
|
7929
|
+
'Outdoor Activity',
|
|
7930
|
+
'Cultural Event',
|
|
7931
|
+
|
|
7932
|
+
// Technology & Digital (146-155)
|
|
7933
|
+
'Tech Support',
|
|
7934
|
+
'App Recommendation',
|
|
7935
|
+
'Software Question',
|
|
7936
|
+
'Device Issue',
|
|
7937
|
+
'Password Reset',
|
|
7938
|
+
'Account Recovery',
|
|
7939
|
+
'Digital Security',
|
|
7940
|
+
'Social Media Tagging',
|
|
7941
|
+
'Online Purchase',
|
|
7942
|
+
'Digital Content Share',
|
|
7943
|
+
|
|
7944
|
+
// Legal & Official (156-160)
|
|
7945
|
+
'Legal Advice',
|
|
7946
|
+
'Document Request',
|
|
7947
|
+
'Official Notification',
|
|
7948
|
+
'Government Matter',
|
|
7949
|
+
'Compliance Issue',
|
|
7950
|
+
|
|
7951
|
+
// Spiritual & Religious (161-165)
|
|
7952
|
+
'Prayer Request',
|
|
7953
|
+
'Religious Event',
|
|
7954
|
+
'Spiritual Guidance',
|
|
7955
|
+
'Meditation Group',
|
|
7956
|
+
'Faith Discussion',
|
|
7957
|
+
|
|
7958
|
+
// Miscellaneous (166-175)
|
|
7959
|
+
'Random Thought',
|
|
7960
|
+
'Philosophical Question',
|
|
7961
|
+
'Deep Conversation',
|
|
7962
|
+
'Hypothetical Scenario',
|
|
7963
|
+
'Dream Sharing',
|
|
7964
|
+
'Memory Recall',
|
|
7965
|
+
'Future Planning',
|
|
7966
|
+
'Goal Setting',
|
|
7967
|
+
'Life Update',
|
|
7968
|
+
'General Chat',
|
|
7969
|
+
|
|
7970
|
+
// Signal & Meta Communication (176-185)
|
|
7971
|
+
'Read Receipt',
|
|
7972
|
+
'Typing Indicator',
|
|
7973
|
+
'Message Reaction',
|
|
7974
|
+
'Voice Message',
|
|
7975
|
+
'Video Call Request',
|
|
7976
|
+
'Phone Call Follow-up',
|
|
7977
|
+
'Connection Test',
|
|
7978
|
+
'Network Issue',
|
|
7979
|
+
'Delivery Failure',
|
|
7980
|
+
'Message Forward',
|
|
7981
|
+
|
|
7982
|
+
// Relationship Dynamics (186-195)
|
|
7983
|
+
'Conflict Resolution',
|
|
7984
|
+
'Relationship Discussion',
|
|
7985
|
+
'Boundary Setting',
|
|
7986
|
+
'Expectation Setting',
|
|
7987
|
+
'Commitment Talk',
|
|
7988
|
+
'Future Plans Talk',
|
|
7989
|
+
'Family Introduction',
|
|
7990
|
+
'Meeting Planning',
|
|
7991
|
+
'Relationship Milestone',
|
|
7992
|
+
'Breakup Discussion',
|
|
7993
|
+
|
|
7994
|
+
// Quick & Brief (196-200)
|
|
7995
|
+
'One-word Response',
|
|
7996
|
+
'Emoji Message',
|
|
7997
|
+
'Sticker/GIF Send',
|
|
7998
|
+
'Quick Reply',
|
|
7999
|
+
'Acknowledgment Only',
|
|
8000
|
+
];
|
|
8001
|
+
const prompt = `Categorize the text message into one of these exact categories:
|
|
8002
|
+
|
|
8003
|
+
Text Message: "${message_text.substring(0, 300)}${message_text.length > 300 ? '...' : ''}"
|
|
8004
|
+
|
|
8005
|
+
Contact Context:
|
|
8006
|
+
- Relationship: ${contact_info?.relationship || 'Unknown'}
|
|
8007
|
+
- Frequency: ${metadata?.message_frequency || 'Unknown'}
|
|
8008
|
+
- Time of Day: ${new Date().getHours()}h
|
|
8009
|
+
- Previous Context: ${metadata?.previous_topic || 'Not provided'}
|
|
8010
|
+
|
|
8011
|
+
Available Categories (200 total):
|
|
8012
|
+
${text_message_categories
|
|
8013
|
+
.slice(0, 25)
|
|
8014
|
+
.map((cat, index) => `${index + 1}. ${cat}`)
|
|
8015
|
+
.join('\n')}
|
|
8016
|
+
[Full list of 200 categories available to the system]
|
|
8017
|
+
|
|
8018
|
+
Instructions:
|
|
8019
|
+
1. Analyze the message content, tone, and context
|
|
8020
|
+
2. Consider the relationship between sender and recipient
|
|
8021
|
+
3. Identify the primary purpose of the message
|
|
8022
|
+
4. Choose the single most relevant category
|
|
8023
|
+
5. Return only the exact category name
|
|
8024
|
+
6. Factor in:
|
|
8025
|
+
- Urgency level
|
|
8026
|
+
- Emotional tone
|
|
8027
|
+
- Relationship context
|
|
8028
|
+
- Time sensitivity
|
|
8029
|
+
- Expected response type
|
|
8030
|
+
7. If unsure, consider the most common interpretation
|
|
8031
|
+
8. For ambiguous messages, choose based on typical usage patterns
|
|
8032
|
+
|
|
8033
|
+
Category:`;
|
|
8034
|
+
|
|
8035
|
+
try {
|
|
8036
|
+
const message_category_ret = await submit_chat_gpt_prompt({
|
|
8037
|
+
uid,
|
|
8038
|
+
prompt: prompt,
|
|
8039
|
+
model: 'gpt-4o-mini', // Good for short text analysis
|
|
8040
|
+
response_format: z.object({
|
|
8041
|
+
message_category: z.enum(text_message_categories),
|
|
8042
|
+
confidence_score: z.number().min(0).max(100),
|
|
8043
|
+
emotional_tone: z.enum(['Positive', 'Neutral', 'Negative', 'Mixed', 'Urgent', 'Playful', 'Formal', 'Casual']),
|
|
8044
|
+
urgency_level: z.enum(['Low', 'Medium', 'High', 'Emergency']),
|
|
8045
|
+
expected_response: z.enum(['None', 'Acknowledgment', 'Short Reply', 'Detailed Reply', 'Action Required', 'Immediate Call']),
|
|
8046
|
+
relationship_dynamics: z.string().max(100).optional(),
|
|
8047
|
+
}),
|
|
8048
|
+
metadata: {
|
|
8049
|
+
func: 'categorize_text_message',
|
|
8050
|
+
message_length: message_text.length,
|
|
8051
|
+
message_type: metadata?.is_media ? 'Multimedia' : 'Text Only',
|
|
8052
|
+
contact_relationship: contact_info?.relationship,
|
|
8053
|
+
time_sent: new Date().toISOString(),
|
|
8054
|
+
platform: metadata?.platform || 'Unknown',
|
|
8055
|
+
is_group_chat: metadata?.is_group_chat || false,
|
|
8056
|
+
},
|
|
8057
|
+
account_profile_info,
|
|
8058
|
+
});
|
|
8059
|
+
|
|
8060
|
+
if (message_category_ret && message_category_ret.code > -1) {
|
|
8061
|
+
const data = typeof message_category_ret.data === 'string' ? JSON.parse(message_category_ret.data) : message_category_ret.data;
|
|
8062
|
+
|
|
8063
|
+
// Analyze message characteristics
|
|
8064
|
+
const message_analysis = analyzeMessageCharacteristics(message_text, data.message_category);
|
|
8065
|
+
|
|
8066
|
+
// Determine priority for notification systems
|
|
8067
|
+
const priority_level = calculateMessagePriority(data.urgency_level, data.message_category, contact_info?.relationship);
|
|
8068
|
+
|
|
8069
|
+
return {
|
|
8070
|
+
success: true,
|
|
8071
|
+
category: data.message_category,
|
|
8072
|
+
confidence: data.confidence_score,
|
|
8073
|
+
emotional_tone: data.emotional_tone,
|
|
8074
|
+
urgency: data.urgency_level,
|
|
8075
|
+
expected_response: data.expected_response,
|
|
8076
|
+
priority: priority_level,
|
|
8077
|
+
relationship_dynamics: data.relationship_dynamics,
|
|
8078
|
+
|
|
8079
|
+
// Analysis results
|
|
8080
|
+
word_count: message_analysis.word_count,
|
|
8081
|
+
contains_questions: message_analysis.contains_questions,
|
|
8082
|
+
contains_requests: message_analysis.contains_requests,
|
|
8083
|
+
time_sensitive: message_analysis.time_sensitive,
|
|
8084
|
+
|
|
8085
|
+
// Context
|
|
8086
|
+
relationship: contact_info?.relationship || 'Unknown',
|
|
8087
|
+
typical_response_time: estimateResponseTime(data.message_category, contact_info?.relationship),
|
|
8088
|
+
|
|
8089
|
+
// Metadata
|
|
8090
|
+
message_preview: message_text.substring(0, 150),
|
|
8091
|
+
timestamp: new Date().toISOString(),
|
|
8092
|
+
|
|
8093
|
+
// Suggestions
|
|
8094
|
+
auto_reply_suggestion: generateAutoReplySuggestion(data.message_category, data.emotional_tone),
|
|
8095
|
+
follow_up_reminder: shouldScheduleFollowUp(data.message_category, data.urgency_level),
|
|
8096
|
+
};
|
|
8097
|
+
} else {
|
|
8098
|
+
return {
|
|
8099
|
+
success: false,
|
|
8100
|
+
category: 'General Chat',
|
|
8101
|
+
confidence: 0,
|
|
8102
|
+
emotional_tone: 'Neutral',
|
|
8103
|
+
urgency: 'Low',
|
|
8104
|
+
priority: 3,
|
|
8105
|
+
message_preview: message_text.substring(0, 150),
|
|
8106
|
+
error: message_category_ret?.message || 'API call failed',
|
|
8107
|
+
timestamp: new Date().toISOString(),
|
|
8108
|
+
};
|
|
8109
|
+
}
|
|
8110
|
+
} catch (error) {
|
|
8111
|
+
console.error('Error in categorize_text_message:', error);
|
|
8112
|
+
return {
|
|
8113
|
+
success: false,
|
|
8114
|
+
category: 'General Chat',
|
|
8115
|
+
confidence: 0,
|
|
8116
|
+
emotional_tone: 'Neutral',
|
|
8117
|
+
urgency: 'Low',
|
|
8118
|
+
priority: 3,
|
|
8119
|
+
message_preview: message_text.substring(0, 150),
|
|
8120
|
+
error: error.message,
|
|
8121
|
+
timestamp: new Date().toISOString(),
|
|
8122
|
+
};
|
|
8123
|
+
}
|
|
8124
|
+
};
|
|
8125
|
+
|
|
8126
|
+
// Helper functions
|
|
8127
|
+
function analyzeMessageCharacteristics(message, category) {
|
|
8128
|
+
const wordCount = message.split(/\s+/).length;
|
|
8129
|
+
const charCount = message.length;
|
|
8130
|
+
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);
|
|
8131
|
+
const containsRequests = /(please|can you|could you|would you|need you|want you|help me|assist)/i.test(message);
|
|
8132
|
+
const containsUrgency = /(urgent|asap|immediately|right now|emergency|quick|fast|hurry)/i.test(message);
|
|
8133
|
+
const containsTimeReferences = /\b(today|tomorrow|now|soon|later|tonight|morning|afternoon|evening)\b/i.test(message);
|
|
8134
|
+
const containsEmoticons = /[:;][\-]?[\)\(DP]|<\/?3|\([^\)]*\)|[\u{1F600}-\u{1F64F}]/gu.test(message);
|
|
8135
|
+
|
|
8136
|
+
return {
|
|
8137
|
+
word_count: wordCount,
|
|
8138
|
+
char_count: charCount,
|
|
8139
|
+
contains_questions: containsQuestions,
|
|
8140
|
+
contains_requests: containsRequests,
|
|
8141
|
+
time_sensitive: containsTimeReferences || containsUrgency,
|
|
8142
|
+
has_emoticons: containsEmoticons,
|
|
8143
|
+
message_type: charCount < 50 ? 'Short' : charCount < 200 ? 'Medium' : 'Long',
|
|
8144
|
+
};
|
|
8145
|
+
}
|
|
8146
|
+
|
|
8147
|
+
function calculateMessagePriority(urgency, category, relationship) {
|
|
8148
|
+
let priority = 3; // Default medium priority
|
|
8149
|
+
|
|
8150
|
+
// Emergency categories get highest priority
|
|
8151
|
+
if (urgency === 'Emergency' || category.includes('Emergency')) {
|
|
8152
|
+
return 1;
|
|
8153
|
+
}
|
|
8154
|
+
|
|
8155
|
+
// High urgency
|
|
8156
|
+
if (urgency === 'High' || category.includes('Urgent')) {
|
|
8157
|
+
priority = 2;
|
|
8158
|
+
}
|
|
8159
|
+
|
|
8160
|
+
// Low urgency or casual messages
|
|
8161
|
+
if (urgency === 'Low' || category.includes('Casual') || category.includes('General Chat') || category.includes('Random Thought')) {
|
|
8162
|
+
priority = 4;
|
|
8163
|
+
}
|
|
8164
|
+
|
|
8165
|
+
// Adjust based on relationship
|
|
8166
|
+
if (relationship === 'Family' || relationship === 'Spouse' || relationship === 'Close Friend') {
|
|
8167
|
+
priority = Math.max(1, priority - 1); // Higher priority for close relations
|
|
8168
|
+
}
|
|
8169
|
+
|
|
8170
|
+
return Math.min(Math.max(priority, 1), 5); // Ensure 1-5 scale
|
|
8171
|
+
}
|
|
8172
|
+
|
|
8173
|
+
function estimateResponseTime(category, relationship) {
|
|
8174
|
+
const baseTimes = {
|
|
8175
|
+
'Emergency Alert': 'Immediately',
|
|
8176
|
+
'Urgent Assistance': 'Within minutes',
|
|
8177
|
+
'Help Request': 'Within 30 minutes',
|
|
8178
|
+
'Question Asking': 'Within hours',
|
|
8179
|
+
'Meeting Coordination': 'Within 2 hours',
|
|
8180
|
+
'Casual Conversation': 'Within 24 hours',
|
|
8181
|
+
'General Chat': 'Within 48 hours',
|
|
8182
|
+
};
|
|
8183
|
+
|
|
8184
|
+
// Find matching base time
|
|
8185
|
+
for (const [key, time] of Object.entries(baseTimes)) {
|
|
8186
|
+
if (category.includes(key) || key.includes(category.split(' ')[0])) {
|
|
8187
|
+
return time;
|
|
8188
|
+
}
|
|
8189
|
+
}
|
|
8190
|
+
|
|
8191
|
+
// Default based on relationship
|
|
8192
|
+
switch (relationship) {
|
|
8193
|
+
case 'Close Friend':
|
|
8194
|
+
case 'Family':
|
|
8195
|
+
case 'Spouse':
|
|
8196
|
+
return 'Within 12 hours';
|
|
8197
|
+
case 'Colleague':
|
|
8198
|
+
case 'Professional':
|
|
8199
|
+
return 'Within business hours';
|
|
8200
|
+
case 'Acquaintance':
|
|
8201
|
+
return 'Within 2 days';
|
|
8202
|
+
default:
|
|
8203
|
+
return 'Within 24 hours';
|
|
8204
|
+
}
|
|
8205
|
+
}
|
|
8206
|
+
|
|
8207
|
+
function generateAutoReplySuggestion(category, tone) {
|
|
8208
|
+
const suggestions = {
|
|
8209
|
+
'Meeting Coordination': "Got it! I'll be there.",
|
|
8210
|
+
'Question Asking': 'Let me check and get back to you.',
|
|
8211
|
+
'Urgent Assistance': 'On it! Getting help now.',
|
|
8212
|
+
'Casual Conversation': 'Hey! Good to hear from you.',
|
|
8213
|
+
'Thank You Message': "You're welcome! 😊",
|
|
8214
|
+
'Birthday Wishes': 'Thank you so much! 🎉',
|
|
8215
|
+
};
|
|
8216
|
+
|
|
8217
|
+
for (const [key, reply] of Object.entries(suggestions)) {
|
|
8218
|
+
if (category.includes(key)) {
|
|
8219
|
+
return reply;
|
|
8220
|
+
}
|
|
8221
|
+
}
|
|
8222
|
+
|
|
8223
|
+
// Generic suggestions based on tone
|
|
8224
|
+
switch (tone) {
|
|
8225
|
+
case 'Positive':
|
|
8226
|
+
return 'Great! Thanks for sharing!';
|
|
8227
|
+
case 'Negative':
|
|
8228
|
+
return 'I understand. Let me know if I can help.';
|
|
8229
|
+
case 'Urgent':
|
|
8230
|
+
return 'Received. Looking into this now.';
|
|
8231
|
+
default:
|
|
8232
|
+
return 'Got your message. Talk soon!';
|
|
8233
|
+
}
|
|
8234
|
+
}
|
|
8235
|
+
|
|
8236
|
+
function shouldScheduleFollowUp(category, urgency) {
|
|
8237
|
+
const followUpCategories = ['Question Asking', 'Information Request', 'Meeting Coordination', 'Help Request', 'Task Assignment', 'Deadline Reminder'];
|
|
8238
|
+
|
|
8239
|
+
return followUpCategories.some((fc) => category.includes(fc)) && (urgency === 'Medium' || urgency === 'High');
|
|
8240
|
+
}
|