salesforce and zingtree

Updated Dec. 23, 2019 for adding Salesforce Objects.

If you are launching Zingtree decision trees from within Salesforce, you have the ability to update Salesforce objects from any node of your tree. You can also add new Cases or other objects if you launch a decision tree outside of Salesforce.

The setup for both inserting and updating objects is the same. Here’s a summary of how to do it:

  1. Add a Connected App to your Salesforce.
  2. Add the Salesforce Object Insert/Update app to your organization within Zingtree.
  3. On any node in your tree, have the app trigger to update or add a new object.
  4. Any Zingtree variables that begin with sf_ will write to the corresponding field in Salesforce.

Also: If launching from within Salesforce, you’ll want to set up the Salesforce Agent Scripting app for Zingtree.

Adding a Connected App in Salesforce

To set up your Salesforce Connected App:

  1. Login into Salesforce and navigate to Setup, Create, Apps.
  2. Under Connected Apps, click New.
  3. Fill in the mandatory fields.
  4. Check the Enable OAuth Settings box.
  5. In the Callback URL field, enter this URL:
    https://zingtree.com/apps/salesforce/auth.php
  6. Under Available OAuth Scopes select:
    Perform requests on your behalf at any time (refresh_token, offline_access)
    Access and manage your data (api)
  7. Your OAuth configuration should look like this when finished:

  8. Click Save and make a note of the generated Consumer Key and Consumer Secret. These need to be entered in the next step.

Adding the Salesforce Object Insert/Update App

To add the App, do the following:

  1. Make sure you are logged into your Zingtree account.
  2. In Zingtree, go to Account, My Apps.
  3. Select the Salesforce Object Insert/Update app.
  4. Enter your Consumer Key and Consumer Secret from the previous task.

    Click Continue.

  5. Allow access to your Salesforce account. (You may need to log into the account first.)

The Salesforce: Object Insert/Update App will now appear in the list of Apps in My Apps.

Triggering a Salesforce Object Update

Once the App is installed in your organization, you can trigger a Salesforce update from any node in your tree when the tree is launched via Salesforce.

  1. Edit the node in Zingtree where you want the update to occur. When this node is reached by an end user, the updater app will trigger.
  2. Under Apps/Webhooks, select your new app Salesforce: Object Insert/Update.

  3. Click Save Changes.

If you are updating a Custom Object type, make sure the name of the custom object type is in the Message part of the App/Webhook call. So if you have a custom object called Medical Record, you would set up the webhook call like this:

Setting up Variable Names

As a part of your Zingtree session, you can collect data variables. Any variable that starts with sf_ will be used to update the corresponding field in Salesforce. For example, if you have a Salesforce field named description, a Zingtree variable named sf_description will be used to update that field.

Adding a Session Transcript

To include the Q&A history of the Zingtree session in a case field, you need to add a special field named Zingtree_Transcript to your Salesforce object. Here’s how to do it for Cases.

In Salesforce:

  1. Go To Setup, Build, Customize, Cases, Fields.
  2. Scroll down to Case Custom Fields, and add a new field.
  3. The Data Type should be Text Area (Long). Click Next.
  4. The Field Name must be Zingtree_Transcript. Other parameters are your choice. See this example:


    Enter the other parameters, then click Next.

  5. Make the field read-only for all users, then click Next.
  6. Pick the Case Layouts where this information will be displayed, then click Save.

Inserting New Salesforce Objects

When running your decision tree outside of Salesforce, the Insert/Update app will create a new object for you. The process is the same, except:

  • Be sure to add the Object type to the App Message Data. Like this:

Troubleshooting

In case things aren’t working as you expect, here’s what to look out for:

  1. Changes to your case may not be reflected right away. Sometimes reloading the case (refreshing the page) will show the updates.
  2. If a Zingtree variable starting with sf_ has no field name counterpart in Salesforce, then the update will fail.
  3. You can check the Zingtree Event Log (Account, Event Log) to see all operations with Salesforce. This will show successes and failed updates, with error messages in case of failure.
  4. If you get a “Requested Resource Does Not Exist” message when trying to update a custom object, make sure the name of the custom object type is in the Message Data part of the App/Webhook call. So if you have a custom object called Medical_Record, you would add Medical_Record__c to the Message Data in the webhook call, like this: