salesforce-suggest-next-best-actions-for-a-lead implementation guide

---
availability: INSTALLABLE
description: A plugin that allows you to instantly uncover the most effective next
  steps for each lead based on their activity and engagement history, empowering your
  sales team to convert faster and smarter.
installation_asset_uuid: 77c3052a-f99e-4275-a6e0-4ff2eb567bc1
name: Suggest Next Best Actions for a Lead
purple_chat_link: https://marketplace.moveworks.com/purple-chat?conversation=%7B%22startTimestamp%22%3A%2211%3A43+AM%22%2C%22messages%22%3A%5B%7B%22role%22%3A%22user%22%2C%22parts%22%3A%5B%7B%22richText%22%3A%22I+want+to+know+the+next+best+actions+for+a+lead.%22%7D%5D%7D%2C%7B%22role%22%3A%22assistant%22%2C%22parts%22%3A%5B%7B%22richText%22%3A%22%3Cp+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EOkay%2C+I+can+help+you+with+that.+Would+you+like+to+see+your+assigned+leads%2C+a+specific+lead+or+leads+by+company+name%3F%3C%2Fp%3E%22%7D%5D%7D%2C%7B%22role%22%3A%22user%22%2C%22parts%22%3A%5B%7B%22richText%22%3A%22leads+assigned+to+me%22%7D%5D%7D%2C%7B%22role%22%3A%22assistant%22%2C%22parts%22%3A%5B%7B%22reasoningSteps%22%3A%5B%7B%22status%22%3A%22pending%22%2C%22richText%22%3A%22Fetching+leads+assigned+to+you+from+%3Cb+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3ESalesforce%3C%2Fb%3E...%22%7D%5D%7D%2C%7B%22richText%22%3A%22%3Cp+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EHere+are+the+leads+currently+assigned+to+you.+Please+select+one%3A%3C%2Fp%3E%3Col+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3E%3Cli%3EJohn+Doe+%28ACME+Corp%29%3C%2Fli%3E%3Cli%3EJane+Smith+%28Global+Solutions%29%3C%2Fli%3E%3Cli%3ERobert+Brown+%28Innovate+Systems%29%3C%2Fli%3E%3C%2Fol%3E%22%7D%2C%7B%22citations%22%3A%5B%7B%22connectorName%22%3A%22salesforce%22%2C%22citationTitle%22%3A%22John+Doe+%28ACME+Corp%29%22%7D%2C%7B%22connectorName%22%3A%22salesforce%22%2C%22citationTitle%22%3A%22Jane+Smith+%28Global+Solutions%29%22%7D%2C%7B%22connectorName%22%3A%22salesforce%22%2C%22citationTitle%22%3A%22Robert+Brown+%28Innovate+Systems%29%22%7D%5D%7D%5D%7D%2C%7B%22role%22%3A%22user%22%2C%22parts%22%3A%5B%7B%22richText%22%3A%22John+Doe%22%7D%5D%7D%2C%7B%22role%22%3A%22assistant%22%2C%22parts%22%3A%5B%7B%22reasoningSteps%22%3A%5B%7B%22status%22%3A%22pending%22%2C%22richText%22%3A%22Fetching+tasks+and+events+for+%3Cb+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EJohn+Doe%3C%2Fb%3E+from+%3Cb+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3ESalesforce%3C%2Fb%3E...%22%7D%2C%7B%22status%22%3A%22pending%22%2C%22richText%22%3A%22Retrieving+recent+call+notes+and+email+activity+for+%3Cb+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EJohn+Doe%3C%2Fb%3E...%22%7D%5D%7D%2C%7B%22richText%22%3A%22%3Cp+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EHere%27s+a+summary+of+recent+activities+and+important+details+for+%3Cb%3EJohn+Doe%3C%2Fb%3E+%28ACME+Corp%29%3A%3C%2Fp%3E%3Cul+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3E%3Cli%3E%3Cb%3ECall+Notes%3A%3C%2Fb%3E%3Cul%3E%3Cli%3E%3Cb%3E2023-10-20+Product+Demo%3A%3C%2Fb%3E+John+expressed+high+interest+in+Q4+features%2C+specifically+reporting+dashboard.+Mentioned+current+pain+points+with+manual+data+aggregation.%3C%2Fli%3E%3Cli%3E%3Cb%3E2023-10-15+Discovery+Call%3A%3C%2Fb%3E+Confirmed+need+for+scalable+analytics+solution.+Identified+key+stakeholders+as+CFO+%28Sarah+Chen%29+and+Head+of+Sales+%28David+Lee%29.+Budget+discussion+pending.%3C%2Fli%3E%3C%2Ful%3E%3C%2Fli%3E%3Cli%3E%3Cb%3EEmail+Pointers%3A%3C%2Fb%3E%3Cul%3E%3Cli%3EReplied+positively+to+marketing+email+on+2023-10-18+regarding+industry+trends.%3C%2Fli%3E%3Cli%3EOpened+but+did+not+reply+to+follow-up+email+on+2023-10-22+regarding+next+steps+after+demo.%3C%2Fli%3E%3C%2Ful%3E%3C%2Fli%3E%3Cli%3E%3Cb%3EUpcoming+Tasks%3A%3C%2Fb%3E%3Cul%3E%3Cli%3EFollow-up+call+with+Sarah+Chen+%28CFO%29+and+David+Lee+%28Head+of+Sales%29+-+Scheduled+for+2023-11-05.%3C%2Fli%3E%3Cli%3EPrepare+customized+proposal+for+ACME+Corp+-+Due+2023-11-03.%3C%2Fli%3E%3C%2Ful%3E%3C%2Fli%3E%3Cli%3E%3Cb%3EPast+Tasks%3A%3C%2Fb%3E%3Cul%3E%3Cli%3EFollow-up+call+scheduled+for+2023-10-26+%28Completed%29%3C%2Fli%3E%3Cli%3ESend+marketing+brochure+%28Pending%29%3C%2Fli%3E%3C%2Ful%3E%3C%2Fli%3E%3Cli%3E%3Cb%3EPast+Events%3A%3C%2Fb%3E%3Cul%3E%3Cli%3EProduct+Demo+with+Sales+Team+%282023-10-20%29%3C%2Fli%3E%3Cli%3EDiscovery+Call+%282023-10-15%29%3C%2Fli%3E%3C%2Ful%3E%3C%2Fli%3E%3C%2Ful%3E%22%7D%2C%7B%22reasoningSteps%22%3A%5B%7B%22status%22%3A%22pending%22%2C%22richText%22%3A%22Retrieving+next+best+actions+for+%3Cb+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EJohn+Doe%3C%2Fb%3E...%22%7D%5D%7D%2C%7B%22richText%22%3A%22%3Cp+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EOkay%2C+for+%3Cstrong%3EJohn+Doe%3C%2Fstrong%3E+%28ACME+Corp%29%2C+based+on+recent+activity+and+engagement%2C+here+are+the+suggested+next+best+actions%3A%3C%2Fp%3E%3Cul+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3E%3Cli%3E%3Cp%3E%3Cstrong%3EPrepare+a+personalized+follow-up+email%3C%2Fstrong%3E+highlighting+our+recent+success+story+with+a+similar+client%2C+specifically+addressing+their+reporting+dashboard+needs.%3C%2Fp%3E%3C%2Fli%3E%3Cli%3E%3Cp%3E%3Cstrong%3EReconfirm+the+upcoming+call%3C%2Fstrong%3E+with+Sarah+Chen+and+David+Lee%2C+and+prepare+to+address+budget+and+integration+questions.%3C%2Fp%3E%3C%2Fli%3E%3Cli%3E%3Cp%3E%3Cstrong%3ESend+them+a+link%3C%2Fstrong%3E+to+the+upcoming+webinar+on+product+enhancements+relevant+to+their+industry%2C+focusing+on+reporting+and+analytics.%3C%2Fp%3E%3C%2Fli%3E%3C%2Ful%3E%22%7D%5D%7D%5D%7D
solution_tags:
- Productivity
- Sales
systems:
- salesforce
---

