Marketo Lead Routing to Salesforce with Chili Piper

Want more control over how or when your leads are routed in Salesforce? Leverage the power of the Marketo marketing automation platform and the Chili Piper REST API to control your Salesforce lead routing.

On a separate note, have you checked out the Marketo API Crash Course yet? If you want hands-on video walkthroughs of how to get set up with the Marketo API and see real-life marketing operations use cases for the API then check out the course using the button below 🙂

Take Tyron’s Course on Demand

Explore the Marketo API Crash Course Bundle

Chili Piper Introduction

Chili Piper is a tool that makes it easy for inbound leads to schedule a meeting with your sales team and then handle the distribution of these meetings to the members of your team.

You can connect Chili Piper to your forms to automatically route leads that are created. However, if you want more control over when leads are routed then you can use the Chili Piper REST API. This in turn means that routing within Salesforce can be controlled by Marketo, since the REST API requests can be made using Marketo webhooks.

Before jumping into the implementation of the Chili Piper routing request in Marketo lets take a quick look at how Chili Piper can be configured to route leads in the way you want.

The distribution of inbound leads and meetings is handled by the “Concierge || Inbound Router” which specifies the rules for how leads are distributed to the members of your sales queues.

queue in Chili Piper is a method of grouping sales team members. Within a queue, you can specify the routing algorithm e.g. Round Robin, Ownership based, and other rules that will determine what events will be directed towards this queue. For example, you can specify that only events for leads with an “A” value quality score can be passed to the “A Quality Score” queue.

Additionally, you can also adjust the weights assigned to “Active Assignees” using the percentage field next to each assignee. For example if we want Mclain to receive double the amount of leads than Colin then we will set Mclain’s percentage to 200%.

Chili Piper Queue Settings
Chili Piper Queue Settings

Following on from the example of having an “A Quality Score” queue, an inbound router can then be set up so that any leads sent through this router can be distributed to different queues based on their quality score. Once the lead has then been matched to a queue, the routing algorithm of the queue and the different assignee weights will determine how this lead gets routed to the sales members within this queue.

Chili Piper Router Settings
Chili Piper Router Settings

Now that you know what Chili Piper can do and how it will handle your leads, take a look at the section below to see how to control the routing of your leads in Salesforce using Marketo webhook actions.

Setting up the Marketo Lead Routing Webhook

To route a lead that exists in Salesforce using the Chili Piper REST API, the email address of the lead along with the router that they are supposed to go through need to be sent in a POST request to the https://api.chilipiper.com/marketing/$DOMAIN endpoint.

In Marketo, this POST request will be made using a webhook, which in turn uses a lead token to pull in the email address and the campaign description token to pull in the router name from the campaign description (see below).

{
	"form": {"Email": "{{lead.Email Address}}"},
	"options": {"router": "{{campaign.description}}"}
}
Marketo Lead Routing Webhook using Chili Piper
Marketo Webhook for Chili Piper Lead Routing

After pasting in the “URL” and “Payload Template” and copying the rest of the settings in the image above, the final step of setting up the webhook is to set a custom header:

  1. Click on “Webhook Actions”
  2. Select “Set Custom Header”
  3. Click “Add”
  4. Put “Content-type” in the “Header” column
  5. Put the word “application/json” in the “Value”
Marketo Lead Routing Webhook Custom Header
Marketo Lead Routing Webhook Custom Header

Using the Marketo Lead Routing Webhook

Once you have created the Chili Piper lead routing webhook following the steps above the next step is to call this webhook from Smart Campaigns and set up an email alert in case the routing fails.

The “OPS – Chili Piper Routing” program channel type is “Operational” which has a single status of “Member”. In each of the campaigns below there is an optional “Change Program Status” action that changes the status of leads who pass through each of these campaigns to “Member” so that we can keep track of all the leads who pass through these campaigns within the program members list.

Marketo Lead Routing Program
Marketo Lead Routing Program

Marketo Lead Routing Smart Campaign Setup

For each Chili Piper router that you want to be able to call from within Marketo follow the steps below:

  1. Paste the Chili Piper router name into the campaign description
  2. Choose the “Campaign is Requested” trigger in the “Smart List”
  3. Choose the “Call Webhook” and “Change Program Status” actions in the “Flow”
    1. Select the webhook you created above in the “Call Webhook” action
    2. Set the “New Status” of the “Change Program Status” action to an applicable status for your program channel type
  4. Activate the smart campaign in the “Schedule” tab and adjust the smart campaign settings so that “Each person can run through the flow every time”
