Salesforce SAML SSO: A Step-by-Step Guide

This blog will cover an example use case for a SAML SSO solution, explore related concepts, and show how to implement it in the Salesforce platform.

The example use case is the following:

There are two orgs, Epic Innovations and Secure Ops, where the latter contains classified information that cannot leave the system for compliance reasons. Agents working on cases in the Epic Innovations org need some additional information available in the Secure Ops org to work on some of their cases.

Salesforce SAML SSO: A step-by-step guide

 

The requirements are:

  1. Password-Free Access

Agents should be able to log in to the Secure Ops org without re-entering their passwords.

  1. Conditional Access Control

Agents should be able to access the Secure Ops org only if they have open cases of type Classified assigned to them.

The subsequent sections are organized as follows: Section I reviews the relevant SAML SSO concepts, Section II, describes how the solution can be implemented in the Salesforce Platform, and Section III shows the implementation results.

1. SAML SSO Concepts

What is Single Sign-On?

Single sign-on (SSO) is an authentication method that enables users to access multiple applications with one login and one set of credentials [1].

SSO greatly simplifies the user experience by eliminating users needing to remember and enter different usernames and passwords for each application they use within a particular environment.

SSO is widely used in web applications and SaaS systems to streamline user authentication and improve overall security. It can be implemented using protocols such as OAuth, OpenID Connect, and SAML (Security Assertion Markup Language).

Identity Providers and Service Providers

An Identity Provider (IdP) is a trusted service that stores and verifies a user’s identity. SSO implementations use an IdP to verify the identity of the user attempting to log in. If their identity is verified, they’re given access to the system. Fig 1 shows an example of the X login page, where Google and Apple can be used as IdPs to verify a user’s identity.

Fig 1. x.com login page.

A Service Provider (SP) is an entity that provides resources or applications to an end user. In SSO, the SP relies on an IdP to verify a user’s identity. Going back to the X example, the X platform serves as an SP, providing access to the X web application, and relies on either Google or Apple to verify the user’s identity.

Salesforce is automatically enabled as an identity provider when a domain is created. After a domain is deployed, admins can add or change identity providers and increase security for their organization by customizing their domain’s login policy [2].

SAML SSO Flows

When setting up SAML SSO there are two possible ways of initiating the login process: from the identity provider or the service provider. The steps for each flow as outlined in the official Salesforce documentation [3] are described below.

Service Provider-Initiated SAML Flow

  1. The user requests a secure session to access a protected resource from the service provider. For instance, the user would like to access X, which can only be achieved by logging in.
  2. The service provider initiates login by sending a SAML request to the identity provider.
  3. The identity provider sends the user to a login page.
  4. The user enters their identity provider login credentials, and the identity provider authenticates the user.
  5. The identity provider now knows who the user is, so it sends a cryptographically signed SAML response to the service provider. The response contains a SAML assertion that tells the service provider who the user is.
  6. The service provider validates the signature in the SAML response and identifies the user.
  7. The user is now logged in to the service provider and can access the protected resource.

Identity Provider-Initiated SAML Flow

The IdP-Initiated flow is a shortened version of the SP-Initiated flow. In this case, a SAML request is unnecessary.

  1. The user logs in to the identity provider.
  2. The user clicks a button or link to access the service provider.
  3. The identity provider sends a cryptographically signed SAML response to the service provider. The response contains a SAML assertion that tells the service provider who the user is.
  4. The user is now logged in to the service provider and can access the protected resource.

II. Salesforce Implementation

Solution outline

In this blog post, the chosen solution for the sample use case involves implementing a service provider-initiated SAML SSO flow. A connected app for the Secure Ops organization will be configured within the Epic Innovations organization. This setup enables agents to be seamlessly redirected to the Secure Ops login page.

Upon reaching the Secure Ops login page, agents will be prompted to authenticate using their Epic Innovations credentials. Subsequently, the system initiates a verification process to check for any open cases of type Classified associated with the respective agent. If open cases are identified, the agents will be granted access. With open cases, they’re allowed access to the system.

Setting up Salesforce as a SAML Identity Provider

To let users access external systems and, in this case, the Secure Ops org, with their Epic Innovations credentials, the Epic Innovations org has to be enabled as an Identity provider.

To enable a Salesforce org as an IdP [4]:

  1. From Setup, in the Quick Find box, enter Identity Provider, then select Identity Provider.
  2. Click Enable Identity Provider.

Once enabled, you can click Edit to choose a certificate, Download Certificate to download the certificate, and Download Metadata to download the metadata associated with your identity provider, which contains information such as the Entity ID, Name ID Format, and other relevant information that will be discussed in the following sections.

Fig 2. Identity Provider Setup in the Epic Innovations org.

Setting up Salesforce as a SAML Service Provider

The Secure Ops org can be configured as a service provider to facilitate access to the Secure Ops organization using Epic Innovations credentials. This is achieved by creating a SAML single sign-on (SSO) setting using some information from the identity provider.

To create a SAML Single Sign-On Setting [5]:

  1. From Setup, in the Quick Find box, enter Single, and then select Single Sign-On Settings.
  2. Click New; this option allows you to specify all the settings manually. You can also create a configuration with existing Metadata Files.
  3. Fill in the relevant information as shown in the picture below.
Fig 3. Single Sign-On settings in the Secure Ops org.

Next, some of the key fields are described:

Name: Epic Innovations incorporation. This is a name that easily references the configuration. This name appears if the identity provider is added to My Domain or an Experience Cloud login page.

Issuer: A unique URL that identifies the identity provider. This was taken from the Identity Provider Setup configured in the Epic Innovations org.

Entity ID: A unique URL that specifies who the SAML assertion is intended for, i.e., the service provider. In this case, the Secure Ops domain is filled in.

Identity Provider Certificate: The authentication certificate issued by the identity provider. This was downloaded from the Identity Provider Setup configured in the Epic Innovations org.

Request Signing Certificate: The request signing certificate generates the signature on a SAML request to the identity provider for a service provider-initiated login.

Request Signature Method: Hashing algorithm for signed requests, either RSA-SHA1 or RSA-SHA256.

