diff --git a/drive.html b/drive.html deleted file mode 100644 index d8f15a0..0000000 --- a/drive.html +++ /dev/null @@ -1,1043 +0,0 @@ - - - - - - Drive - General Bots - - - - - - - - - -
- - - - -
- -
- - -
- - - - - -
-
- - -
- - - - -
-
-
- - - -
- - - - - - - - - - - - - - - - diff --git a/hr/employee-engage.gbai/config.json b/hr/employee-engage.gbai/config.json new file mode 100644 index 0000000..2559c63 --- /dev/null +++ b/hr/employee-engage.gbai/config.json @@ -0,0 +1,35 @@ +{ + "name": "employee-engage", + "version": "1.0.0", + "description": "Employee engagement surveys and sentiment analysis", + "author": "General Bots", + "category": "hr", + "tags": ["engagement", "surveys", "pulse", "sentiment", "feedback", "hr"], + "entry_dialog": "default.gbdialog", + "features": { + "engagement_surveys": true, + "pulse_checks": true, + "sentiment_analysis": true, + "anonymous_feedback": true, + "results_dashboard": true, + "ai_insights": true + }, + "settings": { + "default_anonymous": true, + "pulse_frequency": "weekly", + "sentiment_threshold": 0.3, + "auto_escalate_negative": true, + "survey_reminder_days": 3 + }, + "permissions": { + "create_survey": ["hr", "admin"], + "view_results": ["hr", "admin", "manager"], + "submit_feedback": ["all"], + "manage_settings": ["admin"] + }, + "integrations": { + "calendar": true, + "mail": true, + "analytics": true + } +} diff --git a/hr/employee-engage.gbai/default.gbdialog b/hr/employee-engage.gbai/default.gbdialog new file mode 100644 index 0000000..3ef525b --- /dev/null +++ b/hr/employee-engage.gbai/default.gbdialog @@ -0,0 +1,185 @@ +PARAM action AS STRING LIKE "survey" DESCRIPTION "Action to perform: survey, pulse, results, feedback" +PARAM survey_type AS STRING LIKE "engagement" DESCRIPTION "Survey type: engagement, pulse, onboarding, exit" OPTIONAL +PARAM anonymous AS BOOLEAN LIKE TRUE DESCRIPTION "Anonymous responses" OPTIONAL + +DESCRIPTION "Employee engagement surveys and sentiment analysis" + +SELECT CASE UCASE(action) + +CASE "SURVEY" + survey_id = GUID() + survey_name = ASK "What is the name of this survey?" + target_audience = ASK "Who should receive this survey? (all, department, team, or comma-separated emails)" + + questions = NEW ARRAY + adding_questions = TRUE + + WHILE adding_questions + question_text = ASK "Enter survey question (or 'done' to finish):" + IF UCASE(question_text) = "DONE" THEN + adding_questions = FALSE + ELSE + question_type = ASK "Question type? (scale, choice, text, nps)" + + WITH question + id = GUID() + text = question_text + type = question_type + END WITH + + IF question_type = "scale" THEN + question.min_label = "Strongly Disagree" + question.max_label = "Strongly Agree" + question.scale = 5 + END IF + + IF question_type = "choice" THEN + options_text = ASK "Enter options (comma-separated):" + question.options = SPLIT(options_text, ",") + END IF + + IF question_type = "nps" THEN + question.min_label = "Not Likely" + question.max_label = "Very Likely" + question.scale = 10 + END IF + + PUSH questions, question + END IF + END WHILE + + WITH survey + id = survey_id + name = survey_name + type = survey_type + questions = questions + target = target_audience + anonymous = anonymous + status = "draft" + created_at = NOW() + END WITH + + SAVE survey TO "surveys" + + launch_now = ASK "Launch survey now? (yes/no)" + IF UCASE(launch_now) = "YES" THEN + survey.status = "active" + survey.launched_at = NOW() + SAVE survey TO "surveys" + TALK "Survey launched! Notifications sent to " + target_audience + ELSE + TALK "Survey saved as draft. Launch when ready from the dashboard." + END IF + +CASE "PULSE" + pulse_id = GUID() + pulse_question = ASK "What quick question do you want to ask?" + pulse_frequency = ASK "How often? (daily, weekly, biweekly)" + + WITH pulse + id = pulse_id + question = pulse_question + frequency = pulse_frequency + anonymous = TRUE + status = "active" + created_at = NOW() + responses = NEW ARRAY + END WITH + + SAVE pulse TO "pulses" + TALK "Pulse check created. First pulse will be sent based on " + pulse_frequency + " schedule." + +CASE "RESULTS" + surveys = FIND "surveys" WHERE status = "completed" OR status = "active" + + IF LEN(surveys) = 0 THEN + TALK "No surveys with results found." + ELSE + survey_list = "" + FOR i = 0 TO LEN(surveys) - 1 + survey_list = survey_list + (i + 1) + ". " + surveys[i].name + " (" + surveys[i].status + ")\n" + END FOR + + selection = ASK "Select survey to view results:\n" + survey_list + selected_survey = surveys[INT(selection) - 1] + + responses = FIND "responses" WHERE survey_id = selected_survey.id + + total_responses = LEN(responses) + + IF total_responses = 0 THEN + TALK "No responses yet for this survey." + ELSE + TALK "šŸ“Š Results for: " + selected_survey.name + TALK "Total responses: " + total_responses + + FOR q = 0 TO LEN(selected_survey.questions) - 1 + question = selected_survey.questions[q] + TALK "\nšŸ“‹ " + question.text + + IF question.type = "scale" OR question.type = "nps" THEN + sum = 0 + FOR r = 0 TO LEN(responses) - 1 + answer = responses[r].answers[q] + sum = sum + answer + END FOR + avg = sum / total_responses + TALK "Average: " + FORMAT(avg, "0.0") + " / " + question.scale + END IF + + IF question.type = "choice" THEN + FOR opt = 0 TO LEN(question.options) - 1 + count = 0 + FOR r = 0 TO LEN(responses) - 1 + IF responses[r].answers[q] = question.options[opt] THEN + count = count + 1 + END IF + END FOR + pct = (count / total_responses) * 100 + TALK question.options[opt] + ": " + FORMAT(pct, "0") + "%" + END FOR + END IF + END FOR + + sentiment = ANALYZE SENTIMENT FROM responses + TALK "\nšŸŽÆ Overall Sentiment: " + sentiment.label + " (" + FORMAT(sentiment.score * 100, "0") + "% positive)" + END IF + END IF + +CASE "FEEDBACK" + feedback_type = ASK "Feedback type? (anonymous, identified, suggestion)" + feedback_text = ASK "Enter your feedback:" + + WITH feedback + id = GUID() + type = feedback_type + content = feedback_text + anonymous = (feedback_type = "anonymous") + sentiment = ANALYZE SENTIMENT FROM feedback_text + created_at = NOW() + END WITH + + SAVE feedback TO "feedback" + + TALK "Thank you for your feedback!" + + IF feedback.sentiment.score < 0.3 THEN + TALK "We noticed this might be a concern. Would you like to speak with HR?" + escalate = ASK "Request HR follow-up? (yes/no)" + IF UCASE(escalate) = "YES" THEN + feedback.escalated = TRUE + feedback.escalated_at = NOW() + SAVE feedback TO "feedback" + TALK "HR has been notified and will follow up." + END IF + END IF + +CASE ELSE + TALK "Employee Engagement System" + TALK "Available actions:" + TALK "• survey - Create and launch engagement surveys" + TALK "• pulse - Quick pulse checks" + TALK "• results - View survey results and analytics" + TALK "• feedback - Submit anonymous feedback" + +END SELECT diff --git a/hr/team-feedback.gbai/config.json b/hr/team-feedback.gbai/config.json new file mode 100644 index 0000000..eba03c6 --- /dev/null +++ b/hr/team-feedback.gbai/config.json @@ -0,0 +1,51 @@ +{ + "name": "team-feedback", + "version": "1.0.0", + "description": "Team feedback and pulse surveys for managers", + "author": "General Bots", + "category": "hr", + "tags": ["pulse", "feedback", "team", "manager", "surveys", "hr"], + "entry_dialog": "default.gbdialog", + "features": { + "pulse_surveys": true, + "team_health": true, + "sentiment_analysis": true, + "trend_tracking": true, + "action_items": true, + "ai_insights": true + }, + "settings": { + "default_frequency": "weekly", + "anonymous_responses": true, + "alert_threshold": 3.0, + "trend_periods": 4, + "auto_remind": true, + "reminder_hours": 24 + }, + "templates": { + "wellbeing": { + "name": "Team Wellbeing", + "questions": 4 + }, + "workload": { + "name": "Workload Check", + "questions": 4 + }, + "collaboration": { + "name": "Collaboration Health", + "questions": 4 + } + }, + "permissions": { + "create_pulse": ["manager", "hr", "admin"], + "view_results": ["manager", "hr", "admin"], + "respond": ["team_member"], + "manage_actions": ["manager", "hr", "admin"] + }, + "integrations": { + "tasks": true, + "calendar": true, + "mail": true, + "analytics": true + } +} diff --git a/hr/team-feedback.gbai/default.gbdialog b/hr/team-feedback.gbai/default.gbdialog new file mode 100644 index 0000000..6d5f68c --- /dev/null +++ b/hr/team-feedback.gbai/default.gbdialog @@ -0,0 +1,219 @@ +PARAM action AS STRING LIKE "pulse" DESCRIPTION "Action: pulse, review, insights, actions" +PARAM team_id AS STRING DESCRIPTION "Team identifier" OPTIONAL +PARAM period AS STRING LIKE "weekly" DESCRIPTION "Review period" OPTIONAL + +DESCRIPTION "Team feedback and pulse surveys for managers" + +SELECT CASE UCASE(action) + +CASE "PULSE" + pulse_id = GUID() + pulse_name = ASK "Name this pulse check (e.g., 'Weekly Team Health'):" + + template = ASK "Use template? (wellbeing, workload, collaboration, custom)" + + questions = NEW ARRAY + + IF template = "wellbeing" THEN + PUSH questions, { text: "How are you feeling about work this week?", type: "scale", scale: 5 } + PUSH questions, { text: "Do you feel supported by your team?", type: "scale", scale: 5 } + PUSH questions, { text: "Is your workload manageable?", type: "scale", scale: 5 } + PUSH questions, { text: "Any blockers or concerns?", type: "text" } + END IF + + IF template = "workload" THEN + PUSH questions, { text: "How would you rate your current workload?", type: "scale", scale: 5 } + PUSH questions, { text: "Do you have clarity on priorities?", type: "scale", scale: 5 } + PUSH questions, { text: "Are deadlines realistic?", type: "scale", scale: 5 } + PUSH questions, { text: "What would help you be more productive?", type: "text" } + END IF + + IF template = "collaboration" THEN + PUSH questions, { text: "How effective is team communication?", type: "scale", scale: 5 } + PUSH questions, { text: "Do you feel your input is valued?", type: "scale", scale: 5 } + PUSH questions, { text: "How well is the team working together?", type: "scale", scale: 5 } + PUSH questions, { text: "Suggestions for better collaboration?", type: "text" } + END IF + + IF template = "custom" THEN + adding = TRUE + WHILE adding + q_text = ASK "Enter question (or 'done'):" + IF UCASE(q_text) = "DONE" THEN + adding = FALSE + ELSE + q_type = ASK "Type? (scale/text/choice)" + WITH q + text = q_text + type = q_type + scale = 5 + END WITH + PUSH questions, q + END IF + END WHILE + END IF + + frequency = ASK "Send frequency? (once, daily, weekly, biweekly, monthly)" + + WITH pulse + id = pulse_id + name = pulse_name + template = template + questions = questions + frequency = frequency + team_id = team_id + anonymous = TRUE + status = "active" + created_at = NOW() + END WITH + + SAVE pulse TO "team_pulses" + TALK "Pulse '" + pulse_name + "' created! First survey sends based on " + frequency + " schedule." + +CASE "REVIEW" + pulses = FIND "team_pulses" WHERE team_id = team_id OR team_id = NULL + + IF LEN(pulses) = 0 THEN + TALK "No pulse surveys found. Create one first with action=pulse" + ELSE + pulse_list = "" + FOR i = 0 TO LEN(pulses) - 1 + pulse_list = pulse_list + (i + 1) + ". " + pulses[i].name + "\n" + END FOR + + selection = ASK "Select pulse to review:\n" + pulse_list + selected = pulses[INT(selection) - 1] + + responses = FIND "pulse_responses" WHERE pulse_id = selected.id + + IF LEN(responses) = 0 THEN + TALK "No responses yet." + ELSE + TALK "šŸ“Š " + selected.name + " Results" + TALK "Responses: " + LEN(responses) + + FOR q = 0 TO LEN(selected.questions) - 1 + question = selected.questions[q] + TALK "\n" + question.text + + IF question.type = "scale" THEN + sum = 0 + FOR r = 0 TO LEN(responses) - 1 + sum = sum + responses[r].answers[q] + END FOR + avg = sum / LEN(responses) + + bar = "" + filled = INT(avg) + FOR b = 1 TO 5 + IF b <= filled THEN + bar = bar + "ā–ˆ" + ELSE + bar = bar + "ā–‘" + END IF + END FOR + TALK bar + " " + FORMAT(avg, "0.0") + "/5" + + IF avg < 3 THEN + TALK "āš ļø Area needs attention" + END IF + END IF + + IF question.type = "text" THEN + TALK "Comments:" + FOR r = 0 TO LEN(responses) - 1 + IF responses[r].answers[q] <> "" THEN + TALK "• " + responses[r].answers[q] + END IF + END FOR + END IF + END FOR + + trend = FIND "pulse_trends" WHERE pulse_id = selected.id ORDER BY date DESC LIMIT 4 + IF LEN(trend) > 1 THEN + TALK "\nšŸ“ˆ Trend (last 4 periods):" + FOR t = 0 TO LEN(trend) - 1 + TALK trend[t].date + ": " + FORMAT(trend[t].avg_score, "0.0") + END FOR + END IF + END IF + END IF + +CASE "INSIGHTS" + TALK "šŸ” AI-Generated Team Insights" + + responses = FIND "pulse_responses" WHERE team_id = team_id ORDER BY created_at DESC LIMIT 50 + text_feedback = "" + FOR r = 0 TO LEN(responses) - 1 + FOR a = 0 TO LEN(responses[r].answers) - 1 + IF TYPEOF(responses[r].answers[a]) = "string" THEN + text_feedback = text_feedback + responses[r].answers[a] + " " + END IF + END FOR + END FOR + + IF text_feedback <> "" THEN + themes = ANALYZE THEMES FROM text_feedback + sentiment = ANALYZE SENTIMENT FROM text_feedback + + TALK "\nšŸŽÆ Key Themes:" + FOR t = 0 TO LEN(themes) - 1 + TALK "• " + themes[t].topic + " (" + themes[t].count + " mentions)" + END FOR + + TALK "\n😊 Team Sentiment: " + sentiment.label + TALK "Positive: " + FORMAT(sentiment.positive * 100, "0") + "%" + TALK "Neutral: " + FORMAT(sentiment.neutral * 100, "0") + "%" + TALK "Negative: " + FORMAT(sentiment.negative * 100, "0") + "%" + + IF sentiment.negative > 0.3 THEN + TALK "\nāš ļø Elevated negative sentiment detected. Consider scheduling team discussion." + END IF + ELSE + TALK "Not enough feedback data for insights. Run more pulse surveys." + END IF + +CASE "ACTIONS" + TALK "šŸ“‹ Suggested Actions Based on Feedback" + + low_scores = FIND "pulse_trends" WHERE avg_score < 3 AND team_id = team_id + + IF LEN(low_scores) > 0 THEN + TALK "\nAreas needing attention:" + FOR s = 0 TO LEN(low_scores) - 1 + TALK "• " + low_scores[s].question_text + " (Score: " + FORMAT(low_scores[s].avg_score, "0.0") + ")" + END FOR + + create_action = ASK "Create action item? (yes/no)" + IF UCASE(create_action) = "YES" THEN + action_text = ASK "Describe the action:" + due_date = ASK "Due date (YYYY-MM-DD):" + owner = ASK "Owner (email):" + + WITH action_item + id = GUID() + description = action_text + due = due_date + assigned_to = owner + team_id = team_id + source = "team_feedback" + status = "open" + created_at = NOW() + END WITH + + SAVE action_item TO "action_items" + TALK "Action item created and assigned to " + owner + END IF + ELSE + TALK "No critical areas identified. Team health looks good!" + END IF + +CASE ELSE + TALK "Team Feedback System" + TALK "Available actions:" + TALK "• pulse - Create quick team surveys" + TALK "• review - View pulse results" + TALK "• insights - AI-generated team insights" + TALK "• actions - Review and create action items" + +END SELECT diff --git a/productivity/broadcast.gbai/config.json b/productivity/broadcast.gbai/config.json new file mode 100644 index 0000000..723cb79 --- /dev/null +++ b/productivity/broadcast.gbai/config.json @@ -0,0 +1,52 @@ +{ + "name": "broadcast", + "version": "1.0.0", + "description": "Internal communications and broadcast messaging", + "author": "General Bots", + "category": "productivity", + "tags": ["broadcast", "communications", "announcements", "campaigns", "newsletter"], + "entry_dialog": "default.gbdialog", + "features": { + "multi_channel": true, + "campaign_management": true, + "templates": true, + "scheduling": true, + "analytics": true, + "ai_content": true + }, + "settings": { + "default_channels": ["email", "chat"], + "require_approval": false, + "track_opens": true, + "track_clicks": true, + "max_recipients": 10000 + }, + "channels": { + "email": { + "enabled": true, + "track_opens": true + }, + "chat": { + "enabled": true, + "channel_name": "announcements" + }, + "social": { + "enabled": false, + "platforms": ["linkedin"] + }, + "sms": { + "enabled": false + } + }, + "permissions": { + "create_campaign": ["communications", "hr", "admin"], + "send_campaign": ["communications", "admin"], + "view_analytics": ["communications", "hr", "admin", "manager"], + "manage_templates": ["communications", "admin"] + }, + "integrations": { + "mail": true, + "social": true, + "analytics": true + } +} diff --git a/productivity/broadcast.gbai/default.gbdialog b/productivity/broadcast.gbai/default.gbdialog new file mode 100644 index 0000000..48c8973 --- /dev/null +++ b/productivity/broadcast.gbai/default.gbdialog @@ -0,0 +1,257 @@ +PARAM action AS STRING LIKE "campaign" DESCRIPTION "Action: campaign, send, schedule, templates, analytics" +PARAM channel AS STRING LIKE "all" DESCRIPTION "Channel: all, email, chat, social, sms" OPTIONAL +PARAM audience AS STRING DESCRIPTION "Target audience" OPTIONAL + +DESCRIPTION "Internal communications and broadcast messaging" + +SELECT CASE UCASE(action) + +CASE "CAMPAIGN" + campaign_id = GUID() + campaign_name = ASK "Campaign name:" + campaign_goal = ASK "Campaign goal (awareness, engagement, action):" + + TALK "šŸ“¢ Creating broadcast campaign: " + campaign_name + + message_subject = ASK "Message subject/title:" + message_body = ASK "Message content (supports markdown):" + + use_ai = ASK "Use AI to improve message? (yes/no)" + IF UCASE(use_ai) = "YES" THEN + tone = ASK "Desired tone? (professional, friendly, urgent, inspirational)" + improved = IMPROVE TEXT message_body WITH TONE tone + TALK "AI-improved version:" + TALK improved + use_improved = ASK "Use improved version? (yes/no)" + IF UCASE(use_improved) = "YES" THEN + message_body = improved + END IF + END IF + + channels_input = ASK "Select channels (comma-separated: email, chat, social, sms, or 'all'):" + IF UCASE(channels_input) = "ALL" THEN + selected_channels = ["email", "chat", "social", "sms"] + ELSE + selected_channels = SPLIT(channels_input, ",") + END IF + + audience_type = ASK "Audience? (all, department, role, group, custom)" + IF audience_type = "custom" THEN + audience_filter = ASK "Enter audience filter (emails or group name):" + ELSE + audience_filter = audience_type + END IF + + WITH campaign + id = campaign_id + name = campaign_name + goal = campaign_goal + subject = message_subject + body = message_body + channels = selected_channels + audience = audience_filter + status = "draft" + created_at = NOW() + END WITH + + SAVE campaign TO "broadcast_campaigns" + + preview = ASK "Preview campaign? (yes/no)" + IF UCASE(preview) = "YES" THEN + TALK "šŸ“§ Subject: " + campaign.subject + TALK "šŸ“ Body: " + campaign.body + TALK "šŸ“” Channels: " + JOIN(campaign.channels, ", ") + TALK "šŸ‘„ Audience: " + campaign.audience + END IF + + TALK "Campaign saved. Use action=send or action=schedule to distribute." + +CASE "SEND" + campaigns = FIND "broadcast_campaigns" WHERE status = "draft" OR status = "scheduled" + + IF LEN(campaigns) = 0 THEN + TALK "No campaigns ready to send. Create one first with action=campaign" + ELSE + campaign_list = "" + FOR i = 0 TO LEN(campaigns) - 1 + campaign_list = campaign_list + (i + 1) + ". " + campaigns[i].name + " (" + campaigns[i].status + ")\n" + END FOR + + selection = ASK "Select campaign to send:\n" + campaign_list + selected = campaigns[INT(selection) - 1] + + confirm = ASK "Send '" + selected.name + "' now to " + selected.audience + "? (yes/no)" + IF UCASE(confirm) = "YES" THEN + recipients = GET_RECIPIENTS(selected.audience) + sent_count = 0 + + FOR ch = 0 TO LEN(selected.channels) - 1 + channel_name = selected.channels[ch] + + IF channel_name = "email" THEN + SEND MAIL TO recipients SUBJECT selected.subject BODY selected.body + sent_count = sent_count + LEN(recipients) + END IF + + IF channel_name = "chat" THEN + POST TO "internal_announcements" CONTENT selected.body + sent_count = sent_count + 1 + END IF + + IF channel_name = "social" THEN + POST TO "linkedin" CONTENT selected.body + sent_count = sent_count + 1 + END IF + END FOR + + selected.status = "sent" + selected.sent_at = NOW() + selected.recipients_count = sent_count + SAVE selected TO "broadcast_campaigns" + + TALK "āœ… Campaign sent successfully!" + TALK "Recipients reached: " + sent_count + ELSE + TALK "Send cancelled." + END IF + END IF + +CASE "SCHEDULE" + campaigns = FIND "broadcast_campaigns" WHERE status = "draft" + + IF LEN(campaigns) = 0 THEN + TALK "No draft campaigns to schedule." + ELSE + campaign_list = "" + FOR i = 0 TO LEN(campaigns) - 1 + campaign_list = campaign_list + (i + 1) + ". " + campaigns[i].name + "\n" + END FOR + + selection = ASK "Select campaign to schedule:\n" + campaign_list + selected = campaigns[INT(selection) - 1] + + schedule_date = ASK "Schedule date (YYYY-MM-DD):" + schedule_time = ASK "Schedule time (HH:MM):" + schedule_tz = ASK "Timezone (e.g., America/New_York):" + + selected.status = "scheduled" + selected.scheduled_for = schedule_date + "T" + schedule_time + selected.timezone = schedule_tz + SAVE selected TO "broadcast_campaigns" + + TALK "šŸ“… Campaign scheduled for " + schedule_date + " at " + schedule_time + " " + schedule_tz + +CASE "TEMPLATES" + template_action = ASK "Templates action? (list, create, use)" + + IF template_action = "list" THEN + templates = FIND "broadcast_templates" + IF LEN(templates) = 0 THEN + TALK "No templates found. Create one with templates action=create" + ELSE + TALK "šŸ“‹ Available templates:" + FOR t = 0 TO LEN(templates) - 1 + TALK (t + 1) + ". " + templates[t].name + " - " + templates[t].category + END FOR + END IF + END IF + + IF template_action = "create" THEN + template_name = ASK "Template name:" + template_category = ASK "Category (announcement, newsletter, alert, event):" + template_subject = ASK "Subject template:" + template_body = ASK "Body template (use {{variable}} for placeholders):" + + WITH template + id = GUID() + name = template_name + category = template_category + subject = template_subject + body = template_body + created_at = NOW() + END WITH + + SAVE template TO "broadcast_templates" + TALK "Template saved!" + END IF + + IF template_action = "use" THEN + templates = FIND "broadcast_templates" + IF LEN(templates) = 0 THEN + TALK "No templates available." + ELSE + template_list = "" + FOR t = 0 TO LEN(templates) - 1 + template_list = template_list + (t + 1) + ". " + templates[t].name + "\n" + END FOR + + selection = ASK "Select template:\n" + template_list + selected_template = templates[INT(selection) - 1] + + TALK "Using template: " + selected_template.name + TALK "Subject: " + selected_template.subject + TALK "Body: " + selected_template.body + TALK "Run action=campaign to create a campaign using this template." + END IF + END IF + +CASE "ANALYTICS" + period = ASK "Analytics period? (week, month, quarter, all)" + + campaigns = FIND "broadcast_campaigns" WHERE status = "sent" + + IF LEN(campaigns) = 0 THEN + TALK "No sent campaigns to analyze." + ELSE + total_sent = 0 + total_opened = 0 + total_clicked = 0 + + TALK "šŸ“Š Broadcast Analytics" + TALK "═══════════════════════════════════" + + FOR c = 0 TO LEN(campaigns) - 1 + campaign = campaigns[c] + opens = campaign.opens_count + clicks = campaign.clicks_count + sent = campaign.recipients_count + + IF opens = NULL THEN opens = 0 + IF clicks = NULL THEN clicks = 0 + IF sent = NULL THEN sent = 0 + + total_sent = total_sent + sent + total_opened = total_opened + opens + total_clicked = total_clicked + clicks + + open_rate = 0 + IF sent > 0 THEN + open_rate = (opens / sent) * 100 + END IF + + TALK "\nšŸ“¢ " + campaign.name + TALK " Sent: " + sent + " | Opens: " + opens + " (" + FORMAT(open_rate, "0") + "%)" + END FOR + + TALK "\n═══════════════════════════════════" + TALK "TOTALS" + TALK "Campaigns: " + LEN(campaigns) + TALK "Messages sent: " + total_sent + + overall_open_rate = 0 + IF total_sent > 0 THEN + overall_open_rate = (total_opened / total_sent) * 100 + END IF + TALK "Overall open rate: " + FORMAT(overall_open_rate, "0") + "%" + END IF + +CASE ELSE + TALK "šŸ“¢ Broadcast Communication System" + TALK "Available actions:" + TALK "• campaign - Create a new broadcast campaign" + TALK "• send - Send a campaign immediately" + TALK "• schedule - Schedule a campaign for later" + TALK "• templates - Manage message templates" + TALK "• analytics - View campaign performance" + +END SELECT