Marketo Lead Routing Smart Campaign with Router Name in Description
Smart Campaign with Router Name in Description
Marketo Lead Routing Smart Campaign Smart List with "Campaign is Requested" trigger
Smart List with “Campaign is Requested” Trigger
Marketo Lead Routing Smart Campaign Flow with "Call Webhook" and "Change Program Status" actions
Flow with “Call Webhook” and “Change Program Status” actions
Marketo Lead Routing Smart Campaign with Schedule set with "Each person can run through the flow every time"
Schedule set with “Each person can run through the flow every time”

Requesting the Lead Routing Smart Campaign

Once each of the smart campaigns has been set up with the “Campaign is Requested” trigger they can be called from a flow action in any other Marketo smart campaign.

By using the router name in the description of the smart campaigns this allows us to use a single webhook to route leads through different routers.

N.B. If the lead is newly created in Marketo then you will want to ensure that the lead has synced to Salesforce before requesting any of the routing campaigns. You can either wait until the “SFDC Type” field on the lead has changed to a non-null value to request routing or you can use a “Sync Person to SFDC” action before requesting routing.

If you do the later you might need to use a “Wait” action so that ample time has elapsed for the lead to be created in Salesforce before making the route request. Alternatively, you can be strategic with the order of your flow actions and place intermediary actions inbetween the sync action and the request action.

Marketo flow action to request the different lead routing campaigns
Flow action to request the different routing campaigns

Handling Chili Piper Routing Failure

Identifying a Chili Piper Lead Routing Failure

Contrasting the successful and failed lead assignment responses below it can be seen that for a successful response ?id= follows the “https://telnyx.chilipiper.com/book/test/” URL, whereas for a failed response ?routeID= follows the url.

This knowledge will be used in the “Marketo Lead Routing Failure Alert” section below to send an alert whenever the response from the Chili Piper lead routing webhook fails.

N.B. If the lead already has an owner then the response from the lead routing webhook will include the lead owner name (see the “FAQs” section below) but will still include the ?id= string so it will not trigger our failure alerting campaign unnecessarily.

A Successful Lead Assignment

{"routeId":"601ab36d2e05cd00019e8303","url":"https://telnyx.chilipiper.com/book/test/?id=00Q3a00000stAcwEAE&routeId=601ab36d2e05cd00019e8303&marketing=true","redirect":{"enabled":false,"closeStrategy":"Landing","timeout":5,"phoneCallRedirectEnabled":false,"redirectCallTimeoutStrategy":"AfterCallEnds","redirectCallTimeout":5}}

A Failed Lead Assignment

{"routeId":"601ab16799ad880001fa863e","url":"https://telnyx.chilipiper.com/book/test/?routeId=601ab16799ad880001fa863e&marketing=true","redirect":{"enabled":false,"closeStrategy":"Landing","timeout":5,"phoneCallRedirectEnabled":false,"redirectCallTimeoutStrategy":"AfterCallEnds","redirectCallTimeout":5}}

Marketo Lead Routing Failure Alert

The “Webhook Response Lister” campaign uses the “Webhook is Called” trigger to listen out for anytime the “Chili Piper Lead Routing” webhook is called and the “Response” does not contain ?id= (see the examples above for why this string can be used for detecting routing failure).

Marketo Lead Routing Webhook Response Listener Trigger
Webhook Response Listener Trigger

Whenever this event happens, the “Send Alert” action is used in the flow to send the “Alert – Failed Chili Piper Routing” email to members of your marketing and/or sales operations team who own the lead routing process.

Marketo Lead Routing Failure Alert
Failed Lead Routing Alert Email

Manually Routing a Lead After a Failed Assignment

Once you receive the failure notification email above follow the steps below to identify why the routing failed and how to manually route the lead:

Identifying the Router Name and Reason for Failure

  1. Click on the hyperlinked lead name to bring up the activity log for the lead
  2. Type “Chili” into the search box at the bottom of the screen and press enter
  3. Search for the latest “Call Webhook” event with “Chili Piper” in the name with a response indicating an unsuccessful routing (see the “Identifying a Chili Piper Lead Routing Failure” above to tell if a request was unsuccessful)
  4. Find the campaign listed in the “Campaign Name” column of this event
  5. Identify the router name specified in the description of this campaign. You will use this same router name below when manually routing the lead.
  6. Before proceeding to manually route the lead below make sure that you have addressed the reason the first routing attempt did not succeed.
    1. This is most likely because a newly created lead did not sync to Salesforce

Manually Routing a Lead using Postman or the Terminal

