assistant-conversation-nodejs icon indicating copy to clipboard operation
assistant-conversation-nodejs copied to clipboard

User ID

Open shotamakino opened this issue 4 years ago • 2 comments

I don't see any ID property on the User class but is there a way to retrieve this somewhere, or is there an equivalent/proxy for this?

shotamakino avatar Dec 14 '20 16:12 shotamakino

@shotamakino You can make your own -

import { ConversationV3 } from "@assistant/conversation";
import { v4 as uuidv4 } from "uuid";

export const userId = (conv: ConversationV3): string => {
  if (!conv.user.params.userId) {
    const newUserId = uuidv4();
    conv.user.params.userId = newUserId;
  }

  return conv.user.params.userId as string;
};

kkocel avatar Jul 06 '21 09:07 kkocel

kkocel is correct there is no inherent user identifier but you can generate one and place it in user storage.

Fleker avatar Jul 07 '21 17:07 Fleker