Webhook for Chili Piper Routing

Routing People to Salesforce with Webhooks and Chili Piper

Level 9 - Champion Level 9 - Champion
Level 9 - Champion
Webhook for Chili Piper RoutingWebhook for Chili Piper Routing




Want more control over how or when your people are routed in Salesforce? Leverage the power of webhooks and the Chili Piper API to control your routing in Salesforce.


Chili Piper is a tool that makes it easy for inbound people 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 people that are created. However, if you want more control over when people 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 API requests can be made using 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 people in the way you want.


Chili Piper Introduction


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


A 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 people 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 people than Colin then we will set Mclain’s percentage to 200%.


Chili Piper Queue SettingsChili 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 people sent through this router can be distributed to different queues based on their quality score. Once the person has then been matched to a queue, the routing algorithm of the queue and the different assignee weights will determine how this person gets routed to the sales members within this queue.


Chili Piper Router SettingsChili Piper Router Settings





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


Setting up the Webhook


To route a person that exists in Salesforce using the Chili Piper REST API, the email address of the person 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 person 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}}"}


Chili Piper WebhookChili Piper Webhook




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”


Webhook Custom HeaderWebhook Custom Header




Using the Webhook


Once you have created the Chili Piper 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 people who pass through each of these campaigns to “Member” so that we can keep track of all the people who pass through these campaigns within the program members list.


Chili Piper ProgramChili Piper Program




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”


Smart Campaign with Router Name in DescriptionSmart Campaign with Router Name in Description




Smart List with "Campaign is Requested" TriggerSmart List with "Campaign is Requested" Trigger



Flow with "Call Webhook" and "Change Program Status" actionsFlow with "Call Webhook" and "Change Program Status" actions



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 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 smart campaign.


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


N.B. If the person is newly created then you will want to ensure that the person has synced to Salesforce before requesting any of the routing campaigns. You can either wait until the “SFDC Type” field on the person 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 person 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 in between the sync action and the request action.


Flow action to request the different routing campaignsFlow action to request the different routing campaigns




Handling Chili Piper Routing Failure


Identifying a Chili Piper Failure


Contrasting the successful and failed person 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 “Failure Alert” section below to send an alert whenever the response from the Chili Piper webhook fails.


N.B. If the person already has an owner then the response from the webhook will include the person 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 Person Assignment




A Failed Person Assignment




Failure Alert


The “Webhook Response Lister” campaign uses the “Webhook is Called” trigger to listen out for anytime the 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).


Webhook Response Listener TriggerWebhook 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 routing process.


Failed Routing Alert EmailFailed Routing Alert Email



Manually Routing a Person 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 person:


Identifying the Router Name and Reason for Failure


  1. Click on the hyperlinked person name to bring up the activity log for the person
  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 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 person.
  6. Before proceeding to manually route the person 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 person did not sync to Salesforce


Manually Routing using Postman or the Terminal


To route a person 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": "tyron@theworkflowpro.com"
      "options": {
          "router": "$ROUTER"
  curl \
    --header "Content-type: text/plain" \
    --request POST \
    --data @data.json \


Chili Piper Routing from the TerminalChili Piper 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 Quick-Start Guide to the API


Chili Piper Routing with PostmanChili Piper Routing with Postman



What’s Next?


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





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 person 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 person 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.




Routing with Custom Fields Example


For a router where people are assigned based on a custom field, let’s say “Person Quality Score” then even if the person 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: person Quality Score A
  • Jango Fett: person Quality Score B
  • Luke Skywalker: person Quality Score C


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


Can Chili Piper route people 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 people.


Does Chili Piper handle people and contacts differently?


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



The content in this blog has been reviewed by the Community Manager to ensure that it is following Marketing Nation Community guidelines. If you have concerns or questions, please reach out to @Jon_Chen or comment down below.