In this era of interconnected systems and seamless data flow, integrating different platforms is vital for businesses to streamline operations and enhance customer experience. Cloud integration has become an essential tool in modern business operations.

Salesforce, a leading Customer Relationship Management (CRM) platform, offers powerful features such as topic subscription, while Postmark provides reliable email delivery services. By combining these capabilities with MuleSoft’s integration features, organizations can unlock new possibilities and drive efficiency.

In this comprehensive guide, we discuss how to seamlessly transfer data from Salesforce to Gmail using Postmark and promptly respond via MuleSoft. We will also cover the benefits of MuleSoft integration with Salesforce and how to integrate Salesforce with MuleSoft. Let’s discover how these tools can transform business communication.

What is Postmark ?

Postmark is a SaaS application that can deliver and track application emails. In a nutshell, the service replaces SMTP (Simple Mail Transfer Protocol TCP/IP), which is widely used by email clients such as Gmail, Outlook, Apple Mail, and Yahoo Mail with a far more reliable, scalable, and care-free environment. In addition, statistics such as number of emails sent or processed, opens, bounces, and spam complaints can be tracked.

Getting Started with Salesforce Streaming API

Streaming API in Salesforce can be used to receive notifications whenever there is a change in the Salesforce data. Events are triggered when the changes in the Salesforce data match the SOQL query defined. Salesforce Streaming API is useful when notifications are to be pushed from a server to the client based on the criteria defined.

These events can be received by:

  • Pages in the Salesforce application.
  • Application servers outside Salesforce.
  • Clients outside the Salesforce application.

The sequence of events when using Salesforce Streaming API includes:

  • PushTopic is created based on a SOQL query to define the channel.
  • Clients subscribe to the channel.
  • Record is created, updated, deleted, or undeleted (an event occurs), and the changes to that record are evaluated.
  • If the record changes match the criteria of the PushTopic query, a notification is generated by the server and received by the subscribed clients.

MuleSoft Salesforce Connector

MuleSoft’s Salesforce Connector is an out-of-the-box feature that helps connect to Salesforce using multiple authentication mechanisms. Additionally, the connector can perform most of the operations exposed by Salesforce APIs.

MuleSoft integration Use Cases

Users should receive an email notification when a case has been created/updated in Salesforce. Once the notification has been sent successfully, the case object has to be updated with the notification status. If the user does not exist in Salesforce, a contact is created. Subsequently, the case gets registered against the user.

Pre-requisites:

  • Pages in the Salesforce application.
  • Application servers outside Salesforce.
  • Clients outside the Salesforce application.

Salesforce Developer Account:

  • Create a Salesforce account if you don’t have one (signup).
  • Reset the security token after creating the account
    Go to My Settings > Personal > Reset My Security Token. Click Reset Security Token, and it will send a security token to your registered email.
  • Create two custom fields in Case Object.
    Go to Object Manager > Case object > Fields & Relationships > New > Select Type. Give the field name CaseResolution and NotificationSent and click Ok.
  • CaseResolution with data type Text (128).
  • NotificationSent with data type Date/Time
  • Streaming API in Salesforce triggers a mail to be sent by catching the Salesforce event when a case status changes.
  • Go to the developer console to execute the Query to catch the specific event.
  • The event that has to be queried is: “When Case is escalated with empty NotificationSent and nonEmpty CaseResolution.”
  • Execution using SOQL in the developer console is performed as depicted above.
  • Usually, the query result will be empty. For testing, add a case with Escalated, New, or Working status and with some resolution filled in the custom field CaseResolution in Salesforce. Try the SOQL again to see the records.
  • To catch the event based on the Query, Streaming Push Topics have to be configured.
  • To set up a PushTopic query, workbench is required.
  • Log in with Salesforce credentials, create a push topic with the name Case and set the Query tested earlier in the developer console.
  • Click Save.
  • The PushTopic will look like the below.
  • Every time the event occurs, Salesforce pushes the event to the topic Case.

Salesforce Connector Configuration in Mule 4:

  • Provide username, password, and security token when using the authentication type as basic authentication in Salesforce Connector.
  • Use a created Security Token in Salesforce in connector configuration.

Connecting to Postmark using MuleSoft:

There is no out-of-the-box connector available in MuleSoft to connect to Postmark. Postmark provides REST APIs to interact with the same. MuleSoft’s HTTP connector provides the most practical way to consume an external HTTP service. When sending HTTP requests, one can choose what method to use (GET, POST, etc.) and may include a body, headers, attachments, query parameters, form parameters, and URI parameters. The response is then received by the connector and is passed on to the next element in your flow.

Postmark setup:

  • Signup for a Postmark account (signup).
  • Create a user in Postmark.
  • Create an API token.

Mule application configuration of HTTP request:

  • In headers, add the following
  • In the URL column, enter the following endpoint
  • In the body, add the payload to be sent as mail.
  • The method should be HTTP POST.

Flows in MuleSoft:

The above flows are used to retrieve the contact id of a user (if it exists) to create a case. If the contact id does not exist, the case is created after the contact has been created.

In the third workflow, a subscription topic listener connector will monitor the previously established ‘Case’ topic. This Mule flow is activated whenever a new case is generated in Salesforce. It then utilizes the Postmark API to transmit a notification to the user. On successful transmission of the notification, the timestamp in the corresponding custom object, ‘Notification sent,’ is updated.

Conclusion

Through MuleSoft Integration use cases, we have demonstrated how integrations seamlessly connect to Salesforce and Postmark, highlighting the ease of integrating these platforms using MuleSoft. We have also elaborated on utilizing the Postmark API effectively, becoming proficient in crucial SOQL commands, and setting up the MuleSoft connector to efficiently consume Salesforce topics.

By leveraging the practical tips for integrating these technologies seamlessly and following the guidelines in this blog, businesses can enhance their efficiency, streamline their workflows, and improve their overall productivity. As a leading integration services provider MuleSoft offers enterprise-based solutions for all integration needs, which enhance productivity and improve business agility.

Rachana D
Software Engineer, GSS, Enterprise Integration

Ready to get started?

Contact us Close