To route a lead using a terminal follow the steps below:

  1. Open up the command line on your computer
  2. Copy all the code below to a text editor
  3. Change the email to that of the person you are trying to route
  4. Change the router to match the router you want them to run through
  5. Copy all of your updated code
  6. Paste into the command line
  7. Hit Enter
export DOMAIN="theworkflowpro"
export ROUTER="new-portal-signup"
  cat > 'data.json' <<- EOM
  {
      "form": {
          "Email": "[email protected]"
      },
      "options": {
          "router": "$ROUTER"
      }
  }
EOM
  curl \
    --header "Content-type: text/plain" \
    --request POST \
    --data @data.json \
    https://api.chilipiper.com/marketing/$DOMAIN
Chili Piper Lead Routing from the Terminal
Chili Piper Lead Routing from the Terminal

Alternatively, if you have the free API testing tool Postman downloaded then you can make a POST request as shown in the image below.

If you want an introduction on how to get started with Postman I walk through how to set up an environment and make your first API requests in the Marketo API Quick-Start Guide.

Chili Piper Routing with Postman
Chili Piper Routing with Postman

What’s Next?

Now that you have the Marketo Chili Piper integration nailed, check out the posts below to see how you can integrate Marketo with all sorts of other platforms.

FAQS

How does Chili Piper handle duplicates?

If there are multiple people in Salesforce with the same email address then Chili Piper will pick one of the duplicates to update.

What happens if Chili Piper routes a lead with an existing owner?

Chili Piper will only change the owner of a person in Salesforce if the owner is not a part of the router being called or if the current owner does not comply with the rules of the router.

Simple Round-Robin Routing Example

For a simple round-robin router consisting of X salespeople, if you try and run the round-robin router on a lead that is already owned by one of these X owners then the owner will not be changed. Additionally, the response of the Chili Piper API request will return the name of the existing owner.

{"routeId":"601ae9d48dd8e3000149b71e","url":"https://telnyx.chilipiper.com/book/sfdc-record-ownership/tyron-pretorius?id=00Q3a00000stAcwEAE&routeId=601ae9d48dd8e3000149b71e&marketing=true","redirect":{"enabled":false,"closeStrategy":"Landing","timeout":5,"phoneCallRedirectEnabled":false,"redirectCallTimeoutStrategy":"AfterCallEnds","redirectCallTimeout":5}}

Routing with Custom Fields Example

For a router where leads are assigned based on a custom field, let’s say “Lead Quality Score” then even if the lead is already owned by one of the salespeople in the router then it can still be re-assigned if the current owner does not match the rules associated with this custom field.

  • Tyron Pretorius: Lead Quality Score A
  • Jango Fett: Lead Quality Score B
  • Luke Skywalker: Lead Quality Score C

For example, if Jango Fett already owns a lead who has an “A” quality score then when the lead is passed through the quality score router they will be reassigned to Tyron Pretorius.

Can Chili Piper route leads based on custom fields?

Yes! You can use any Salesforce field in your routing logic. As shown in the “Chili Piper Introduction” and the “Routing with Custom Fields Example” above you can configure your router so that your best salespeople get the best quality leads.

Does Chili Piper handle leads and contacts differently?

No, thankfully Chili Piper does not. You can use the exact same REST API request and Marketo webhook to route both leads and contacts and the responses returned by Chili Piper will be the exact same as the 3 examples given in this post.

About The Author — Tyron Pretorius
Tyron Pretorius

Greetings fellow MO Pros! As a previous mechanical engineer turned marketing operations lead, I now fancy myself as a full-stack marketer capable of designing websites, writing SEO-optimized content, and doing all the tracking and automation on the backend. That being said my bread and butter is marketing operations and I love to get down and dirty with the Marketo API, Python, Zapier, and Google Scripts.

Related free workshops

The New Four Pillars of Marketing Operations

The New Four Pillars of Marketing Operations

Created with the assistance of DALL·E Introduction and Background In 2018, Edward Unthank introduced the four pillars of marketing operations, setting the stage for the management of effective marketing technology (Martech) functions. These pillars have since been the bedrock for many successful careers in marketing operations. My journey to redefine

Become a member
The Role of Front-End Martech Tools in the Age of Generative AI

The Role of Front-End Martech Tools in the Age of Generative AI

Introduction: Blending Human and Technical Perspectives in Martech Caption: Future gardens of martech will blend human and AI perspectives As a co-host of the Humans of Martech podcast, I’ve had the privilege of interviewing some of the brightest minds in marketing technology. This unique experience has provided a blend of

Become a member