Skip to main content

i am trying to find a workaround so when an email is sent to a QUE in Salesforce it will send back an email with Outlook, with case # and info to the original sender (works fine). Problem is when they reply it will create a loop and create a new case. When salesforce send the automated email back (corporate wont allow our que to have automated return emails) it includes a Thread:: so when the user replies back its added to the case. Question: how do i add/find the thread to the email or how can i send an email from SalesForce so it adds the thread? Thanks

Welcome to the community, ​@Jazzy3—great to have you here! 🎉 

If I’m understanding this correctly you’ve built a Zap that triggers when an email is sent to a QUE in Salesforce and uses an Microsoft Outlook (Send Email?) action which contains the case # and info to the original sender but, if the sender replies to that email it’s seen as a new case, instead of a reply to an existing case—is that correct?

If so, is there a thread ID or case reference of some kind available when the Zap triggers?

Asking as it looks like you could potentially use a Create Record action with the Email Message object selected to send a reply that has a specific case and/or thread selected:

23f535940a5fbcf883f447886d0e5548.png
 

f7eef73b752e65c261fae309362234b0.png
 

So I’m thinking that if you use that instead of the Microsoft Outlook action to send the email to the original sender, it should ensure that when/if they they reply to the email, their reply gets added into the case thread. 

And if there isn’t a thread ID or reference available, I’d suggest using a Find Record action to find the original email in the QUE to see if gives the ID/reference which can then be passed over to the Create Record action.

Do you think that sort of approach could work?


You can try removing the trigger step and adding it again and then submitting a test form, 

Or

You can just skip test add a dummy action afterwards and publish the zap, make a form submission and review the zap history to see whether the form data is coming in, You can then use that run as a trigger step.


​@SamB the Create Record action with Email Message option creates an email in the activity, but doesnt actually send the email. it appears only when it send an email will it attach/show the thread. so the trick woudl be how do we get Zapier to have Salesforce send the emali and not use Outlook?


Sorry to hear the Create Record action didn’t send out the email as hoped, ​@Jazzy3.

I did some further digging into email threading in Salesforce and it seems that if lightning threading is enabled then you may be able to get the reply added to the correct case threads if the original email subject and body are included in the email that the Send Email action sends:

5c92cde1abfa7531efc8d96e009c1939.png

If that doesn’t work, the only other way I can think of would be to try using an API Request action to send the email via Salesforce’s API. It’s a bit more advanced as you’d need to reference their API but happy to help troubleshoot if you run into any trouble with it. 


Send Action, assuming you mean Send Email, there is no way to connect it to the case, also tried using the same subject and body and didn’t work.. I did use Create A Record and was able to add an email to the Emails of the case but it didn’t actually send an email nor did it add the ThreadID. if i manually send an email from the case through Salesforce the ThreadID will show up. i am at a total loss of how to use the API Request Beta and not sure or syntax for URL or any type of Query string parameters.


Ah, yes sorry for the typo there ​@Jazzy3. I’ve updated my reply to make it clearer for anyone that might come this thread in the future.

I’ve been doing some testing to see if I could get a working example using the API Request action, but unfortunately wasn’t able to get it to send the email as expected.

As an alternative, you could potentially BCC a Salesforce routing email address when sending the customer email. 🤔 Thinking that would have Salesforce automatically create the case and associate replies using their Email-to-Case functionality. I’ve not been able to test that setup though so I can’t confirm for certain if the thread IDs would align correctly when the customer replies, but it might be worth trying on your end to see if it works with your Salesforce setup.

The only other workaround I can think of to would be to set up an automation or rule in Salesforce to detect and merge duplicate cases based on the subject and sender. It’s not ideal I know, but hopefully it would help to automatically merge the cases that get created from the replies—do you think that could be a viable option?


it appears that without support from Corporate this cannot be accomplished. Apex, Workflow, allowing salesforce to automate the return email (said there are limits of how many they are allowed). the only other thing i can think of would be Webhooks or API but i am totally green to them. 


Thanks for the update, ​@Jazzy3. Didn’t want this to go unsolved so I’ve been doing a lot more experimenting on my end and, with the help of Salesforce’s API documentation here, finally managed to get the request to send without error. 🎉

That said, I didn’t actually receive the email but I’m hoping that’s more to do with the Salesforce instance I was testing with not having the right email delivery options/settings enabled—as there were no errors on the request that was made.

This was the set up I used:

63a1f2e31ed40f714343213488608f75.png

And managed to get a successful 200 response back from Salesforce:

a39c2fd1285eea0548b086a02dd6aad6.png


For the URL you’d want to replace ™salesforcedomain] with the domain of your Salesforce: https://osalesforcedomain].my.salesforce.com/services/data/v60.0/actions/standard/emailSimple and for the Body of the API request you’d use this format:

{
"inputs": g
{
"emailBody": "The content of your email message goes here",
"emailAddresses": "recipientsemail@goeshere.com",
"emailSubject": "The subject for your email goes here",
"senderType": "CurrentUser"
}
]
}

Could you give that set up a try in your Zap and let me know whether you receive the email it sends? 


