|
| 1 | +### Document: Contact Support Modal or Fallback to Email Client Logic Flow |
| 2 | + |
| 3 | +--- |
| 4 | + |
| 5 | +#### **Overview** |
| 6 | +This document outlines the logic flow for determining whether the Practera app displays a **HubSpot support form modal** or falls back to the **email client** for user support. The decision is based on the email address configured in the admin settings. |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +### **Logic Flow** |
| 11 | + |
| 12 | +#### **1. Input: Support Email Address** |
| 13 | +The support email address is retrieved from the current experience's configuration in the app's storage. |
| 14 | + |
| 15 | +#### **2. Conditions** |
| 16 | +The app evaluates the email address to determine the appropriate support path: |
| 17 | + |
| 18 | +1. **Practera Support Email**: |
| 19 | + - If the email address contains `@practera.com`, the app: |
| 20 | + - Activates the **HubSpot support form modal**. |
| 21 | + - Users can submit their queries directly within the app. |
| 22 | + - Example: `support@practera.com`. |
| 23 | + |
| 24 | +2. **Custom Support Email**: |
| 25 | + - If the email address does **not** contain `@practera.com`, the app: |
| 26 | + - Falls back to the **email client**. |
| 27 | + - Opens the user's default email client with a pre-filled subject line containing the current program name. |
| 28 | + - Example: `support@customdomain.com`. |
| 29 | + |
| 30 | +3. **Default Fallback**: |
| 31 | + - If no email address is configured, the app uses the default Practera helpline email (`programs@practera.com`) and opens the email client. |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +### **Logic Implementation** |
| 36 | + |
| 37 | +#### **Key Functions** |
| 38 | +1. **`checkIsPracteraSupportEmail()`**: |
| 39 | + - Checks if the configured email address contains `@practera.com`. |
| 40 | + - Broadcasts an event (`support-email-checked`) with `true` or `false` to notify other parts of the app. |
| 41 | + |
| 42 | + ```typescript |
| 43 | + checkIsPracteraSupportEmail() { |
| 44 | + const currentExperience = this.storageService.get('experience'); |
| 45 | + if (currentExperience && currentExperience.supportEmail) { |
| 46 | + const supportEmail = currentExperience.supportEmail; |
| 47 | + if (supportEmail.includes("@practera.com")) { |
| 48 | + this.broadcastEvent('support-email-checked', true); |
| 49 | + return true; |
| 50 | + } |
| 51 | + this.broadcastEvent('support-email-checked', false); |
| 52 | + return false; |
| 53 | + } |
| 54 | + this.broadcastEvent('support-email-checked', false); |
| 55 | + return false; |
| 56 | + } |
| 57 | + ``` |
| 58 | + |
| 59 | +2. **`openSupportPopup(event)`**: |
| 60 | + - Determines whether to show the HubSpot modal or fallback to the email client based on the `hubspotActivated` flag. |
| 61 | + |
| 62 | + ```typescript |
| 63 | + async openSupportPopup(event): Promise<void> { |
| 64 | + if (event instanceof KeyboardEvent && event.key !== 'Enter' && event.key !== ' ') { |
| 65 | + return; |
| 66 | + } |
| 67 | + if (this.hubspotActivated === true) { |
| 68 | + const componentProps = { |
| 69 | + mode: 'modal', |
| 70 | + isShowFormOnly: true, |
| 71 | + }; |
| 72 | + |
| 73 | + const modal = await this.modalController.create({ |
| 74 | + componentProps, |
| 75 | + component: SupportPopupComponent, |
| 76 | + cssClass: 'support-popup', |
| 77 | + backdropDismiss: false, |
| 78 | + }); |
| 79 | + |
| 80 | + return modal.present(); |
| 81 | + } |
| 82 | + |
| 83 | + return this.mailTo(event); |
| 84 | + } |
| 85 | + ``` |
| 86 | + |
| 87 | +3. **`mailTo(event)`**: |
| 88 | + - Opens the email client with a pre-filled subject line and recipient email address. |
| 89 | + |
| 90 | + ```typescript |
| 91 | + mailTo(event) { |
| 92 | + if (event instanceof KeyboardEvent && event.key !== 'Enter' && event.key !== ' ') { |
| 93 | + return; |
| 94 | + } |
| 95 | + |
| 96 | + let mailto = `mailto:${this.helpline}?subject=${this.currentProgramName}`; |
| 97 | + const supportEmail = this.utils.getSupportEmail(); |
| 98 | + |
| 99 | + if (!this.utils.checkIsPracteraSupportEmail() && !this.utils.isEmpty(supportEmail)) { |
| 100 | + mailto = `mailto:${supportEmail}?subject=${this.currentProgramName}`; |
| 101 | + } |
| 102 | + window.open(mailto, '_self'); |
| 103 | + } |
| 104 | + ``` |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +### **Logic Flow Diagram** |
| 109 | + |
| 110 | +```plaintext |
| 111 | +Start |
| 112 | + | |
| 113 | + v |
| 114 | +Retrieve Support Email Address (after experience selection / login) |
| 115 | + | |
| 116 | + v |
| 117 | +Is Email Address Practera Support Email? (contains "@practera.com") |
| 118 | + | Yes | No |
| 119 | + v v |
| 120 | +Show HubSpot Modal Open Email Client |
| 121 | + | | |
| 122 | + v v |
| 123 | +User Submits Query Pre-fill Email with: |
| 124 | + - Recipient: Support Email |
| 125 | + - Subject: Current Program Name |
| 126 | + | |
| 127 | + v |
| 128 | +End |
| 129 | +``` |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +### **Default Email Address** |
| 134 | +If no email address is configured in the admin settings, the app defaults to using `programs@practera.com` as the recipient email. |
| 135 | + |
| 136 | +--- |
| 137 | + |
| 138 | +### **How to Configure the Support Email** |
| 139 | +1. Go to the **Admin Settings** in the Practera platform. |
| 140 | +2. Locate the **Support Email** field under the current experience or program settings. |
| 141 | +3. Enter a valid email address: |
| 142 | + - Use a `@practera.com` email for HubSpot integration. |
| 143 | + - Use a custom email for fallback to the email client. |
| 144 | +4. Save the changes. |
| 145 | + |
| 146 | +--- |
| 147 | + |
| 148 | +### **Supported and Unsupported Configurations** |
| 149 | + |
| 150 | +#### **Supported Configurations** |
| 151 | +- **Practera Support Email**: Enables HubSpot modal. |
| 152 | +- **Custom Support Email**: Falls back to the email client. |
| 153 | + |
| 154 | +#### **Unsupported Configurations** |
| 155 | +- **Empty or Missing Email Address**: Defaults to `programs@practera.com`. |
| 156 | + |
| 157 | +--- |
| 158 | + |
| 159 | +### **Testing** |
| 160 | +- Test with both Practera and custom email addresses. |
| 161 | +- Verify the HubSpot modal opens for Practera emails. |
| 162 | +- Verify the email client opens with the correct pre-filled details for custom emails. |
| 163 | +- Test fallback to the default email address when no email is configured. |
| 164 | + |
| 165 | +--- |
| 166 | + |
| 167 | +This document ensures clarity on the logic flow and configuration for the support functionality in the Practera app. |
0 commit comments