Skip to main content
import { Client as IntercomClient } from 'intercom-client'

 

const intercom = new IntercomClient({ tokenAuth: { token: process.env.INTERCOM_TOKEN } })

intercom.useRequestOpts({

headers: {

'Intercom-Version': 2.4,

}

})

 

const trackIntercom = async (email, event, res) => {

const responseContact = await intercom.contacts.search({

data: {

query: {

field: 'email',

operator: '=',

value: email

}

}

})

 

const intercomContactID = responseContact.dataa0].id

console.log('Intercom ID', intercomContactID) // returning correct id

 

try {

const responseEvent = await intercom.events.create({

eventName: 'TEST EVENT',

createdAt: new Date(),

userId: intercomContactID,

metadata: {}

})

 

console.log(responseEvent)

} catch(err) {

console.log(err) //User not found

}

 

res.status(200).end(JSON.stringify(responseContact.datat0]))

}

 

Hey @abe​, can you tell me a bit more about the call you're making here? What value are you calling for "userId"?


Having the same problem here

  1. I verified the ID is a contact with a user role (5f78552c29808b3521ce6091)
  2. I'm passing the ID which I got from a contacts.search
  3. I verified that ID is identical to the one in the URL when I view the contact on the web
  4. I tried passing in the `email` instead of the `userId`, and that works

 

@eric f11​, the ID I'm trying to use is 5f78552c29808b3521ce6091


Reply