Contact Us 1-800-596-4880

Integrate Salesforce Data into Slack and Email Notifications

logo cloud IDE Cloud IDE

logo desktop IDE Desktop IDE

Open Beta Release: The cloud IDE and AsyncAPI implementation support are in open beta. Any use of Anypoint Code Builder in its beta state is subject to the applicable beta services terms and conditions, available from the IDE.

Create an integration that notifies you through email or Slack when a new case is created in Salesforce.

The integration that you build contains a flow with the following logic:

  • The creation of a new case in Salesforce triggers your flow.

  • If the case is escalated, your application sends an email to the regional leader including the case number, origin, reason, priority, and status.

  • If the case is not escalated, your application sends a message to a Slack channel with the same information.

Before You Begin

Before you begin, ensure you:

Set Up Your Slack Workspace

  1. Navigate to Slack and log in using your organization credentials.

    If your work organization restricts users from creating new workspaces, log in using your personal email account.

  2. Create a new Workspace called Integration Test.

  3. Skip the step to invite new users and type a brief description of your Workspace, for example, This is a test Workspace.

  4. Navigate to Your Apps and click Create an App:

    Create an App in Slack
  5. Select From scratch.

  6. Name your app OAuth for Anypoint Code Builder, and select your Integration Test workspace.

  7. Click Generate:

    Generate a configuration token in Slack
  8. Click Create App:

    Name your app and select a workspace in Slack
  9. Click Install App:

    Install an app in Slack
  10. Click Permission scope:

    Click permission scope in Slack
  11. Scroll down to the Scopes section and, under Bot Token Scopes, select Add an OAuth Scope, and select chat:write.public:

    Add OAuth scope in Slack
  12. Select Add scopes when prompted to add other necessary scopes for chat:write.public.

  13. Scroll up to the OAuth Tokens for Your Workspace and select Install to Workspace.

  14. Click Allow:

    Allow OAuth access to workspace
  15. Under Bot User OAuth Token, click Copy and save it on a safe location.

    Copy OAuth token for Bot User

    You use this token to connect to your Slack workspace from Anypoint Code Builder:

  16. Create a new public channel called "this-is-a-test" in your Integration Test workspace.

  17. Add the OAuth for Anypoint Code Builder app to the this-is-a-test channel.

Set up an App Password for Your Email

Later in this tutorial, you configure the Email Connector to send emails to your configured email account. To avoid using your email password, follow Google instructions to configure an App password.

The Gmail account must have 2-factor authentication enabled to configure an App password.

Create an Integration

  1. Navigate to Anypoint Code Builder.

  2. Open the Command Palette.

    Show me how
    • Use the keyboard shortcuts:

      • Mac: Cmd+Shift+p

      • Windows: Ctrl+Shift+p

    • In the desktop IDE, select View > Command Palette.

    • In the cloud IDE, click the (menu) icon, and select View > Command Palette.

  3. Provide the following command:

    MuleSoft: Develop an Integration
  4. Provide integration project properties to the Develop an Integration form:

    Develop an Integration form
    1. Under Project Name, provide the name New Case Salesforce.

    2. Under Project Location, click Browse, and then select your home directory.

    3. Under Create, select Empty Project.

    4. Select a Mule runtime and Java version.

      You can select any of the supported Mule runtime and Java versions. The IDE saves your version settings to the project’s mule-artifact.json file. To set default Mule runtime and Java versions for the projects you create, see Version Settings for Mule, Java, and Connectors.

  5. Click Create Project.

    The IDE provides a notification if it is necessary to download the selected Mule runtime or Java version for the project. Mule runtime downloads to ${user.home}/AnypointCodeBuilder/runtimes, and the selected Java version downloads to ${user.home}/AnypointCodeBuilder/java.

  6. Proceed to Create a Configuration File for Slack and Salesforce to create configuration files for connectors.