Be Netflix, not Blockbuster | How to evolve in a volatile property market
The times, they are a’changing. And the property industry needs to change too. If you’re not making digital adoption your number…
Read On24 Feb 2018 | 5 min read
Note: this is a pretty technical post so unless you "speak code", you may want to look at some of our other posts.
RealEstate.com.au is used by many of our property clients to generate enquiries for their projects. Those enquiries come through to our clients in the form of emails. We developed a solution so that those email-based enquiries can be automatically converted to Leads in Salesforce via an Email-to-Lead service.
The benefits of this approach include:
We will be using Salesforce's Email Service for this task:
Email services are special-purpose Force.com processes that use Apex classes to process incoming email messages.
This will create a dedicated Salesforce email address (e.g. emailservice@dfdfkje.apex.salesforce.com), and all emails to that address will be handled by an Apex class.
RealEstate.com.au require that you provide them a company email so we suggest asking your I.T department to set up a specific email address for all enquiries such as enquiries@mycompany.com.au. You will then forward on all emails received at that inbox to your Salesforce email service address.
The Email Service will need to be associated with an Apex class to handle the logic as per the notification:
An Apex class that functions as an inbound email handler should implement the Messaging.InboundEmailHandler interface, and a single method, handleInboundEmail. This method has 2 arguments: email, which you get the contents of the email from, and envelope, which stores the to and from addresses.
Normally, you would then use the following code to get the details of the enquirer from the email and store it in a Contact object:
However, with Realestate.com.au emails, the enquirer's details such as name and email address are embedded within the HTML-formatted email:
What we therefore have to do is break up the email into separate lines and then read the applicable lines to get the details we require. We also need to remove all of the HTML tags such as <strong> etc.
We will then know, for example, that the Name details is on line 37. We scan that line, and store the details in our Contact object:
The rest of the procedure is pretty much the same: find the relevant lines for the Email and the Project (so you associate a lead with a Project), and pull out the information.
We then create the Contact and provided there are no errors, we create a Lead with the ID that was returned from the Contact.
We can also put additional logic in there such as adding the Contact to a Campaign for that Project.
The above snippets only show a very small percentage of logic required to get this set up. However, our clients are very happy with result - less work for them and improved conversion rates!
It is by no means a perfect solution. If RealEstate.com.au change the layout of their email templates, we'll need to update our code accordingly or it will no longer function. RealEstate.com.au also have multiple templates depending on where the person enquired (e.g a Proejct page), so we need additional logic in there to determine the type of email sent.
If you would like assistance with setting up a similar service for your Salesforce environment, please email us at hello@liquid.com.au for a free consultation.