Articles in this section

Create a custom Callout flow in Salesforce for Solve Email

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. 

Screenshot 2024-02-16 at 10.22.12 AM.png

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.

When Case is used as an object

4. On your Flow Builder, open the left panel and select New Resource.

Screenshot 2024-02-17 at 8.31.22 AM.png

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.

Screenshot 2024-02-16 at 10.50.57 AM.png

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

Screenshot 2024-02-16 at 9.45.30 AM.png

When Case is used as an object
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

Screenshot 2024-02-16 at 11.37.58 AM.png

7. Add an Action node after the Assignment node.

Screenshot_2023-10-17_at_4.48.17_PM.png

8. Select the SendEmailMessage action that is included in the package. 

Screenshot_2023-10-17_at_4.48.34_PM.png

9. Set the value of the body as the Apex-defined variable forethoughtRequestBody from step 3 above.

Screenshot 2024-03-13 at 4.17.29 PM.png

10. You can test the flow by clicking Debug to send a test record and click Run.

Was this article helpful?
0 out of 0 found this helpful

Support

  • Need help?

    Click here to submit a support request. We are here to assist you.

  • Business hours

    Monday to Friday 8am - 5pm PST excluding US holidays

  • Contact us

    support@forethought.ai