I’m using the official NodeJS v3 SDK and I can’t find a way to create engagements, specifically notes and tasks. There’s nothing in the docs about this, and even looking through the SDK source code I can’t find any references to creating engagments.
How can I achieve this with the latest version of the node SDK?
Hey @philiplindberg
Thanks for adding the question!
Going to bring in a smart fellow from the community to see if we can get you an answer
@kierana ! hello, friend! Do you have thoughts?
Thanks!!
d
kierana
September 23, 2020, 1:56pm
3
In the examples folder you can get a rough idea of how to create an Engagement:
const response = await hubspotClient.apiRequest({
path: `/engagements/v1/engagements`,
method: 'POST',
body: payload,
})
const id = _.get(req, 'params.id')
if (_.isNil(id)) {
return res.redirect('/error?msg=Missed contact')
}
res.render('engagements', { id })
} catch (e) {
handleError(e, res)
}
})
app.post('/contacts/:id/engagement', async (req, res) => {
try {
const id = _.get(req, 'params.id')
let payload = _.clone(req.body)
payload = _.set(payload, 'metadata.startTime', toDate(_.get(payload, 'metadata.startTime')))
payload = _.set(payload, 'metadata.endTime', toDate(_.get(payload, 'metadata.endTime')))
// Create an Engagement
// POST /engagements/v1/engagements
// https://developers.hubspot.com/docs/methods/engagements/create_engagement
console.log('Calling apiRequest API method. Create contact engagement')
Find more detail on what you need to supply as the body/etc:
Yep, that did it. Thanks!