Introducing the New and Improved Match My Email Dashboard. View announcement

Introducing the New and Improved Match My Email Dashboard. View announcement

MME Technology Blog

How to Use Salesforce AI with Email Data

Salesforce AI Demo image showcasing screenshots of various interface elements and workflows, illustrating How to Use Email Data effectively, with the Match My Email logo prominently at the bottom left. The background transitions from dark blue to lighter blue in a smooth gradient.

If you haven’t heard, Salesforce just released a breakthrough AI product called Agentforce. It’s a big deal for the value companies can unlock from email data. Below, we will cover how you can use email data with Agentforce and the new AI tools from Salesforce. The demo below will specifically be showing how AI can be used to process and interpret emails written in regular language and then automatically update data in Salesforce when a customer has mentioned a change in their email. This will only possible for you today if you store email data directly in Salesforce with tools like Match My Email.
 


 

Learning resources for the tools used in this demo can be found: here
 

The Demo Goal and Setup

In our demo, we had a clear goal. We set up a contact with a booking reserved for 2 guests. We set up a number of emails to be matched to this contact with one email in particular where the contact has requested to update the booking from 2 to 4 guests. The goal of this demo was to have the AI be able to discern this request from a set of similar sounding emails and update the booking appropriately.

Question for your organization: What valuable data lives in emails with your customers? What information from emails does your team have to manually pull out of emails? This could be a great use case for a Salesforce flow that leverages AI.
 

Data set up to develop our Flow with AI
 

Setting up a Flow

Once this goal was decided, we set up a flow that pulls in the relevant data. In our case, this meant pulling in the relevant booking and all the email messages related to the contact related to the booking. We prepared this demo with the idea of it being an Agent Action for Agentforce so we set the trigger to be “autolaunched flow” but could have been any type of trigger we wanted.

New to Flows? we recommend the following resources:

 

Flow set up to run through AI prompt template
 

Pulling Email Messages into a Flow

While it may seem easy to pull email messages into a flow, there may be an extra unexpected step. If you use Match My Email to store email messages as custom objects, it is very easy to pull the email messages related to a contact directly into the flow.

If you use Match My Email to store email messages as enhanced emails, you have to first get the tasks related to the contact and then get the email messages related to their activity IDs on the task. This was how we set our demo up. First we had to get all tasks related to the contact with the type of “email”. Next, we created a collection variable for the tasks. We had to loop through all the tasks to add them to this collection. Then, we had to get all email messages related to the collection.
 

Setting up an AI Prompt Template

To utilize the power of AI in our flow, we had to create a prompt template. A prompt template is a reusable AI prompt that can be triggered by a flow. It is created in a tool called Prompt Builder (not to be confused with Process Builder, the old name for Flows). We set up our prompt template with a prompt template type of Flex. By choosing the Flex type, we are allowed to bring in 5 different objects into the same prompt. Since our flow uses email messages and a booking, we need to bring in the email message object and the booking object.

Once set up, we can bring data from these objects directly into our prompt. As our flow runs through a loop, it will bring a different email message into the prompt each time.

For our scenario, we were trying to detect a change to guest count for a specific booking. This means the prompt instructions had to be very specific to ensure the AI was first checking to see if the email message was related to the booking and next check to see if the message mentioned a guest count change. If all of that was the case, then the prompt told AI to only respond with the number and nothing else or the string “No Change” verbatim. It is important to note that this prompt failed with chatGPT 3.5 but worked every time with chatGPT 4.

Here is the exact prompt from the demo:

Identify if there is a mention of the email sender wanting to update guest count in the email message below related to the booking below. Assume the guest has multiple bookings. For the email message to relate to the booking, at least the name, date or start time in the booking should be mentioned in the email message. If any information in the email message conflicts with the booking confirmation, then the conclusion should be that the email message is not corresponding to the booking below. Guest count has to do with the number of guests on a vacation trip and nothing else.
State the new guest count as just the number. Only include a number in the response.
If not, respond with “No Change” verbatim.

///////////////////////////////
Booking:
{!$Input:Booking.Experience_Name__c}
{!$Input:Booking.Number_of_Guests__c}
{!$Input:Booking.Date__c}
{!$Input:Booking.Start_Time__c}
{!$Input:Booking.End_Time__c}
{!$Input:Booking.Name}

///////////////////////////////

Email Message:
{!$Input:Email_Messages.Subject}
{!$Input:Email_Messages.TextBody}
Email Date:
{!$Input:Email_Messages.MessageDate}

 

This exact prompt was created after much testing. We created many similar sounding emails to make sure that the AI would consistently discern a guest count change and avoid anything that did not meet the criteria.

New to Prompt Builder and Agentforce? we recommend the following resources:

 

Prompt template created to assess emails and update data in Salesforce
 

Final Testing of the Flow

Once the beginning of our flow was set up and our prompt template was written, we had to do some final testing to get everything to work. We set up an action in our flow to trigger our prompt template pulling in the booking called earlier in our flow and the current email message of the loop.

Important Tip: When setting up this action, we ran into a small bug that made it unclear how to select the records we wanted from the flow. When trying to select the booking for example, Flow builder automatically brought the name in as {!Get_Booking.} and then prompted us to select an ID but then did not let us select an ID. To solve this, we had to just remove the trailing period following “Get_Booking” so it looked like {!Get_Booking} and then was able to pull in the appropriate records.

After setting up the entire flow and a few rounds of testing, the demo was complete!
 

Next Step: Build Your Own Flow with AI and Email Data

Thank you for taking the time to read about our AI demo. The only thing left to do is for you to go out and build your own flows with AI to automate tasks in your business. If you are an existing customer, we hope this article gives you the resources needed to go build flows of your own!

If you are not a Match My Email customer and interested in storing your email data in Salesforce in order to build flows with AI, our sales team would always love to chat: Book a Demo.
 

All Learning Resources for Tools Used in Demo

New to Flows? we recommend the following resources:

 

New to Prompt Builder and Agentforce? we recommend the following resources:

Read More From The Email Technology Blog