intercom / intercom-node

Node.js bindings for the Intercom API
https://developers.intercom.com
Other
366 stars 116 forks source link

I can not create a contact user. #353

Closed greg-md closed 1 year ago

greg-md commented 1 year ago

I tried to create a user based on the example from the readme, but it was created as a lead with missing most of the params.

const user = await client.contacts.createUser({
    externalId: '536e564f316c83104c000020',
    phone: '+48370044567',
    name: 'Niko Bellic',
    signedUpAt: 1638203719,
    lastSeenAt: 1638203720,
    isUnsubscribedFromEmails: true,
});

As a result, I got a Lead created with missing externalId, signedUpAt and lastSeenAt. Do I miss something?

PS: Until now our app was using v2 of the package, so now we are trying to migrate to v4, but nothing is working properly.

Also tried to send a message to an existing user, but it says that user is not found.

await client.messages.create({
    from: {
        id: 500000,
        type: 'admin'
    },
    to: {
        id: '501825',
        type: 'user'
    },
    messageType: 'inapp',
    body: 'This is a test message from v4 sdk'
});
colmdoyle commented 1 year ago

Have you tried updating the API version your app is targeting?

I ask because v4 of the SDK targets 2.6 of the API

greg-md commented 1 year ago

@colmdoyle The app is still using 1.0 version.

colmdoyle commented 1 year ago

That's your issue. In order to use the latest SDK, you also need to use the latest API version. We could probably do a better job of documenting that.

colmdoyle commented 1 year ago

The notion of a User or Lead as distinct objects was removed in 2.0 of the API

greg-md commented 1 year ago

So if I will create another app on Developer Hub, and use the v4 sdk, would it still work with old users?

greg-md commented 1 year ago

Is there a way to migrate all that without affecting existing data?

colmdoyle commented 1 year ago

So if I will create another app on Developer Hub, and use the v4 sdk, would it still work with old users?

Yes, you'll just need to use the Contacts API.

Is there a way to migrate all that without affecting existing data?

No migration needed, just use the new endpoints.

greg-md commented 1 year ago

Thank you. Seems like it worked with creating new auth token for newer api version.