APIs & Integrations

ArnieK
Participante | Partner nivel Elite
Participante | Partner nivel Elite

Create email engagement - NodeJS

resolver

Hi everyone,

 

I am trying to develop a NodeJS program to create email engagements on a client's Hubspot. I have done everything but the creation of the engagement. I have found a sample code of a note engagement but I can't find one for email engagements.

 

Does anyone have a solution for this?

 

Thank you in advance,

Arnie

0 Me gusta
1 Soluciones aceptada
dennisedson
Solución
Equipo de producto de HubSpot
Equipo de producto de HubSpot

Create email engagement - NodeJS

resolver

Hey @ArnieK 

I gather that you found the sample on node tab of the dev docs here.

If you go back to the json and look at the example, scroll down to after the note example and you will see the meta that you need for email.   You would replace the note meta that is provided in the node example with the email metadata

Example:

"metadata": {
    "from": {
      "email": "email@domain.com",
      "firstName": "First",
      "lastName": "Last"
    },
    "to": [
      {
        "email": "contact name <test@test.com>"
      }
    ],
    "cc": [],
    "bcc": [],
    "subject": "This is the subject of the email",
    "html": "<div>This is the body of the email</div><div><br></div><div>-Me</div>",
    "text": "This is the body of the email\n\n-Me"
}

Ver la solución en mensaje original publicado

3 Respuestas 3
webdew
Guía | Partner nivel Diamond
Guía | Partner nivel Diamond

Create email engagement - NodeJS

resolver

Hi @ArnieK ,

You can create an email engament with the same api just need to change the object type. consider the following code as an example. var request = require("request");

var options = { method: 'POST',
url: 'https://api.hubapi.com/engagements/v1/engagements',
qs: { hapikey: 'demo' },
headers:
{'Content-Type': 'application/json' },
body:
{ engagement:
{ active: true,
ownerId: 1,
type: 'EMAIL',
timestamp: 1409172644778 },
associations:
{ contactIds: [ 11877974 ],
companyIds: [],
dealIds: [],
ownerIds: [] },
attachments: [ { id: 4241968539 } ],
metadata: { body: 'note body' } },
json: true };

request(options, function (error, response, body) {
if (error) throw new Error(error);

console.log(body);
}); For more info please refer to this doc:https://legacydocs.hubspot.com/docs/methods/engagements/create_engagement

Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regard.

dennisedson
Solución
Equipo de producto de HubSpot
Equipo de producto de HubSpot

Create email engagement - NodeJS

resolver

Hey @ArnieK 

I gather that you found the sample on node tab of the dev docs here.

If you go back to the json and look at the example, scroll down to after the note example and you will see the meta that you need for email.   You would replace the note meta that is provided in the node example with the email metadata

Example:

"metadata": {
    "from": {
      "email": "email@domain.com",
      "firstName": "First",
      "lastName": "Last"
    },
    "to": [
      {
        "email": "contact name <test@test.com>"
      }
    ],
    "cc": [],
    "bcc": [],
    "subject": "This is the subject of the email",
    "html": "<div>This is the body of the email</div><div><br></div><div>-Me</div>",
    "text": "This is the body of the email\n\n-Me"
}

ArnieK
Participante | Partner nivel Elite
Participante | Partner nivel Elite

Create email engagement - NodeJS

resolver

Hi @dennisedson,

 

That is what I found yes but your solution was perfect! Thank you for your help!

 

Regards,

Arnold