Integrate Salesforce Einstein

Content on this page is for a product or feature in controlled release (CR). If you are not part of the CR group and would like more information, contact your CXone Account Representative.

Before completing the tasks on this page, be sure that the prerequisites for the integration have been met.

Create a Script

Permissions Required: Studio Script View, Create/Edit

You need to create at least one Studio script to route interactions to your virtual agent. Follow the script guidelines and requirements. The supported virtual agent action for this provider is Textbot Exchange and your script must have the digital media typeClosed A medium, such as voice, email, and chat, through which a contact connects with an intended recipient..

You can learn more about Studio scripting in the Fundamentals and Technical Reference Guide sections of the online help.

When your virtual agent is ready to go into production, assign the script to one or more points of contact.

Generate a Certificate and Keys

You will use the certificate and keys during the integration setup process. To complete this task, you must have OpenSSL installed.

  1. Using a command line utility, navigate to the directory where you want to create the files.
  2. Type the command openssl and press Enter.
  3. Type the following commands one by one. Press Enter after each one: 
    • openssl genrsa -out private-key.pem 3072
    • openssl rsa -in private-key.pem -pubout -out public-key.pem
    • openssl req -new -x509 -key private-key.pem -out cert.der -days 360
  4. Check the specified directory to verify that you have the following files: 
    • cert.der
    • private-key-pem
    • public-key.pem

Create and Configure a Salesforce Connected App

Follow these steps to create a connected app in Salesforce Lightning. Connected apps allow Salesforce to integrate with external applications, such as CXone.

  1. Log in to Salesforce using an account with administrative privileges.
  2. Create a connected app: 
    1. Go to Setup and search for App Manager in the quick find search bar on the left side of the page.
    2. In the App Manager, click New Connected App.
    3. Complete the Basic Information section on the Manage Connected Apps page.
    4. Under API (Enable OAuth Settings), select Enable OAuth Settings.
    5. Select Enable Digital Signatures, then click Choose File and upload the certificate that was created when you generated the JWT.
    6. From the Selected OAuth Scopes list, add the following scopes: 
      • Access Connect REST API resources (chatter_api)
      • Access Chatbot services (chatbot_api)
      • Perform requests at any time (refresh_token, offline_access)
    7. Click Save.
  3. Configure OAuth policies and add an administrator profile for the app you just created: 
    1. Under Platform Tools in the menu on the left side of the page, click Apps > Connected Apps > Manage Connected Apps.
    2. Select the app you created.
    3. Click Edit Policies.
    4. Under OAuth Policies, select Admin approved users are pre-authorized from the Permitted Users drop-down.
    5. From the IP Relaxation drop-down, select Relax IP restrictions.
    6. Save your changes.
    7. On the same page, scroll down to Profiles and add a System Administrator profile.
  4. Enable Manage Consume Details to get the keys: 
    1. Under Platform Tools in the menu on the left side of the page, click Apps > Connected Apps > Manage Connected Apps.
    2. From the drop-down list for the Manage Authentication app, click View.
    3. Under API (Enable OAuth Settings), click Manage Consumer Details. Salesforce sends an email with a verification code to the email address used in your Salesforce account.
    4. Enter the code in the Verify Your Identity window.
    5. Copy the keys, which appear under Consumer Details.

Connect Salesforce Einstein with the Connected App

After creating the Connected app in Salesforce, you need to connect it to Salesforce Einstein.

  1. In Salesforce Einstein, select Overview from the drop-down in the upper left corner of the page.
  2. Under Connections, click Add.
  3. On the Add Connection window, select API from the Connection drop-down.
  4. Enter an Integration Name.
  5. Select the name of the Connected App you created in the previous task.
  6. Make a note of the URL listed under Runtime Base URL. You need this information in a later task.
  7. Click Save.

Generate a JWT Bearer Token

You must generate a JSON Web Token (JWT) to use with your integration. These steps describe one method of generating the token. If you have a different, preferred method, use that with the parameters as defined in the following steps.

  1. Open your web browser and go to the jwt.io website A square with an arrow pointing from the center to the upper right corner..
  2. From the Algorithm drop-down, select RS256.
  3. In the Payload field, add the following details in JSON: 
    • iss: Enter the OAuth client_id for the connected app you created the certificate for.
    • aud: The authorization server is the intended audience. Use one of the following URLs: 
      • https://login.salesforce.com

      • https://test.salesforce.com

      • https://site.force.com/customers (if implementing for an Experience Cloud site)

    • sub: The username of the Salesforce Agent user that's generating the token, if implementing an Experience Cloud site. For backward compatibility, you can use principal (prn) instead. If both sub and prn are included, prn is used.

    • exp: The expiration time of the JWT. Enter the time as the number of seconds from 1970-01-01T00:00:00Z UTC. The time used can be accurate to within three minutes of the actual expiration time.

  4. Paste the contents of the public-key.pem and private-key.pem files into the fields under Verify Signature. These are two of the files you downloaded when you created the certificate.
  5. Click Share JWT to copy the JWT to your clipboard.