Assertion Decryption Certificate: If the identity provider encrypts SAML assertions, the appropriate certificate should be selected for this field. In this case, the Epic Innovations org would not encrypt the assertion, so the Assertion not encrypted option can be selected.

SAML Identity Type: This is selected based on how the identity provider identifies Salesforce users in SAML assertions. In this case, the Federation ID will be used.

SAML Identity Location: This option is based on where the identity provider stores the user’s identifier in SAML assertions. In this case, we chose Identity in the NameIdentifier element of the Subject statement. When we set up a connected app, we’ll specify this in the Epic Innovations org.

Service Provider Initiated Request Binding: This is selected according to the binding mechanism that the identity provider requests from SAML messages. In this case, HTTP POST will be used.

Identity Provider Login URL: Since HTTP POST was chosen as the request binding, the URL with endpoint /idp/endpoint/HttpPost is used. This endpoint can be found in the Identity Provider’s metadata file. Also, the corresponding endpoint for HTTP Redirect is available in this file.

Custom Logout URL: This is a URL to which the user will be redirected once logged out. Here, the Epic Innovations’ My Domain was chosen.

Adding the Epic Innovations org to the Secure Ops login page

With the SSO Setting in place, it is time to add the Epic Innovations login option to the Secure Ops login page.

To add the Epic Innovations login option to the My Domain login page [5]:

  1. From Setup, in the Quick Find box, enter My Domain, and then select My Domain.
  2. Under Authentication Configuration, click Edit.
  3. Enable the Epic Innovations option.
  4. Save the changes.
Fig 4. My Domain Authentication Configuration in the Secure Ops org.

Specifying a Service Provider as a Connected App

A connected app that implements SAML 2.0 for user authentication can be set up to integrate a service provider with Epic Innovations org.

To set up the connected app [6, 7]:

  1. From Setup, in the Quick Find box, enter Apps, and then select App Manager.
  2. Click New Connected App
  3. Fill in the basic information section as appropriate.
  4. In the Web App Settings section, fill in the Start URL with the Secure Ops’ My Domain. This will redirect users to Secure Ops org when they access the connected app.
  5. Click Enable SAML; this will allow more information to be filled in.
  6. For Entity ID, fill in the Secure Ops’ My Domain.
  7. For the ACS URL, which stands for Assertion Consumer Service URL, fill in Secure Ops’ My Domain. The SP’s metadata file can provide this.
  8. For Subject Type, select Federation ID. Remember that the service provider set the Identity Type to Federation ID.
  9. For Name ID Format, select the one that matches the NameIDFormat in the SP’s metadata file.

Add the Connected App to the App Launcher

Since the created Connected App has the start URL set up, it can be added to the app launcher for easier access. To do this:

  1. From Setup, in the Quick Find box, enter App Menu, and then select App Menu.
  2. Then, search the Connected App and mark it as Visible in App Launcher.

Setting up conditional access control

As stated in the requirements, users should only be able to access the Secure Ops org whenever they have open cases marked as classified. A Connected App handler will be used to fulfill this requirement. Connected App handlers can be used to customize connected apps’ behavior when invoked.

A Connected App handler is an Apex class that extends the ConnectedAppPlugin class. Here is the entire implementation for this use case.

				
					global with sharing class SecureOpsAppPlugin extends Auth.ConnectedAppPlugin
{
        global override Boolean authorize(
Id userId,
Id connectedAppId,
Boolean isAdminApproved,
Auth.InvocationContext context
    ){
        // get the number of open cases the user has
        Integer i = [
SELECT COUNT() FROM Case
WHERE
Status!='Closed' AND Type='Classified' AND OwnerId=:userId
   ];
        
        // if the user has one or more cases open, authorize access
        return (i > 0);
    }
}

				
			

As mentioned earlier, the created class extends the ConnectedAppPlugin class. In this case, the authorized method is overridden. This method permits the specified user to access the connected app [8]. The method returns a boolean indicating whether the user is approved or not to access the connected app. A value true indicates the user is authorized, and a false indicates that it didn’t grant access.

Since the requirements indicate that access should be denied if there are no open cases, the code runs a COUNT query to check the number of Open cases of type Classified the user has. If the user has at least one case with those characteristics, the method returns true, granting access to the connected app. Otherwise, it returns false, denying access.

Managing Users

There’s one last task before diving into the results: user management. While configuring the Single Sign-On settings, it was established that the Federation ID would be the identifier for the user logging in.

Consequently, any user logging into the Secure Ops organization via the Epic Innovations login should have a corresponding user in the Epic Innovations organization with a matching Federation ID. If a matching Federation ID is not found, the user cannot log in.

To set the Federation ID for a user:

  1. From Setup, in the Quick Find box, enter Users, and then select Users.
  2. Find the user and click Edit.
  3. In the Single Sign On Information section, fill in the Federation ID field.

 

III. Results

To validate the implementation, let’s first try to access the Secure Ops org without any cases of type Classified open.

From the App Launcher, we select the Secure Ops Solutions connected app we created.

Fig 5. Secure Ops Connected App in the App Launcher.

This redirects us to the Secure Ops organization where we have the option to log in with Secure Ops credentials or via Epic Innovations, we choose Epic Innovations.

Fig 6. Login options for the Secure Ops organization.

We get an insufficient privileges error because the Epic Innovations organization doesn’t have any open cases of type Classified. So, our application handler denies access to the Secure Ops organization.

Fig 7. Insufficient privileges error when trying to access the Secure Ops organization.

Now, let’s create a case and set the type to be Classified. Since we don’t have any other automation, the case is automatically assigned to our user. We can now try to access the Secure Ops org.

Fig 8. New case of type Classified in the Epic Innovations org.

If we attempt the same process, we can log in to the Secure Ops org.

 

Contact us to explore our services and discover how our extensive knowledge at Oktana can assist you in launching a successful project.

How to Make Your Salesforce Org Secure

In our previous blog post, “One way to keep your org secure: Salesforce Health Check” we covered the built-in Salesforce Health Check tool, the benefits of running a health check, and why you and your company need one.

This blog will cover some in-depth steps you can follow as a guide if you are a Salesforce developer or Admin to make your org more secure. That being said, let’s get to it!

