Kaizen #68 - Scoring Rules APIs[Part 1]

Kaizen #68 - Scoring Rules APIs[Part 1]

Hello everyone!
Welcome to another week of Kaizen!
This week we will discuss the Scoring Rules APIs.

What are scoring rules?

You may have different strategies to engage with customers, make their journeys successful in your business, and to convert them to potentials soon.
Scoring each lead based on certain criteria helps you determine who is likely to become a valuable potential.
These criteria or rules are called scoring rules.

When should you use scoring rules?

  • When there are multiple decision makers. In a B2B model where the sales cycle in the business model is long, it is important to have scoring rules for every touchpoint so that you can identify/track the deals with the highest conversion potential and move these deals quickly down the funnel.
  • In a multi-product and cross-selling business, you need to score leads based on the different products they are interested in, and then engage them in cross-products.
  • When you have multiple customer touchpoints. For example, your business may use strategies such as email campaigns, surveys, webinars, training sessions etc. Scoring the customers separately for each touchpoint gives you a more detailed insight into their interests and decide the best engagement strategy.
Note
  • You can configure scoring rules for Leads, Accounts, Contacts, Deals, and custom modules.
  • Scoring rules are layout-specific and each layout can have up to five rules.
For more details, refer to this help page.

Let us now understand how to configure a scoring rule, update, delete, and execute a scoring rule through APIs. 
Consider that you have configured Emails to use email insights and have integrated with Zoho Campaigns, Telephony, and Zoho Survey. You want to score the leads based on their responses to these touchpoints, besides scoring them based on their position in the company. 
Here is an example of how you can score based on the various touchpoints:
  • 10 points for opening an email
  • -5 when the email bounces
  • 10 points for responding to a survey
  • 10 points for opening a campaign
  • -10 for not responding to calls
  • 10 points when the Position is Decision Maker or Regional Manager
Here, scoring based on the custom picklist field "Position" is the field rule, while scoring based on the integration and insights is called the signal rule. 
Let us see how to achieve this through the Scoring rules API.

Create a Scoring Rule

Request URL: {api-domain}/crm/v4/settings/automation/scoring_rules
Request Method: POST
Scope: ZohoCRM.settings.scoring_rules.ALL/CREATE
Supported Modules: Leads, Contacts, Accounts, Deals, and custom

Sample Input

{
    "scoring_rules": [
        {
            "name": "Rule 2",
            "description": "Rule for Module Leads",
            "module": {
                "api_name": "Leads",
                "id": "3652397000000002175"
            },
            "layout": {
                "api_name": "Standard",
                "id": "3652397000000091055"
            },
            "active": false,
            "field_rules": [
                {
                    "score": 10,
                    "criteria": {
                        "group_operator": "OR",
                        "group": [
                            {
                                "field": {
                                    "api_name": "Position"
                                },
                                "comparator": "equal",
                                "value": "Regional Manager"
                            },
                            {
                                "field": {
                                    "api_name": "Position"
                                },
                                "comparator": "equal",
                                "value": "Decision Maker"
                            }
                        ]
                    }
                }
            ],
            "signal_rules": [
                {
                    "score": -5,
                    "id": "3652397000010473049",
                    "signal": {
                        "namespace": "EmailInsight_Bounce__s",
                        "id": "3652397000000112025"
                    }
                },
                {
                    "score": -10,
                    "id": "3652397000010473050",
                    "signal": {
                        "namespace": "Telephony_Missed__s",
                        "id": "3652397000000112027"
                    }
                },
                {
                    "score": 10,
                    "id": "3652397000010473051",
                    "signal": {
                        "namespace": "EmailInsight_Open__s",
                        "id": "3652397000000112021"
                    }
                },
                {
                    "score": 10,
                    "id": "3652397000010473052",
                    "signal": {
                        "namespace": "Survey_Responded__s",
                        "id": "3652397000000112029"
                    }
                },
                {
                    "score": 10,
                    "id": "3652397000010473053",
                    "signal": {
                        "namespace": "Campaign_Open__s",
                        "id": "3652397000000112031"
                    }
                }
            ]
        }
    ]
}

Key
Description
name
string, optional
Unique name of the scoring rule. Accepts up to 25 alphanumeric characters.
description
string, optional
Description of the scoring rule. Accepts up to 500 characters.
module
JSON object, mandatory
API name and ID of the module you want to create this rule in. Use the Modules API to get the module's API name and ID.
layout
JSON object, mandatory
The API  name and ID of the layout in the module you want to create the scoring rule on. Use the Layouts Metadata API to get this ID.
active
boolean, optional
Represents if you want to activate the scoring rule right after creation. The default value is true.
field_rules
JSON array, mandatory
The details of the fields and their values based on which you want to score the records.
score - integer - the score you want to assign
criteria - JSON object - the group that contains the field's API names, values and comparators, and the group operator(and, or). 
signal_rules
JSON array, optional
The details of the various signals raised through integrations and insights, and their scores.
score - integer - the score you want to assign
signal - JSON object - the namespace and ID of the signal you want to associate with this scoring rule. Refer to the Get Configured Signals API to get these details.

Update Scoring Rules

Request URL: {api-domain}/crm/v4/settings/automation/scoring_rules/{scoring_rule_ID} or 
{api-domain}/crm/v4/settings/automation/scoring_rules (with rule_id in the input body)
Request Method: PUT
Scope: ZohoCRM.settings.scoring_rules.ALL/UPDATE
Supported Modules: Leads, Contacts, Accounts, Deals, and custom

What can you update through this API?

  • Name, description, and score
  • Add field and signal rules
  • Update or delete field or signal rules
To delete a field or signal rule, include the key _delete with the ID of the rule and the signal, respectively.
Here is an example to delete the email insight bounce signal rule we configured earlier. We have also added another criteria for the field rule.

{
   "scoring_rules":[
      {
         "name":"Rule 8",
         "id":"3652397000010466004",
         "description":"Updated rule",
         "field_rules": [ //new field rule
                {
                    "score": 5,
                    "criteria": {
                        "group_operator": "OR",
                        "group": [
                            {
                                "field": {
                                    "api_name": "Position"
                                },
                                "comparator": "equal",
                                "value": "Regional Manager"
                            },
                            {
                                "field": {
                                    "api_name": "Position"
                                },
                                "comparator": "equal",
                                "value": "Reviewer"
                            }
                        ]
                    }
                }
            ],
         "signal_rules": [ //to delete the email insight bounce signal rule
                {
                    "score": -5,
                    "id": "3652397000010466007",
                    "_delete":null
                }
            ]
      }
   ]
}

Delete Scoring Rules

Request URL: {api-domain}/crm/v4/settings/automation/scoring_rules/{scoring_rule_ID} or 
{api-domain}/crm/v4/settings/automation/scoring_rules?ids=id1,id2..
Request Method: DELETE
Scope: ZohoCRM.settings.scoring_rules.ALL/DELETE
Supported Modules: Leads, Contacts, Accounts, Deals, and custom

Execute Scoring Rule

After creating a scoring rule, you have to execute it to apply the rule to the matching records. The Execute Scoring Rules API allows you to execute the scoring rules by their IDs or the layout ID. 
Request URL: {api-domain}/crm/v3/{module_api_name}/actions/run_scoring_rules
Request Method: PUT
Scope: ZohoCRM.settings.scoring_rules.ALL/UPDATE
Supported Modules: Leads, Contacts, Accounts, Deals, and custom

To execute scoring rules by their IDs

Note that all the scoring rules must be for the same module. You can execute up to 5 rules.

Sample Input
{
    "scoring_rules" : [
        "3652397000010466004",
        "3652397000006074001"
    ]
}

To execute scoring rules in a layout by the layout ID

Sample Input
{
    "layout" : {
            "id" :"3652397000000091055"   
    }
}

We hope you found this post useful. Next week, we will discuss cloning, activating/deactivating a scoring rule, and getting the score of a record from a module.

Write to us at support@zohocrm.com if you have any questions.

Cheers!





    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now