## **Introduction**

The **"Suggest Next Best Actions for a Lead"** plugin helps sales teams by automatically recommending the most relevant actions for each lead through the Moveworks AI Assistant. It analyzes lead activity, engagement, and status to suggest timely calls, emails, tasks, or follow ups eliminating manual guesswork and helping users focus on the smartest next steps to close deals faster and improve productivity

This guide will walk you through installing and configuring the plugin in Agent Studio in just a few minutes. Let's get started!

## **Prerequisites**

• Access to **Agent Studio**

## **What are we building?**

### **Agent Design**

This [purple chat](https://marketplace.moveworks.com/purple-chat?conversation=%7B%22startTimestamp%22%3A%2211%3A43+AM%22%2C%22messages%22%3A%5B%7B%22role%22%3A%22user%22%2C%22parts%22%3A%5B%7B%22richText%22%3A%22I+want+to+know+the+next+best+actions+for+a+lead.%22%7D%5D%7D%2C%7B%22role%22%3A%22assistant%22%2C%22parts%22%3A%5B%7B%22richText%22%3A%22%3Cp+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EOkay%2C+I+can+help+you+with+that.+Would+you+like+to+see+your+assigned+leads%2C+a+specific+lead+or+leads+by+company+name%3F%3C%2Fp%3E%22%7D%5D%7D%2C%7B%22role%22%3A%22user%22%2C%22parts%22%3A%5B%7B%22richText%22%3A%22leads+assigned+to+me%22%7D%5D%7D%2C%7B%22role%22%3A%22assistant%22%2C%22parts%22%3A%5B%7B%22reasoningSteps%22%3A%5B%7B%22status%22%3A%22pending%22%2C%22richText%22%3A%22Fetching+leads+assigned+to+you+from+%3Cb+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3ESalesforce%3C%2Fb%3E...%22%7D%5D%7D%2C%7B%22richText%22%3A%22%3Cp+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EHere+are+the+leads+currently+assigned+to+you.+Please+select+one%3A%3C%2Fp%3E%3Col+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3E%3Cli%3EJohn+Doe+%28ACME+Corp%29%3C%2Fli%3E%3Cli%3EJane+Smith+%28Global+Solutions%29%3C%2Fli%3E%3Cli%3ERobert+Brown+%28Innovate+Systems%29%3C%2Fli%3E%3C%2Fol%3E%22%7D%2C%7B%22citations%22%3A%5B%7B%22connectorName%22%3A%22salesforce%22%2C%22citationTitle%22%3A%22John+Doe+%28ACME+Corp%29%22%7D%2C%7B%22connectorName%22%3A%22salesforce%22%2C%22citationTitle%22%3A%22Jane+Smith+%28Global+Solutions%29%22%7D%2C%7B%22connectorName%22%3A%22salesforce%22%2C%22citationTitle%22%3A%22Robert+Brown+%28Innovate+Systems%29%22%7D%5D%7D%5D%7D%2C%7B%22role%22%3A%22user%22%2C%22parts%22%3A%5B%7B%22richText%22%3A%22John+Doe%22%7D%5D%7D%2C%7B%22role%22%3A%22assistant%22%2C%22parts%22%3A%5B%7B%22reasoningSteps%22%3A%5B%7B%22status%22%3A%22pending%22%2C%22richText%22%3A%22Fetching+tasks+and+events+for+%3Cb+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EJohn+Doe%3C%2Fb%3E+from+%3Cb+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3ESalesforce%3C%2Fb%3E...%22%7D%2C%7B%22status%22%3A%22pending%22%2C%22richText%22%3A%22Retrieving+recent+call+notes+and+email+activity+for+%3Cb+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EJohn+Doe%3C%2Fb%3E...%22%7D%5D%7D%2C%7B%22richText%22%3A%22%3Cp+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EHere%27s+a+summary+of+recent+activities+and+important+details+for+%3Cb%3EJohn+Doe%3C%2Fb%3E+%28ACME+Corp%29%3A%3C%2Fp%3E%3Cul+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3E%3Cli%3E%3Cb%3ECall+Notes%3A%3C%2Fb%3E%3Cul%3E%3Cli%3E%3Cb%3E2023-10-20+Product+Demo%3A%3C%2Fb%3E+John+expressed+high+interest+in+Q4+features%2C+specifically+reporting+dashboard.+Mentioned+current+pain+points+with+manual+data+aggregation.%3C%2Fli%3E%3Cli%3E%3Cb%3E2023-10-15+Discovery+Call%3A%3C%2Fb%3E+Confirmed+need+for+scalable+analytics+solution.+Identified+key+stakeholders+as+CFO+%28Sarah+Chen%29+and+Head+of+Sales+%28David+Lee%29.+Budget+discussion+pending.%3C%2Fli%3E%3C%2Ful%3E%3C%2Fli%3E%3Cli%3E%3Cb%3EEmail+Pointers%3A%3C%2Fb%3E%3Cul%3E%3Cli%3EReplied+positively+to+marketing+email+on+2023-10-18+regarding+industry+trends.%3C%2Fli%3E%3Cli%3EOpened+but+did+not+reply+to+follow-up+email+on+2023-10-22+regarding+next+steps+after+demo.%3C%2Fli%3E%3C%2Ful%3E%3C%2Fli%3E%3Cli%3E%3Cb%3EUpcoming+Tasks%3A%3C%2Fb%3E%3Cul%3E%3Cli%3EFollow-up+call+with+Sarah+Chen+%28CFO%29+and+David+Lee+%28Head+of+Sales%29+-+Scheduled+for+2023-11-05.%3C%2Fli%3E%3Cli%3EPrepare+customized+proposal+for+ACME+Corp+-+Due+2023-11-03.%3C%2Fli%3E%3C%2Ful%3E%3C%2Fli%3E%3Cli%3E%3Cb%3EPast+Tasks%3A%3C%2Fb%3E%3Cul%3E%3Cli%3EFollow-up+call+scheduled+for+2023-10-26+%28Completed%29%3C%2Fli%3E%3Cli%3ESend+marketing+brochure+%28Pending%29%3C%2Fli%3E%3C%2Ful%3E%3C%2Fli%3E%3Cli%3E%3Cb%3EPast+Events%3A%3C%2Fb%3E%3Cul%3E%3Cli%3EProduct+Demo+with+Sales+Team+%282023-10-20%29%3C%2Fli%3E%3Cli%3EDiscovery+Call+%282023-10-15%29%3C%2Fli%3E%3C%2Ful%3E%3C%2Fli%3E%3C%2Ful%3E%22%7D%2C%7B%22reasoningSteps%22%3A%5B%7B%22status%22%3A%22pending%22%2C%22richText%22%3A%22Retrieving+next+best+actions+for+%3Cb+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EJohn+Doe%3C%2Fb%3E...%22%7D%5D%7D%2C%7B%22richText%22%3A%22%3Cp+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3EOkay%2C+for+%3Cstrong%3EJohn+Doe%3C%2Fstrong%3E+%28ACME+Corp%29%2C+based+on+recent+activity+and+engagement%2C+here+are+the+suggested+next+best+actions%3A%3C%2Fp%3E%3Cul+xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%3E%3Cli%3E%3Cp%3E%3Cstrong%3EPrepare+a+personalized+follow-up+email%3C%2Fstrong%3E+highlighting+our+recent+success+story+with+a+similar+client%2C+specifically+addressing+their+reporting+dashboard+needs.%3C%2Fp%3E%3C%2Fli%3E%3Cli%3E%3Cp%3E%3Cstrong%3EReconfirm+the+upcoming+call%3C%2Fstrong%3E+with+Sarah+Chen+and+David+Lee%2C+and+prepare+to+address+budget+and+integration+questions.%3C%2Fp%3E%3C%2Fli%3E%3Cli%3E%3Cp%3E%3Cstrong%3ESend+them+a+link%3C%2Fstrong%3E+to+the+upcoming+webinar+on+product+enhancements+relevant+to+their+industry%2C+focusing+on+reporting+and+analytics.%3C%2Fp%3E%3C%2Fli%3E%3C%2Ful%3E%22%7D%5D%7D%5D%7D) shows the experience we are going to build.

## **Installation Steps**

We recommend creating the connector for **Salesforce** first, prior to installing this plugin. Please follow the  [Salesforce Connector](https://marketplace.moveworks.com/connectors/salesforce#how-to-implement) guide to set up the connector.

For this plugin, ensure the Salesforce integration user has the following permissions:

- `Read` and `Create` access to the **Task**, **Event**, and **Campaign** objects
- `Read` access to the **Lead** object

After you have configured the connector, Please refer to our [plugin installation documentation](https://help.moveworks.com/docs/ai-agent-marketplace-installation) for more details on how to install a plugin in Agent Studio.

## **Appendix**

### **API #1 : Get Leads by Email**

```bash
curl --location 'https://<your-instance>/services/data/v59.0/query/?q=SELECT+Id%2C+Name%2C+Title%2C+Company%2C+Email%2C+Owner.Name%2C+Status%2C+Phone%2C+Street%2C+City%2C+State%2C+PostalCode%2C+Country%2C+LastModifiedDate+FROM+Lead+WHERE+Owner.Email%3D%27{{email}}%27+AND+IsConverted%3Dfalse+ORDER+BY+LastModifiedDate+DESC' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-access-token>'
```

**Query Parameters**

- `email` - Search by Lead Owner’s Email.

### **API #2 : Get Leads by Name**

```bash
curl --location 'https://<your-instance>/services/data/v59.0/query/?q=SELECT+Id%2CName%2CTitle%2CCompany%2CEmail%2COwner.Name%2CStatus%2CPhone%2CStreet%2CCity%2CState%2CPostalCode%2CCountry%2CLastModifiedDate+FROM+Lead+WHERE+Name+LIKE+%27%25{{name}}%25%27+AND+IsConverted%3Dfalse+ORDER+BY+LastModifiedDate+DESC+LIMIT+50' \
--header 'Authorization: Bearer <your-access-token>'
```

**Query Parameters**

- `name`  - Search for a specific lead by name.

### **API #3 :** **Get Leads by C**ompany

```bash
curl --location 'https://<your-instance>/services/data/v59.0/query/?q=SELECT+Id%2CName%2CTitle%2CCompany%2CEmail%[2COwner.Name](http://2cowner.name/)%2CStatus%2CPhone%2CStreet%2CCity%2CState%2CPostalCode%2CCountry%2CLastModifiedDate+FROM+Lead+WHERE+Company+LIKE+%27%25{{company_name}}%25%27+AND+IsConverted%3Dfalse+ORDER+BY+LastModifiedDate+DESC+LIMIT+50' \
--header 'Authorization: Bearer <your-access-token>'
```

**Query Parameters**

- `company_name` - Search by company name to retrieve lead details.

### **API #4 : Create Suggest Next Best Actions for a Lead**

```bash
curl --location 'https://<your-instance>/services/data/v56.0/composite/batch/' \
--header 'Authorization: Bearer <your-access-Token>' \
--header 'Content-Type: application/json' \
--data '{

    "batchRequests": [

        {

            "method": "GET",

            "url": "services/data/v56.0/query/?q=SELECT+Subject,ActivityDate,Status,TaskSubtype,Description+FROM+Task+WHERE+WhoId=%27{{lead_id}}%27+ORDER+BY+ActivityDate+DESC"

        },

			  {

            "method": "GET",

            "url": "services/data/v56.0/query/?q=SELECT+Subject,ActivityDate,Location,Description+FROM+Event+WHERE+WhoId={{lead_id}}+ORDER+BY+ActivityDate+DESC"

        }, 

            {
            "method": "GET",
            "url": "services/data/v56.0/query/?q=SELECT+Campaign.Name,Campaign.Type,Campaign.Description,Status,HasResponded,FirstRespondedDate+FROM+CampaignMember+WHERE+LeadId={{lead_id}}+ORDER+BY+FirstRespondedDate+DESC"
        }
    ]
}
```

**** **Request Body Parameters**

- `lead_id`  - Retrieves the active lead based on the user’s input and fetches its ID.