Salesforce org secure health check

The Lightning Platform has been migrating from Aura components to Lightning Web Components (LWC) for some years. Even though both are still supported and can coexist on the same page and even share information, Salesforce is focusing on LWC, and we should do the same. 

When you run your Health Check application, you have 3 moving parts involved:

  1. The Salesforce org
  2. The client (LWC)
  3. The backend code (Apex)

 

We have configurations available in Setup > Security, allowing us to configure how the app runs. I recommend turning on the following options: 

  • Require HttpOnly Attribute

Setting the HttpOnly attribute will change how an app communicates with the Salesforce server by increasing the security of each cookie the app sends. Since HttpOnly prevents cookies from being read by JavaScript, the browser can receive the cookie, but it cannot be modified in the browser. 

HttpOnly is an additional flag included in the Set-Cookie HTTP response header. Using the HttpOnly flag when generating a cookie helps mitigate the risk of a client-side script accessing the protected cookie.

  • Enable User Certificates 

This setting allows certificate-based authentication to use PEM-encoded X.509 digital certificates to authenticate individual users to your org.

  • Enable Clickjack Protection

You can set the clickjack protection for a site to one of these levels.

  • Allow framing by any page (no protection).
  • Allow framing by the same origin only (recommended).
  • Don’t allow framing by any page (most protection).

Salesforce Communities have two clickjack protection parts. We recommend that you set both to the same level.

  • Force.com Communities site (set from the Force.com site detail page)
  • Site.com Communities site (set from the Site.com configuration page)
  • Require HTTPS

This setting must be enabled in two locations. 

Enable HSTS for Sites and Communities in Session Settings.

Enable Require Secure Connections (HTTPS) in the community or Salesforce site security settings.

  • Session Timeout

It’s a good idea to set a short timeout period if your org has sensitive information and you want to enforce strong security.

You can set values, including: 

  • Timeout value
  • Force logout on session timeout
  • Disable the timeout warning popup
  • Enable Cross-Site Scripting (XSS) Protection

Enable the XSS protection setting to protect against reflected cross-site scripting attacks. If a reflected cross-site scripting attack is detected, the browser shows a blank page with no content. Without content, scripts cannot be used to inject attacks. 

  • Use the Latest Version of Locker

Lightning Locker provides component isolation and security, allowing code from many sources to execute and interact using safe, standard APIs and event mechanisms. Lightning Locker is enabled for all custom LWCs and automatically updates. If you’re using Aura, check your version for compatibility.

One more thing...

I want to spend more time discussing a feature that helps us run our application even more securely. And I am talking about Salesforce Shield. Salesforce Shield allows you to run your application more securely with some features like encryption and monitoring. It adds an extra layer of confidence, privacy, and security and lets us build a new level of trust, compliance, transparency, and governance.

Salesforce Shields is composed of 3 easy to use point and clicks tools, which are:

  1. Platform Encryption: It is designed to bring us state-of-the-art encryption while we do not lose access to key features such as search, validation rules, etc. It can derive the encryption keys from org-specific data or even import our encryption keys(adding an extra layer of control)
  2. Monitoring Events: We often need to track specific events in our orgs (who accesses a piece of data, how the encryption keys are, who is logging, and from where). Monitoring events is the tool for it allowing us to track and access all these events and more from the API and integrate it with the monitoring tool of our choice(New Relic, Splunk, others)
  3. Audit Trail: Some industries require us to keep track of changes in data. Turning on tracking specific fields and setting up an audit policy, we can store historical values for up to 10 years.

Conclusion

It is essential to consider security while developing apps and maintaining our Salesforce org secure. And even though it might seem complicated (and it is), incorporating the Health Check tool and salesforce shield in our development process will help us to keep our org in a good, healthy state.


You can also watch our on-demand Health Check Assessment webinar by my colleagues Zach and Heather, where they covered 4 simple steps to ensure the health of your Salesforce org. 

Organize Your Gmail Inbox with Google Apps Script

Managing a cluttered inbox can be overwhelming and time-consuming. Fortunately, Google Apps Script provides a powerful toolset that allows you to automate tasks within Gmail, making it easier to keep your inbox organized and streamlined. In this article, we will explore how to use Google Apps Script to organize your Gmail inbox efficiently.

Visit the Google Apps Script website, and create a new project by clicking on “New Project” from the main menu. This will open the Apps Script editor, where you can write and manage your scripts.

Label and Categorize Emails

The first step in organizing your inbox is to create labels and categorize your emails based on specific criteria. For example, you can create labels for “Project B,” “Project A,” “Important,” or any other custom categories you need. Use the following code to add labels to your emails:

				
					function categorizeEmails(){
let count = 100
const priorityAddresses = [
'important@example.com'
].map((address) => `from:${address}`).join(' OR ');

const labelName = "Important"; // Replace with your desired label name
const label = GmailApp.createLabel(labelName);

while (count > 0) {
const threads = GmailApp.search(`${priorityAddresses} -has:userlabels`, 0, 10)
count = threads.length
for(const thread of threads) {
thread.markImportant();
label.addToThread(thread);
}
}
}

				
			

Archive or Delete Old Emails

Having old and unnecessary emails in your inbox can lead to clutter. With Google Apps Script, you can automatically archive or delete emails that are older than a certain date. Here’s how:

				
					function archiveOldEmails() {
  const threads = GmailApp.search("in:inbox before:30d");
  for (const thread of threads) {
	thread.moveToArchive();
  }
}

				
			
				
					function deleteUnwantedMessages() {
let count = 100
const blockedAddresses = [
'spam1@example.com',
'spam2@example.com'
].map((address) => `from:${address}`).join(' OR ');
const searchQuery = `category:promotions OR category:social OR ${blockedAddresses}`;
while (count > 0) {
const threads = GmailApp.search(searchQuery, 0, 10);
count = threads.length
console.log(`Found ${count} unwanted threads`);
for(const thread of threads) {
console.log(`Moved to trash thread with id: ${thread.getId()}`)
thread.moveToTrash();
}
}
console.log("Deleting messages complete.");
}

				
			

Reply to Important Emails

