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:
- Add a Connected App to your Salesforce.
- Add the Salesforce Object Insert/Update app to your organization within Zingtree.
- On any node in your tree, have the app trigger to update or add a new object.
- 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:
- Login into Salesforce and navigate to Setup, Create, Apps.
- Under Connected Apps, click New.
- Fill in the mandatory fields.
- Check the Enable OAuth Settings box.
- In the Callback URL field, enter this URL:
- Under Available OAuth Scopes select:
Perform requests on your behalf at any time (refresh_token, offline_access)
Access and manage your data (api)
- Your OAuth configuration should look like this when finished:
- 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:
- Make sure you are logged into your Zingtree account.
- In Zingtree, go to Account, My Apps.
- Select the Salesforce Object Insert/Update app.
- Enter your Consumer Key and Consumer Secret from the previous task.
- 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.
Troubleshooting tip: Make sure you are logged in to just one Salesforce instance, or log out of all Salesforce instances if you get an error.
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.
- 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.
- Under Apps/Webhooks, select your new app Salesforce: Object Insert/Update.
- 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.
- Go To Setup, Build, Customize, Cases, Fields.
- Scroll down to Case Custom Fields, and add a new field.
- The Data Type should be Text Area (Long). Click Next.
- The Field Name must be Zingtree_Transcript. Other parameters are your choice. See this example:
Enter the other parameters, then click Next.
- Make the field read-only for all users, then click Next.
- 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:
In case things aren’t working as you expect, here’s what to look out for:
- Changes to your case may not be reflected right away. Sometimes reloading the case (refreshing the page) will show the updates.
- If a Zingtree variable starting with sf_ has no field name counterpart in Salesforce, then the update will fail.
- 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.
- 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: