⚙ Operations Hub

ChrisChiha
Contributor

Can I trigger an email through custom code action inside my workflow ?

Hello,
 
My current scenario requires triggering an email through my custom code. The normal "Send Email" action is not applicable in my scenario as this is a deal based workflow and i am fetching an email address from the deal so i can send him an email.
 
Noting : I have to use deal-based workflow as my email contains personalized tokens from the Deal object.
 
So far my custom code is working great. I am able to fetch the email addresses from the enrolled deals and i am storing them in variables in the code.
My question is, is there a way or a specific hubspot API that i can call in my code to trigger a "send email" action from my custom code to the fetched contact ?

(Ideally if contact-based workflow accepted emails with personalized tokens from deals, my scenario would be simple, but i need a workaround for this to work.)
 
I read about the Single Send API, but how is it possible to pass the to email address and email template id as parameters to this API ?
 
Thank you in advance !

0 Upvotes
ChrisChiha
Contributor

Can I trigger an email through custom code action inside my workflow ?

hubspotClient.apiRequest({
method: 'POST',
path: `/email/public/v1/singleEmail/send?hapikey=${process.env.HAPIKEY}`,
body:
{
"emailId": 19597989,
"message": {
"to": `${customerEmail}`,
},
 
"customProperties": [
{
"name": "Bank",
"value": "Bank Name"
}
]
}
});
   
   
 
I would like to know specifically if i pass the properties this way, will the email body populate the personalization tokens. 
I would like to know if this works before finalizing any purchace on the transac addon. I don't have any access to test if my case works or not.
  
Scenario:
Deal has a property "country"
I can fetch this property to my custom code.
I need to pass this property in the body of my single send API, so that it will populate the country personalization token inside my email.
0 Upvotes
JenBergren
Guide | Diamond Partner
Guide | Diamond Partner

Can I trigger an email through custom code action inside my workflow ?

Thanks for the tag @JenWeiss ! A few of my team members have been digging into APIs recently so I'll tag them in to see if they have advice:
@jamesle @jspencerdav 


Thanks!
Jen Bergren
Sr. Operations Manager
Remotish -- A HubSpot RevOps and WebOps Agency
JenWeiss
HubSpot Moderator
HubSpot Moderator

Can I trigger an email through custom code action inside my workflow ?

Hi @ChrisChiha

 

Thank you so much for reaching out to us! 

 

I would like to tag some of our experts into this since they would be able to provide further insight @JenBergren , @warrendavey , and @Drew_Cohen

 

Best,

@JenWeiss