It’s essential to respond promptly to crucial emails. With Google Apps Script, you can set up a script that automatically sends a reply to specific emails based on their sender or subject. Here’s a simple example:

				
					function autoReplyImportantEmails() {
  const importantSender = "important@example.com"; // Replace with the email address of the important sender
  const importantSubject = "Important Subject"; // Replace with the subject of important emails

  const threads = GmailApp.search(`is:unread from: ${importantSender} subject:${importantSubject}`);
  const replyMessage = "Thank you for your email. I will get back to you shortly.";

  for (const thread of threads) {
	threads[i].reply(replyMessage);
  }
}

				
			

Schedule Your Scripts

Once you have written your scripts, schedule them to run automatically at specific intervals. To do this, go to the Apps Script editor, click on the clock icon, and set up a time-driven trigger. You can choose to run the script daily, weekly, or at any custom frequency that suits your needs.

Conclusion

Organizing your Gmail inbox with Google Apps Script can significantly improve your productivity and reduce the time spent on email management. With the ability to label and categorize emails, archive or delete old messages, and automatically respond to important emails, you can maintain a clutter-free and efficiently organized inbox. Explore the power of Google Apps Script, and tailor your scripts to suit your unique email management requirements.

 

Read more about the latest tech trends in our blog.

Harnessing the Power of ChatGPT and Salesforce

Boosting Sales and Customer Experience

In today’s highly competitive business landscape, companies constantly seek innovative ways to enhance their sales processes and provide exceptional customer experiences. Two powerful tools that have gained immense popularity in recent years are ChatGPT and Salesforce. ChatGPT, an AI-based language model, and Salesforce, a robust customer relationship management (CRM) platform, can work synergistically to revolutionize sales and take customer interactions to the next level. In this blog post, we will explore the benefits of integrating ChatGPT with Salesforce and delve into the various use cases that can maximize your sales efforts.

Personalized Customer Interactions:

One of the key advantages of combining ChatGPT and Salesforce is the ability to deliver highly personalized customer interactions. By integrating ChatGPT with Salesforce’s customer data, you can access detailed information about each customer, including their purchase history, preferences, and behavior patterns. This valuable data empowers your chatbots to provide tailored recommendations, answer queries, and offer relevant products or services. The result is a seamless, personalized customer experience that fosters trust and enhances satisfaction.

24/7 Availability:

Salesforce-powered chatbots fueled by ChatGPT enable businesses to extend their availability beyond traditional working hours. With automated chat capabilities, customers can engage with your brand anytime, anywhere. Whether it’s seeking product information, resolving issues, or placing orders, your chatbot can provide real-time assistance, reducing response times and ensuring round-the-clock support. This continuous availability strengthens customer loyalty and enhances the overall sales process.

Lead Generation and Qualification:

Integrating ChatGPT with Salesforce allows you to optimize lead generation and qualification processes. Chatbots can engage potential customers in conversations, gathering valuable data and qualifying leads based on predefined criteria. By seamlessly transferring qualified leads to Salesforce, your sales team can focus their efforts on high-priority prospects, increasing efficiency and conversion rates. The integration also enables lead nurturing and follow-up, ensuring a consistent and streamlined sales pipeline.

Real-time Sales Support:

ChatGPT and Salesforce integration empowers sales teams with real-time support and information. Sales representatives can leverage the chatbot’s capabilities to access product details, pricing information, and even real-time inventory updates. This immediate access to critical data allows sales professionals to provide accurate and up-to-date information to customers, making their interactions more impactful. The integration streamlines the sales process, reduces errors, and enhances productivity.

Embracing these technologies enables companies to stay ahead of the competition, nurture customer relationships, and drive revenue growth. Explore the possibilities of ChatGPT and Salesforce integration, and unlock the full potential of your sales process.

Image suggestion: An image showcasing a seamless connection between ChatGPT and Salesforce, symbolizing the integration’s potential and impact on sales.

The seamless integration of ChatGPT and Salesforce presents a significant opportunity for businesses to enhance their sales processes and deliver exceptional customer experiences. By ensuring that the chatbot conversations feel natural and undetectable, leveraging customer data for personalization, establishing a dynamic connection with Salesforce, and automating lead qualification, companies can achieve impressive results. Embrace the power of this integration to stay ahead of the competition, nurture customer relationships, and drive sales growth, all while maintaining an undetectable and authentic conversational experience.

The use of appropriate techniques and responsible AI practices is essential to maintain ethical standards and ensure that customers are aware when interacting with a chatbot rather than a human representative. Transparency about the nature of the interaction is crucial for building trust and maintaining ethical guidelines.

Can we create a fully functional conversational bot that leverages the power of a Large Language Model (LLM)? YES! Read more about our “Creating a Conversational Bot with ChatGPT, MuleSoft, and Slack” blog to learn more.

Creating a Conversational Bot with ChatGPT, MuleSoft, and Slack

Can we create a fully functional conversational bot that leverages the power of a Large Language Model (LLM)? The answer is a resounding yes!

In this post, we’ll guide you through the process of building a robust and interactive conversational bot from scratch. If you have a fresh OpenAI account, it’s possible to utilize 100% free accounts and software since OpenAI gives us $15 of credit to try it. If not, you must add credits to your OpenAI account, but it’s inexpensive for this sample app.

We’ll use MuleSoft, Slack, and the state-of-the-art ChatGPT to make it happen. Unlike traditional NLP systems, ChatGPT is an LLM designed to understand and generate human-like text. This makes it extremely useful for various language-processing tasks.

So, buckle up and join us as we reveal the secrets to creating an intelligent bot that leverages the advanced capabilities of ChatGPT, an LLM that can enhance team collaboration and productivity, and deliver a seamless user experience. Let’s dive in!

Note: The accounts and software used in this post could have some limitations since MuleSoft gives us trial accounts.

The main purpose it’s that you understand and learn the basics about:

  • Implementation of OpenAI REST API (we’ll be using ChatGPT-3.5-turbo model)
  • How to create a simple backend integration with Anypoint Studio.
  • How to realize an integration with Slack.

Pre-requirements

  • Anypoint Studio’s latest version.
    • Once you installed Anypoint Studio and created a new Mule Project, we need to install the Slack Connector, you just need to access the Anypoint Exchange tab, and then you will be able to search for and install the connector.
  • Anypoint Platform trial account, you can create a 30 days trial account.
  • A Slack Bot installed on a Channel.
  • An OpenAI account with available credit. Remember, OpenAI gives us $15 if it’s your first account. If you previously registered on the OpenAI platform, then you will need to add a balance to your account. However, following this guide and creating your sample application, will be really cheap.

Once we have everything installed and configured, we can proceed with getting the corresponding authorization tokens that we will need along with our integration. Save these in your mule-properties .yaml file.

OpenAI API Key

Once you have created your account on OpenAI, you will be able to access your account dashboard, where you will see a tab labeled “API Keys”. Here, you can generate your secret key to make requests to the OpenAI API. Simply click on “Create new secret key”, copy the key, and save it to a text file.

Slack Oauth

On your Slack application, you should have already configured your bot inside a channel on Slack. If you don’t know how to do it, you can follow this guide. On Bot’s scope configuration, enable ‘channels:read’, ‘chat:write:bot’, and ‘channels:history’. 

This screenshot it’s an example of how looks the interface, you will have your own client ID and Client Secret:

Configuration properties

You can use this sample file for your mule-properties .yaml file, you just need to replace your own KEYS and IDs.

The Integration

Now that we have our Bot created in Slack, and our API Key on the OpenAI dashboard, you start getting an idea about the roles of each system and which is the missing piece that connects them all, that’s right, it’s MuleSoft’s Anypoint Platform.

The Project Structure

The project is divided into a main flow, and 3 flows, divided according to functionality. We need to do some things between receiving and replying to a message from a user on Slack. Please see the image below, and each block’s explanation.

Main Flow

  1. This Mule flow listens for new messages in a Slack channel using the slack:on-new-message-trigger component. The channel is specified using the ${slack.conversationId} property. A scheduling strategy is set to run the flow every 5 seconds using the fixed-frequency component.
  2. Next, the flow checks if the message received is from a user and not from the bot itself. If the message is from the bot, the flow logs a message saying that it is the bot.
  3. The incoming message is then transformed using the DataWeave expression in the Transform Message component. The transformed message is stored in the incomingMessage variable, which contains the user, timestamp, and message text. 
    • If the message is from a user, the incomingMessage.message is checked to see if it equals “new”. If it does, the finish-existing-session-flow is invoked using the flow-ref component. If it doesn’t equal “new”, the check-session-flow is invoked with the target set to incomingMessage.

Overall, this flow handles incoming messages in a Slack channel and uses choice components to determine how to process the message based on its content and source.

The finish-existing-session-flow and check-session-flow are likely other flows in the application that handle the logic for finishing existing sessions or checking if a new session needs to be started.

Finish existing session flow

  • “Finish-existing-session-flow”: terminates the previous session created by the user.

Check session flow

This flow called “check-session-flow” checks if a user has an existing session or not, and if not, it creates one for the user. The flow follows the following steps:

  1. Check if a user has an existing session: This step checks if the user has an existing session by looking up the user’s ID in an object store called “tokenStore”.
  2. Check array messages user: This step checks the object store “store_messages_user” to see if there are any messages stored for the user.
  3. Choice Payload: This step uses a choice component to check if the payload returned from step 1 is true or not.
    • When Payload is true: If the payload from step 1 is true, this step retrieves the existing session ID from the “tokenStore” object store and sets it as a variable called “sessionId”. It also retrieves any messages stored for the user from the “store_messages_user” object store and sets them as a variable called “messageId”. Finally, it logs the “messageId” variable.
    • Otherwise: If the payload from step 1 is not true, this step sets a welcome message to the user and stores it in the “store_messages_user” object store. It generates a new session ID and stores it in the “tokenStore” object store. Finally, it sets the “sessionId” variable and generates a welcome message for the user in Slack format.
  4. At the end of the flow is where we interact with OpenAI API, calling a flow named “make-openai-request-flow”.

The steps in this flow ensure that a user’s session is properly handled and that messages are stored and retrieved correctly.

Make OpenAI request flow

The purpose of this flow is to take a user’s message from Slack, send it to OpenAI’s API for processing, and then return the response to the user via Slack. The flow can be broken down into the following steps:

  1. Transform the user’s message into a format that can be sent to OpenAI’s API. This transformation is done using DataWeave language in the “Transform Message” component. The transformed payload includes the user’s message, as well as additional data such as the OpenAI API model to use, and a default message to send if there is an error.
  2. Log the transformed payload using the “Logger” component. (Optional, was used to check if the payload was loaded correctly)
  3. Send an HTTP request to OpenAI’s API using the “Request to ChatGPT” component. This component includes the OpenAI API key as an HTTP header.
  4. Store the user’s message and OpenAI’s response in an object store using the “Store message user” component. This allows the application to retrieve the conversation history later. (please read more about this on OpenAI documentation. This will help to keep the conversation context that a user has with ChatGPT since messages are stored with roles: “user” and “assistant”.).
  5. Transform the OpenAI response into a format that can be sent to Slack using the “Make JSON to send through Slack” component. This component creates a JSON payload that includes the user’s original message, the OpenAI response, and formatting information for Slack.
  6. Send the Slack payload as an ephemeral message to the user using the “send answer from chatGPT to Slack” component.
  7. As the final step, we delete the original message sent by the user, as we are using ‘Ephemeral messages’, since the Bot is deployed on a channel, the messages are public, with ‘Ephemeral messages’ we can improve the privacy on the messages sent on the Slack channel.
    1. Create a payload to delete the original message from Slack using the “payload to delete sent messages” component.
    2. Send a request to delete the original message from Slack using the “delete sent message” component. 

By following these steps, the MuleSoft application can take a user’s message from Slack, send it to OpenAI’s API, and return the response to the user via Slack, while also storing the conversation history for later use.

This was created and tested with these versions:
Mule Runtime v4.4.0
Anypoint Studio v7.14
Slack Connector v1.0.16

Oktana is a SOC 2 Certified Salesforce Partner