Test with Postman

After generating your token, you can use Postman A square with an arrow pointing from the center to the upper right corner. to test the authorization functionality, if you want. If you choose to do this, use the following information in your request: 

  • Verb: POST
  • URL: https://login.salesforce.com/services/oauth2/token
  • Body: Add the following key-value pairs: 
    • "grant_type" : "urn:ietf:params:oauth:grant-type:jwt-bearer"

    • "assertion" : "{your bearer token}"

When you receive the authorization token, send a POST request to the Einstein virtual agent to test its ability to respond. Use the URL for your instance of Salesforce. An example of the request is shown in the following image.

Add an App to Virtual Agent Hub

Permissions Required: Automation & AI > Launch Automation & AI Studio Script View, Create/Edit

Adding a configuration app to Virtual Agent Hub establishes the connection between CXone and your virtual agent provider.

  1. In CXone, click the app selector and select Other > Automation & AI and then click Virtual Agent Hub. You can also double-click the virtual agent action in your Studio script to launch Virtual Agent Hub.
  2. Click Add Bot.
  3. Enter a Virtual Agent (Bot) Name and click Salesforce Einstein in the list of virtual agent providers.

  4. Click Next.

  5. Complete the fields in the configuration form and click Next. You can find details about this form in the Configuration Page Details section on this page.

  6. Click Next.

  7. Select Text Only (No Voice Support) on the Voice page.

  8. Click Next.

  9. On the Transcript page, select the option for whether you want the conversation transcript and intent information captured.

  10. Click Next.

  11. On the Test + Add page, you can test your bot's connection by sending voice or text prompts. If your test messages don't work, click Back to return to the Configuration page and verify the settings. You may also need to verify configurations in your virtual agent provider's management console.

  12. Click Add.

Salesforce Einstein Configuration Page Details

Use the information in the following table when completing the Configuration page. You see this page when adding an app in Virtual Agent Hub

Assign the Salesforce Einstein App to an Action

Permissions Required: Studio Script View, Create/Edit

When the virtual agentClosed The meaning or purpose behind what a contact says/types; what the contact wants to communicate or accomplish app is set up and configured in Virtual Agent Hub, you need to assign it to the virtual agent action in your script. This connects the action and the script to your virtual agent provider.

  1. In Studio, open the script you want to modify.
  2. If you haven't done so already, click the Tools tab, expand the Automation and AI category, and add the virtual agent action you want to use. Be sure to put it in the correct location in your script. If you don't see the action you expect, verify that your script media type is correct. For example, if you're creating a script for a voice virtual agent, the script must be a phone script.

  3. Double-click the action to open Virtual Agent Hub.

  4. In the left column, locate the virtual agent that you want to assign to the action and click the checkmark An icon of a circle with a checkmark inside. next to it.
  5. Click Close.

Test Your Virtual Agent Connection

Permissions Required: Automation & AI > Launch Automation & AI Studio Script View, Create/Edit

You can test many aspects of your virtual agent to make sure everything works as intended. You can run tests from the virtual agent app's properties page in Virtual Agent Hub. When testing, you can: 

  • Verify that the virtual agent app is correctly configured to communicate with the virtual agent provider.
  • Add custom payload JSON to test the virtual agent's handling of custom payload data.
  • Trigger a welcome intent event to test how the virtual agent begins a conversation.
  • Trigger a custom intent event to test any custom events you've created for your virtual agent.
  • Trigger a timeout event to test how the virtual agent responds when the contact times out.

The following image is an example of the properties page for a virtual agent app in Virtual Agent Hub. It shows the Configuration and Voice tabs and the Test pane.

  1. In CXone, click the app selector and select Other > Automation & AI and then click Virtual Agent Hub. You can also double-click the virtual agent action in your Studio script to launch Virtual Agent Hub.
  2. Click to select the configuration app for the virtual agent you want to test from the list on the left.
  3. In the Test pane, enter a test message in the Type a message field and press Enter to send it. You can also click Microphone An icon shaped like a microphone. and speak into your computer's microphone.

  4. Click Start with welcome intent to start a test conversation from the beginning. The virtual agent responds with its default welcome message. You can enter test messages.
  5. Click More Options An icon with three dots stacked vertically. to test other aspects of your virtual agent.

  6. Click Reset to start your test again.
  7. If you need to make changes based on the results of your testing, you can: 

    • Modify the Studio scripts for the virtual agent.
    • Modify the configuration settings in the virtual agent's app in Virtual Agent Hub.
    • Modify the virtual agent's configuration settings in the provider's console. Click the large square button on the app properties page in Virtual Agent Hub. The example at the beginning of this section shows the Google Dialogflow CX app with the provider button. It has the An icon that has a square with an arrow overlaid on top of it. The arrow points from the center of the square to the top right corner of the square. icon on it to indicate that the link opens an external site.
  8. Test the virtual agent thoroughly after each change to your scripts or any configuration settings.
  9. When you're finished testing, click Close.