ok it worked and i received the email but the email has no connection to the case and the Thread ID. i need Salesforce (or Outlook) to send an email with the Thread attached so when someone replies it attaches to the case. Thank you for your continued help with this. i believe its addThreadingTokenToBody and/or addThreadingTokenToSubject and it appears to be referring to Apex which i don’t believe i can do without corporate getting involved. Need to pull ThreadID for the case from salesforce


Thanks for testing that out, ​@Jazzy3. So glad you were able to receive the email on your end—we’re almost there! 😅

The addThreadingTokenToBody and addThreadingTokenToSubject parameters should be able to use the Email-to-Case functionality to link the email replies to the correct case. It seems the Apex Email Service would only be required if you’re wanting to link them to other records: 

51b442d30331eb5d164baad57042fd77.png
 

We’ll still need to use that Create Record action you made earlier to create the actual case in Salesforce. Then you can map the case’s ID to the relatedRecordId field in the request:

fb343c3f9e09977b2a5fc7f9d535025c.png
 

That way the threading token fields should be able to automatically generate the correct tokens based on the related record ID (case ID).

You’d want to include those fields in the request like this:

{
"inputs": -
{
"emailBody": "The content of your email message goes here",
"emailAddresses": "recipientsemail@goeshere.com",
"emailSubject": "The subject for your email goes here",
"senderType": "CurrentUser",
"relatedRecordId": "Case_ID_goes_here",
"addThreadingTokenToBody": true,
"addThreadingTokenToSubject": true
}
]
}

Can you give that a try and keep me posted on how it goes?


your a genius, thank you so much. still a part left. only way i can get it to connect to the case is if i send the email to operations@… (that is the Que to Email address in Salesforce). if i send it to the originator of the case me,(also current user) it does not attach. Ideas? maybe change sender type?


You’re very welcome, ​@Jazzy3—so pleased my suggestion helped! 🤗 

For the part you’re still working on I think you’re on the right track. Changing the senderType to OrgWideEmailAddress and specifying the senderAddress as the operations@… address could potentially sort it 🤔

Can you try updating the request like so:

{
"inputs": g
{
"emailBody": "The content of your email message goes here",
"emailAddresses": "recipientsemail@goeshere.com",
"emailSubject": "The subject for your email goes here",
"senderType": "OrgWideEmailAddress",
"senderAddress": "operations@emailgoeshere.com",
"relatedRecordId": "Case_ID_goes_here",
"addThreadingTokenToBody": true,
"addThreadingTokenToSubject": true
}
]
}

Fingers crossed that’ll fix it! 🤞


Org Wide email provided is not valid. seems corporate wont allow the address to be added. another road block

 


That’s unfortunate, ​@Jazzy3. Hmm 🤔 the only way I can think of to get around that would be to create a user account in Salesforce that has the same email as that operations@… email (assuming it doesn’t already have a user account using it?). Then add a new app connection for that account and connect the API Request action to it.

With that you’d need to change the senderType back to be the CurrentUser, and remove the senderAddress from the request. So it’ll look like this again:

{
"inputs": <
{
"emailBody": "The content of your email message goes here",
"emailAddresses": "recipientsemail@goeshere.com",
"emailSubject": "The subject for your email goes here",
"senderType": "CurrentUser",
"relatedRecordId": "Case_ID_goes_here",
"addThreadingTokenToBody": true,
"addThreadingTokenToSubject": true
}
]
}

Keep me updated on how it goes, excited to hear how you get on with this!


corporate is not willing to do that either. will post the resolution once i get corporate to agree to do something. Thank you so much, you helped me tremendously, even to understand Zapier better.


Sorry to hear they didn’t go for that approach either, ​@Jazzy3. I really enjoyed working on this with you—tricky challenges like this are always a fun puzzle to try and solve! 😄 So glad to hear it helped deepen your understanding of Zapier. 🙌

Looking forward to hearing how it goes with corporate. Feel free to reach out if anything else comes up in the meantime!


what would be the syntax to add HTML to the message body? i believe if i use the ccRecipientAddressList it will connect the emails to the case, problem is alot of emails goes to that box, maybe setup a filter or something in outlook.

 


Good question, ​@Jazzy3! 🙂

To use HTML in the email, I’d have thought that you’d need to include the sendRichBody input field in the body of the request and set it to true. Then you’d add the relevant HTML tags to the message in the emailBody field (be sure to escape any quote marks used inside the HTML tags by putting a backslash in front of them e.g. \"). For example:

{
"inputs": b
{
"emailBody": "<p>The content of your email message goes here with some <a href=\"https://www.link.com\">HTML tags</a>included".</p>",
"emailAddresses": "recipientsemail@goeshere.com",
"emailSubject": "The subject for your email goes here",
"senderType": "CurrentUser",
"relatedRecordId": "Case_ID_goes_here",
"addThreadingTokenToBody": true,
"addThreadingTokenToSubject": true,
"sendRichBody": true
}
]
}

i believe if i use the ccRecipientAddressList it will connect the emails to the case, problem is alot of emails goes to that box, maybe setup a filter or something in outlook."

Great idea! Similar to the bcc’ing the email, using the ccRecipientAddressList should send a copy of the email to the cc’d address. I’m not super familiar with all Outlook’s features but seems like is should indeed be possible to filter the emails automatically using rules in Outlook: Manage email messages by using rules in Outlook

Hope it goes well—keep us updated on how you get on! 🤞


Reply