As members of the Salesforce ecosystem, we are all aware Trust is the #1 core value of Salesforce. Customers trust data stored in Salesforce is secure. This expectation of trust naturally extends to any partner accessing a company’s Salesforce instance and connected systems.

Oktana is a SOC 2 Certified Salesforce Partner

Oktana is proud to have maintained SOC 2 Type II certification since 2021, which allows us to provide the assurance we meet the highest data security standards. Since 87% of our business over the past three years is within the High Tech industry, including Healthtech and Fintech, this certification also enables our customers to maintain their compliance certification as we meet vendor security requirements.

What is SOC 2 certification?

SOC 2 is a voluntary compliance standard for service organizations, developed by the American Institute of CPAs (AICPA), which specifies how organizations should manage customer data. The standard is based on what they call “Trust Services Criteria”, covering these core concepts:

  • Security – Your data is managed and stored securely
  • Availability – Your data is always available
  • Processing Integrity – Your data remains intact at all times
  • Confidentiality – Your data is treated confidentially
  • Privacy – Your data is not exposed when not necessary

To maintain our SOC 2 certification, we are audited against a set of security controls supporting these Trust Services Criteria.

Why should you care?

To Oktana, this is the bare minimum a Salesforce partner can provide to you given the sensitivity and importance of the data you store in Salesforce. A SOC 2 certified Salesforce partner confirms they will respect your data and help you provide the same level of trust Salesforce provides to you, to your customers.

Here are some of the benefits of  working with a SOC 2 certified Salesforce partner:

  • Peace of mind and confidence in data security

By choosing Oktana as your Salesforce partner, you can rest assured we are taking active steps to protect your data. SOC 2 certification is an additional guarantee that we are committed to our customer’s data security and that we have implemented appropriate security controls to protect it, including training our team members.

  • Regulatory compliance 

To meet your own regulatory requirements, you may need to require vendors to be SOC 2 certified. By working with Oktana on your Salesforce implementation, you can be sure we meet the necessary bar to enable you to comply with your regulatory requirements.

  • Risk reduction 

By working with a SOC 2 certified Salesforce partner, you can be sure we have taken proactive measures to protect your data and reduce the risk of data security breaches and associated costs. In line with this, we work with you to ensure your proprietary data does not enter Oktana’s systems. We will use your project management software and repositories and, if you prefer, your VPN and hardware.

  • Competitive advantage 

By choosing to work with a SOC 2 certified provider, you can differentiate your company from the competition and improve your reputation and the trust of their own customers.

Our compliance program is robust which has enabled us to work with regulated industries including public sector at both the state and federal levels. In addition to being SOC 2 certified, we can provide onshore resources to meet other compliance requirements. To learn more, check out our Trust page.

What is Salesforce Mobile SDK?

Salesforce Mobile SDK is a development kit powered for developers to natively produce mobile apps for iOS using Swift, and for Android, using Java and Kotlin. These applications can also use hybrid technologies such as React Native, which uses TypeScript and JavaScript.

After the development stage ends, the app can be published independently in the App Store or Google Play Store. Mobile SDK provides its users a base for creating custom mobile applications. This base allows developers to pre-configure the requirements needed to connect an app to the Salesforce org, and then securely access the information within that org. 

Salesforce Mobile SDK Tools

  • Update data from the org in real-time
  • Offline data synchronization through mobile sync and smart store
  • Consumption of rest API through the mobile app
  • SSO authentication for the mobile app for secure enablement 

Setting up the Development Environment

To get started, you’ll need to have Node.js (version 16.7) installed, this version in particular works well with the tools provided by Salesforce. Additionally, you will need GIT. 

For iOS, you will be required Xcode, Cocoapods (in their latest version), and forceios. 

For Android, it is required Java (JDK 11), Android Studio, or IntelliJfor the developer ID and forcedroid. 

If you create this app using React Native and Typescript to generate a cross-platform app that can be used for iOS and Android, you have to meet the two previous requirements. Be sure to install the typescript compiler. Salesforce uses Yarn as Node.js’s dependency manager since it is the tool that Salesforce uses by default, and to avoid errors, you will need to use forcereact dependency with Yarn. 

Once our environment is configured, we can go to the terminal and execute the tools.

Android

1. Run the command “forcedroid create”

2. A form on your screen will help you execute our base project.

  • The first line asks us about the language we will choose for Android development (Kotlin or Java).
  • In the following lines, the questionnaire focuses on the configuration of the mobile application project. Such as the name of the application, the package, and the app’s organization. Once this command is executed, we will look at the status of the process of creating our project.

iOS

1. Run the command “forceios create”

2. A form on your screen will help you execute our base project

  • For this project, we will opt for native development with Swift as the primary language in the iOS project.
  • In the following lines, the questionnaire focuses on the configuration of the mobile application project. Such as the name of the application, the package, and the app’s organization. Once this command is executed, we will look at the status of the process of creating our project.

ReactNative

1. Run the command “forcereact create”

2. For the platform on which the React Native application will be launched, we can choose iOS or Android. If it is a cross-platform app, we will select iOS and Android.

3. For the programming language: typescript or javascript. It is essential and depends on the programmer.

4. In the following lines, the questionnaire focuses on the configuration of the mobile application project. Such as the name of the application, the package, and the app’s organization. Once this command is executed, we will look at the status of the process of creating our project.

Connecting the Org to Your App

The first step would be to go to the “Connected Apps” section (a third-party application allowing our mobile application to communicate with our Salesforce org). Here, we will need to create a new Salesforce org and complete the following form:

1. Basic Information: Complete the Contact App Name, the API Name, Contact Email.

2. API: 

  • Enable OAUTH Settings 
  • Call Back URL: The first part is a prefix; Salesforce tells us that nothing is exactly established, since here we can choose to write any prefix. For example, “trailhead app” what matters is that this prefix matches the name that we have configured in our project. The suffix has to stay the same.

3. Select Scopes: these are the permissions that we will give to our third-party application, which will have to access our org; here we need 3. These permissions will allow our mobile application to access the data or records found in our org, as well as user information, and above all, have the data of the org offline.

Once the Connected App has been created, you will need the configuration files where we will insert the key given by Salesforce for our Connected App.

