Do mentions work with nickname or the userid?

Right now we are using the uuid we have for users, should we instead make it a “handle” or something more readable? Also, can userIds be updated?

Thanks!

Hi @John_Ottenlips,

Mentions require you to utilize a UserID, nicknames would not work. Additionally, UserIDs can not be updated after creation.

You could have the user mention the nickname, and the find the matching user in the channel and grab their UserID.

1 Like

Nice, so if they do @Some User, we can send their uuid up as a mention

@John_Ottenlips, My apologies. I overlooked that you were using the UIKit. In order for you to implement this, you’d have to utilize the onBeforeSendUserMessage prop on the Channel component. Here you’d implement your logic to check if the text contains @Nickname and then find the UserID for the user to which that nickname belongs.

1 Like

You can see an example of that prop being used in this snippet from the documentation:

// onBeforeSendUserMessage & onBeforeSendFileMessage & onBeforeUpdateUserMessage
const ChannelWithOnBeforeActions = ({ sdk }) => (
    <div style={{ height: '520px' }}>
        <Channel channelUrl={channelUrl}
            onBeforeSendUserMessage={(text) => {
                const params = new sdk.UserMessageParams();
                params.message = text + EXTRA_MESSAGE;
                params.data = DATA;
                return params;
            }}
            onBeforeSendFileMessage={(file) => {
                const params = new sdk.FileMessageParams();
                params.file = file;
                params.data = DATA;
                return params;
            }}
            onBeforeUpdateUserMessage={(text) => {
                const params = new sdk.UserMessageParams();
                params.message = text + MESSAGE_TO_UPDATE;
                params.data = DATA;
                return params;
            }}
        />
    </div>
)

const ConnectedChannel = withSendBird(ChannelWithOnBeforeActions, (store) => ({
    sdk: getSdk(store),
}))

export const OnBeforeActionsChannel = () => (
    <Sendbird appId={appId} userId={userId}> <ConnectedChannel />
    </Sendbird>
);