SOLVED

Re: We have over 200 locations, how do I dynamically send leads to each one?

Go to solution
SanfordWhiteman
Level 10 - Community Moderator

Re: We have over 200 locations, how do I dynamically send leads to each one?

Just so I can explain what I need to the website developer, the webhook would include all the information associated with the location id (sales owner first, last and email) and when the webhook is called with a smart campaign flow step these would be written in to these fields in Marketo?

Yes, the webhook request payload might look like this:

var locationMap = [

  {

    locationIds : [1,23,98],

    ownerAddress: "sandy@example.com"

  },

  {

    locationIds : [7,14,22,198],

    ownerAddress: "mandy@example.fr"

  },

  {

    locationIds : [6,11,12],

    ownerAddress: "tandy@example.co.uk"

  }

];   

var matchedLocation = locationMap

  .find(entry =>

     entry.locationIds.some(locationId =>

         locationId == {{lead.currentLocationId}}

     )

  );

return {

  ownerAddress : matchedLocation.ownerAddress

};

Then, in this example, ownerAddress gets mapped back to the lead field under Response Mappings.

The locationMap might itself be a token that's included in the webhook payload as {{my.token name}}, rather than being typed in the payload box (better for reuse that way).

Of course, the language, format, and API you use will most definitely be different -- this is just an example of how I write such things in my preferred environment.

Adam_Wingate
Level 2

Re: We have over 200 locations, how do I dynamically send leads to each one?

Great thank you!