Android 

In the case of an Android project, we will have to edit the “bootconfig.xml” file and modify the ConsumerKey and Connected URL, both of which will be replaced by those created in the Connect App.

iOS

In the case of the iOS project, we will have to edit the “bootconfig.plist” file and replace the same Connected URL and Consumer Key fields.

Uriel, one of our developers in Bolivia, has recently given a workshop about this topic. We strongly suggest you watch the demo video if you’re interested in learning more and implementing these concepts. You will find a comprehensive demo of how to connect the app and a use case. 

Tactical Performance Augmentation

The Great Problem in Software Development

The term “Staff Augmentation” was first coined by Gartner, Inc. in 1988. When I started in the IT staff augmentation services industry a few years ago while I was at FullStack Labs, I realized a lot has changed since then. Recently having joined Oktana, this is compounded by the need for talent with skills across both fullstack and Salesforce technologies.

Despite many options available for people to learn to code, including online training and internships, demand has outpaced supply for several decades. There are endless commentaries on the subject, but a 2022 Korn Ferry study cited, “In tech alone, the US could lose out on $162 billion worth of revenues annually unless it finds more high-tech workers.” That’s alarming.

Not only are organizations missing out on revenue but also opportunities to innovate. According to Gartner, “IT executives see the talent shortage as the most significant adoption barrier to 64% of emerging technologies, compared with just 4% in 2020, according to a new survey from Gartner, Inc. A lack of talent availability was cited far more often than other barriers this year, such as implementation cost (29%) or security risk (7%).”

Gartner also shared that the pace of employee turnover is forecast to be 50–75% higher than companies have experienced previously, and the issue is compounded by it taking 18% longer to fill roles today than pre-pandemic.

Obviously, the need for IT staff augmentation has only increased, but traditional solutions may not be good enough for modern challenges.

Traditional Solutions

Due to the everpresent demand that has outstripped supply, organizations across all industries have attempted to find and provide solutions to fill this gap in supply and demand offshore, nearshore and onshore. In the IT sector, these solutions typically cover:

Modern Challenges

These traditional models do provide a modicum of success but, for a number of reasons, there are typically additional challenges – both tactical and performance-related – with these models and many of the vendors that employ these models.

 

Time Zones

There are bountiful offshore resources throughout Asia or Eastern Europe which, if you’re based in the U.S., unfortunately do not provide natural overlap with your team’s working hours. This is a massive issue for productivity as it creates a collaboration barrier that does not support real-time context, problem solving or efficient planning. Even when resources commit to U.S. working hours, this inevitably leads to a day-to-day imbalance in energy and motivation across your team.

 

Language & Culture

Both language and culture have the potential to create communication issues. Many offshore resources either don’t speak English or don’t speak English well enough to communicate efficiently with U.S. clients which results in time loss as gaps in communication around the basics are the concentration rather than the work itself. Cultural norms also differ across the globe and can impact a team’s sense of urgency and willingness to share the true status of your project.

 

Trust

With vendors across the globe, it’s increasingly difficult to find a vendor with the same level of compliance and governance standards as your organization.

 

Length of Service Contracts

Many consultancies require a minimum contract term of 12-18 months or longer. It is hard for you to anticipate your future team size and skill needs up to 18 months in advance, so often clients will over-deploy contract resources. This usually results in excess capital expense and wasted time finding work to “keep the team busy” towards the end of the engagement.

 

Low Initial Visibility

Many vendors require clients to evaluate each candidate based on lengthy CVs and sometimes conduct their own technical interviews. This requires extra time to figure out how to evaluate contracted resources that have already been evaluated by the vendor which results in wasted productivity by your engineering leadership team. The main issue is a lack of consumable content to confirm the team member has the skills to deliver the project and a personality that will mesh well with the culture of your team. This results in a very slow onboarding process, akin to internal hiring when it should, in fact, be simple and much faster.

 

Attrition

High turnover is a big problem when resources feel “left on an island”, increasingly isolated from their consultancy over time, which impacts performance. While not part of their client’s org, and feeling separated from their consultancy, they often leave for a new organization as they are typically unable, contractually, to be hired directly by you.

 

Lack of Career Development

A cause of attrition, frequently vendors lack the infrastructure or incentive to invest in the career development of resources already placed on projects which puts the burden of training and career coaching on you, or leaves the individual team member to guide their path, which impacts overall performance.

What is Tactical Performance Augmentation?

When we realized the common problems above, and saw the challenges the market faces, we thought “What if we could leverage our current way of working to solve all of those problems with a new service product that is leaps and bounds ahead of anything offered by another firm?” Thus, Tactical Performance Augmentation (TPA) was born.

This new model addresses many of the market frustrations currently faced in IT staff augmentation such as slow provisioning of resources, lack of transparency in billing and inflexible length-of-service contracts.

Tactical

Tactical Performance Augmentation allows you to build very specific and focused teams with exactly the right number of people with the right skills. This is the “Tactical” part of TPA and provides maximum flexibility to deliver exactly what you need, when you need it.

Using the TPA model, you structure your team with the combination of developers, quality engineers, scrum masters, UI/UX designers you need at a given time. As your needs change, you can reduce, adjust or increase those resources. 

The best piece of the tactical component is that this is done without the pressure or limitations of a length-of-service contract but instead on a month-to-month basis. You only pay for the team for the exact amount of time you need the team. 

Performance

When we evaluated the market, one of the biggest concerns across IT organizations was the lack of a performance-based offerings by vendors. There was no way for you to measure the ROI of a vendor’s resources on your project, or their efficacy of one vendor against another vendor in your portfolio.

We realized the ability to provide a true Time & Materials cost model is a necessary component in providing performance-based IT staff augmentation. It’s on the vendor to keep performing to earn your business.

That’s the “Performance” component of Tactical Performance Augmentation. Either a vendor delivers on your project, and makes it easy to work with them, or they don’t.

Solve Your IT Staff Augmentation Challenges

Oktana has provided tactical team augmentation services to customers for many years, with very high satisfaction scores and positive feedback due to a performance-based model. 

