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 is 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:

    slack create app
  5. Select From scratch.

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

  7. Click Generate:

    generate token
  8. Click Create App:

    slack create app workspace
  9. Click Install App:

    slack install app
  10. Click Permission scope:

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

    slack bot permissions chat write
  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:

    slack allow install app workspace
  15. Under Bot User OAuth Token, click Copy and save it on a safe location.

    slack copy oauth token

    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. Select the command.

  5. Configure your integration using the following values:

    integration create ui
    1 Under Project Name type: New Case Salesforce.
    2 Under Project Location click Browse, and then select your home directory.
  6. Click Create Project.

    Anypoint Code Builder creates the base files for your integration.

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