If the Forethought - Solve Email 2.0 - Callout is too broad, or if the cases are coming from an API, the Salesforce admin can decide to deactivate it. They can then add a new custom flow with different trigger conditions to send only a subset of cases to Forethought for automation. This filtering happens before the Email Automation filtering.
1. The trigger conditions can be modified to better suit your business needs. They determine what subset of cases you want to automate. Our advice is to keep the subset as large as possible since Forethought exposes a traffic control tool in the dashboard. This tool can be controlled by non-Salesforce admin users and removes dependency or work that needs to be done by the Salesforce admin.
2. Create a new Record-Triggered Flow Rule.
3. In the Object, we strongly recommend using EmailMessage instead of Cases, as we do not receive updates when using Cases. For more context, please refer to this Salesforce support ticket. The deflection status of emails is set to true by default, unless:
- We receive a user reply, or
- The user clicks the "not helpful" button.
Using Cases may lead to inaccurate deflection metrics.
If you have enabled "Enhanced Email" mode, you should use the EmailMessage object, which is utilized in the default Flow that comes with the Solve Email 2.0 package. Otherwise, you can use the Case object. Configure any conditions that meet your business needs. In the "Optimize the Flow for" section, select Actions and Related Records. Ensure that the checkbox below is checked to include a Run Asynchronously path.
4. On your Flow Builder, open the left panel and select New Resource.
5. Create an Apex-Defined variable with the API name forethoughtRequestBody and use ExternalService_forethought_ForethoughtSolveService_SendEmailMessage_IN_body Apex class that is shared in the package.
6. Under the "Run Asynchronously" path, add an Assignment node and configure the following mapping. Depending on whether you use Case or EmailMessage in Step 3, make sure to pick the right fields. Use fromRecordToRequest as the Label and API Name.
When sending an email, you have two options for the "from_address": Contact Email or Supplied Email. It's generally better to use Supplied Email, even though Contact Email may also work. This is because if you use a new email sender who isn't in your Salesforce contact list, the email may fail to send if you use Contact Email.
Warning: If the "from_address" is empty or null, the webhook handling process will simply fail with a 422 error.
Field Name | Type | Description | If $Record is EmailMessage |
parent_id | id | Case ID | $Record.ParentId |
incoming | boolean | Indicates if this is an incoming message from an end-user or an outgoing message from an agent. | $Record.IsIncoming |
from_address | text | Address of the user that filed the case. | $Record.FromAddress |
to_address | text | Email-to-case address used for Email Automations on the Forethought side. If you don't use "automation", you can set it to null. | $Record.ToAddress |
subject | text | Case or Email Subject | $Record.Subject |
text_body | text | Case or Email Body | $Record.TextBody |
created_date (Optional) | text | Case or Email Created Date | $Record.CreatedDate |
created_by_id (Optional) | text | Id of the user that created the case. | $Record.CreatedById |
is_externally_visible (Optional) | boolean | Indicates if the EmailMessage or request is externally visible in the case feed. | $Record.IsExternallyVisible |
Example mapping from the default flow with $Record as an EmailMessage
Field Name | Type | Description | If $Record is Case |
parent_id | id | Case ID | $Record.Id |
incoming | boolean | Indicates if this is an incoming message from an end-user or an outgoing message from an agent. | Default to True or based on custom logic |
from_address | text | Address of the user that filed the case. | $Record.SuppliedEmail (preferred) or $Record.ContactEmail (Less recommended as you may not have a contact profile for a net new customer) |
to_address | text | Email-to-case address used for Email Automations on the Forethought side. If you don't use "automation", you can set it to null. | Pick a default support address or based on custom logic. |
subject | text | Case or Email Subject | $Record.Subject |
text_body | text | Case or Email Body | $Record.Description |
created_date (Optional) | text | Case or Email Created Date | $Record.CreatedDate |
created_by_id (Optional) | text | Id of the user that created the case. | $Record.CreatedById |
is_externally_visible (Optional) | boolean | Indicates if the EmailMessage or request is externally visible in the case feed. | True |
Example mapping from the default flow with $Record as a Case
7. Add an Action node after the Assignment node.
8. Select the SendEmailMessage action that is included in the package.
9. Set the value of the body as the Apex-defined variable forethoughtRequestBody from step 3 above.
10. You can test the flow by clicking Debug to send a test record and click Run.