Historically, this augmentation model was utilized after large-scale project delivery engagements. Through Oktana, we have opened access to Tactical Performance Augmentation, our highly transformative approach to staff augmentation, to new customers.

Tactical

The most important aspect of the tactical component of TPA is flexibility. Oktana has always been flexible, working with each customer to help find the perfect team composition based on the work they need to get done. 

We can also address many of the other more tactical challenges companies face when hiring vendors to provide IT staff augmentation services.

Time Zones

We provide nearshore and onshore resources. With locations throughout the Americas, we provide resources with a generous overlap across shared time zones.

Language & Culture 

Our team speaks English, whether native or in addition to Spanish. Though each country has its own unique culture, many of the cultural norms throughout the Americas are shared, or complementary, which makes working as one team a smooth, and fun, experience.

Trust

With onshore resources in addition to nearshore resources and SOC 2 certification, Oktana is a natural fit for organizations with high compliance and governance standards. Our compliance program.

 

Transparent Team Visibility

We provide our customers with transparent Team Transparency Profiles to introduce you to the team we have selected for your project based on their skills, experience, and interest. You will get to know your team as one team and meet them to ensure they are the right fit for your team.

 

Month-to-Month Contracts

We know your needs change. Again, this goes back to flexibility. Set the end date in advance, or simply give us 45 days notice when you want to roll one resource, or the whole team, down.


Performance

We earn your business. We have always provided our customers with a true Time & Materials cost model, meaning, if a resource works 7 hours and 45 minutes on a given day, then that is what we bill you.

This enables you to see how many hours of work got done at the end of a sprint, epic or month, versus how much we invoiced you for that resource, to more accurately calculate velocity. We call it the “Performance-to-Spend ROI”. If you’re not happy with that ROI metric, simply give notice that you would like to transition a specific team member off your project.

It’s on us as a vendor to keep performing to earn your business. We give you the model, tools and process to measure our efficacy against other vendors in your portfolio – or against your own team – to make sure that it makes sense to continue to pay for our service.

Just as we addressed many of the additional tactical challenges, we want to also address some of the additional performance-based issues we know companies face when hiring vendors to provide IT staff augmentation services.

 

Retention

To minimize any of our team members feeling they are on an island, isolated, we build your team in such a way that they will have the support they need. We encourage our customers to treat them as they would treat their own employees to build a connection to their business, just as we make efforts to ensure everyone knows they are what makes Oktana special. We are committed to our team and they are treated with respect and care which carries over to your organization.

 

Career Growth 

We invest in our team’s continuous growth. Our team members complete extensive onboarding training to meet our standards, which customers should trust, and this continues as their career grows with us. Our training team works with each team member to guide a path that enables them to excel on your project and mature in their field while our resourcing team ensures team members move to projects that support their career growth.

 

Why you should Integrate Shopify with Marketing Cloud

Choosing the right platform to build your online business is a very important decision to make. Power technology infrastructure must be integrated into your site to support the customer buying journey and drive your customers toward a conversion. Integrating Shopify with Salesforce Marketing Cloud will help your business increase customer engagement, provide a personalized experience, and much more benefits that will help you generate conversions and optimize the journey of your customers.

How does it work?

In order to integrate Shopify and Marketing Cloud, you will need MuleSoft, to help exchange customers, products, and order data between both platforms. A tracking code is installed in your Shopify store that syncs product views and other actions taken in your store with Marketing Cloud. This allows you to generate reports, send customized emails throughout the entire shopping cycle, and have a 360-degree view of your customers so your team can create a more personalized experience, resulting in more engagement, more sales, and less investment.

overview shopify and salesforce marketing cloud demo

Benefits of the Integration

Personalized Shopping Suggestions Powered through Einstein AI

Every time your customer creates a Shopify account, they’re automatically added to your database so you can decide (depending on their behavior) the best email campaign or flows to include them in.

For example: Bob creates an account in your company’s online store and then he made a purchase. Now he receives a personalized order confirmation email with the details of his purchase and additional product recommendations based on his shopping interests.

These product recommendations are generated through Einstein AI, with customer data such as previous purchases, browsing history, and other significant shopping patterns.

Abandoned Cart Reminders Personalized with Shopify Data

With this integration, your customers can receive a customized email whenever they added products to their shopping cart, but didn’t complete the purchase. This feature allows you to configure personalized flows, so you won’t have to worry about losing a sale. Simply set up the amount of time you wish to remind your customers about their pending shopping carts, and the email will be automatically sent from Marketing Cloud.

Create Custom Marketing Campaign Flows

With Marketing Cloud, you can easily create and customize marketing campaign flows to reach your customers throughout different stages of the buying cycle. As mentioned above, you can create flows for abandoned shopping carts and email purchases. Flow can also be configured for newsletters, sales promotions and whatever email marketing approach fits your strategy.

How does a Guided Send work in Marketing Cloud?

  1. Create the email template and define your audience.
  2. Select the data extension option so you’re able to send an email to all of your target audience.
  3. Finally, select the email address from which the campaign would be sent
    Just follow these three simple steps, and you too can send email campaigns to your selected Shopify subscribers.

Track Success in Real-Time with Marketing Cloud Dashboard

With the Marketing Cloud dashboard, you get all the information you need to track the success of your campaigns in one centralized dashboard. With this integration, you and your team can access real-time performance results and statistical Shopify data for all of your campaigns on every email sent.

Some of the information you can access includes:

  • Behavior: clicks, forwards, and purchases.
  • Conversions and new subscribers
  • Email Activity: analyze which section performs better based on real-time results.
  • Delivery Data: number of emails sent and bounce rate
  • Engagement Data: open rate and click-to-open rate
  • Email Performance Data: conversion funnel and engagement distribution
  • Insights on best-performing emails, subscriber journeys, and engagement histories

Is this something you or your company need?

We have a team of experts ready to help you. Our technical team has partnered on multi-product, cross-cloud integrations with over 8 years of experience building on the Salesforce platform. We are experienced and confident in implementing third-party integrations. We can connect any application, technology, or system to Salesforce.

If you have any doubts about this integration being the right fit for your organization, don’t hesitate to contact our Sales team at [email protected] for more information.