Skip to main content
Answered

API returns user not found when the ID is correct


  • New Participant
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.data[0].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.data[0]))
}

 

Best answer by Eric Fitz

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

View original
Did this topic help you find an answer to your question?

2 replies

Eric Fitz
Employee
Forum|alt.badge.img+5
  • Employee
  • 1630 replies
  • Answer
  • March 28, 2022

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


  • New Participant
  • 1 reply
  • June 30, 2022

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings