message.addReaction web v4 sdk - Invalid Parameters

I am running into a bug related to customizing messages, specifically manually triggering reactions using v4 of the web SDK.

This is the block of code I am running, as per the documentation here: React to a message in a group channel | Chat JavaScript SDK | Sendbird Docs

groupChannel
  ?.addReaction(message, emojiKey)
  .then((reactionEvent) => {
    if (reactionEvent) {
      message.applyReactionEvent(reactionEvent);
    }
  })
  .catch((error) => {
    console.error("ERROR", error);
  });

And I’m running into the following error:

ERROR SendbirdError: Invalid parameters.
    at new n (__bundle-3e5c2f79.js:149:7246)
    at Function.get (__bundle-3e5c2f79.js:149:10759)
    at c.eval (__bundle-de5ca068.js:128:180582)
    at eval (__bundle-3e5c2f79.js:149:2257)
    at Object.eval [as next] (__bundle-3e5c2f79.js:149:2362)
    at eval (__bundle-3e5c2f79.js:149:1278)
    at new Promise (<anonymous>)
    at r (__bundle-3e5c2f79.js:149:1023)
    at s.addReaction (__bundle-de5ca068.js:128:180218)

Below is an example of the parameters I am passing to the groupChannel.addReaction() call:

Group Channel (calling object):

{
    "_iid": "su-1113f8c2-738b-46ac-8481-b941ae5cdda5",
    "_name": "redacted_group_channel_name",
    "_createdAt": 1716411346000,
    "channelType": "group",
    "coverUrl": "https://file-us-1.sendbird.com/e0c892bffbad4180af623ed6110da001.png",
    "customType": "",
    "data": "",
    "isFrozen": false,
    "isEphemeral": false,
    "creator": null,
    "_messageCollectionLastAccessedAt": 0,
    "_url": "sendbird_group_channel_343808000_8712fce3cf5cceffa9fd4c3399d64fffff878aa0",
    "_unreadMemberStateMap": {},
    "_undeliveredMemberStateMap": {},
    "_typingStatus": {},
    "_lastMemberCountUpdated": 0,
    "_typingStarted": 0,
    "_typingEnded": 0,
    "isDistinct": false,
    "isSuper": false,
    "isBroadcast": false,
    "isExclusive": false,
    "isPublic": false,
    "isDiscoverable": false,
    "isChatNotification": false,
    "isAccessCodeRequired": false,
    "isPushEnabled": true,
    "unreadMessageCount": 0,
    "unreadMentionCount": 0,
    "totalUnreadReplyCount": 0,
    "members": [
        {
            "_iid": "su-1113f8c2-738b-46ac-8481-b941ae5cdda5",
            "userId": "17d32498-fee9-46fa-ad1d-bc4aabaaefff",
            "nickname": "redacted_1",
            "plainProfileUrl": "https://www.modal.io/images/chat-logo.png",
            "requireAuth": false,
            "metaData": {},
            "connectionStatus": "offline",
            "isActive": true,
            "lastSeenAt": -1,
            "preferredLanguages": null,
            "friendDiscoveryKey": null,
            "friendName": null,
            "restrictionInfo": {
                "restrictionType": null,
                "description": null,
                "endAt": -1,
                "remainingDuration": -1
            },
            "state": "joined",
            "role": null,
            "isMuted": false,
            "isBlockedByMe": false,
            "isBlockingMe": false
        },
        {
            "_iid": "su-1113f8c2-738b-46ac-8481-b941ae5cdda5",
            "userId": "150b9176-75c2-4a23-8e7a-ae6ad889a41d",
            "nickname": "redacted_2",
            "plainProfileUrl": "https://file-us-1.sendbird.com/profile_images/a224cbd982d54840878b0383af75cf42.png",
            "requireAuth": false,
            "metaData": {},
            "connectionStatus": "offline",
            "isActive": true,
            "lastSeenAt": -1,
            "preferredLanguages": null,
            "friendDiscoveryKey": null,
            "friendName": null,
            "restrictionInfo": {
                "restrictionType": null,
                "description": null,
                "endAt": -1,
                "remainingDuration": -1
            },
            "state": "joined",
            "role": null,
            "isMuted": false,
            "isBlockedByMe": false,
            "isBlockingMe": false
        },
        {
            "_iid": "su-1113f8c2-738b-46ac-8481-b941ae5cdda5",
            "userId": "580183b3-7d19-4e06-ae74-f14f7caa8e1d",
            "nickname": "redacted_3",
            "plainProfileUrl": "",
            "requireAuth": false,
            "metaData": {},
            "connectionStatus": "offline",
            "isActive": true,
            "lastSeenAt": -1,
            "preferredLanguages": null,
            "friendDiscoveryKey": null,
            "friendName": null,
            "restrictionInfo": {
                "restrictionType": null,
                "description": null,
                "endAt": -1,
                "remainingDuration": -1
            },
            "state": "joined",
            "role": null,
            "isMuted": false,
            "isBlockedByMe": false,
            "isBlockingMe": false
        },
        {
            "_iid": "su-1113f8c2-738b-46ac-8481-b941ae5cdda5",
            "userId": "e17a20f3-1dd5-4cfd-9f7a-3837ffc52738",
            "nickname": "redacted_4",
            "plainProfileUrl": "",
            "requireAuth": false,
            "metaData": {},
            "connectionStatus": "offline",
            "isActive": true,
            "lastSeenAt": -1,
            "preferredLanguages": null,
            "friendDiscoveryKey": null,
            "friendName": null,
            "restrictionInfo": {
                "restrictionType": null,
                "description": null,
                "endAt": -1,
                "remainingDuration": -1
            },
            "state": "joined",
            "role": null,
            "isMuted": false,
            "isBlockedByMe": false,
            "isBlockingMe": false
        },
        {
            "_iid": "su-1113f8c2-738b-46ac-8481-b941ae5cdda5",
            "userId": "4c4209c5-dece-48fa-919d-9a6f85d32417",
            "nickname": "redacted_5",
            "plainProfileUrl": "https://file-us-1.sendbird.com/profile_images/76be1afc00da4cf3ac0b53c17473e6b9.png",
            "requireAuth": false,
            "metaData": {},
            "connectionStatus": "online",
            "isActive": true,
            "lastSeenAt": 0,
            "preferredLanguages": null,
            "friendDiscoveryKey": null,
            "friendName": null,
            "restrictionInfo": {
                "restrictionType": null,
                "description": null,
                "endAt": -1,
                "remainingDuration": -1
            },
            "state": "joined",
            "role": null,
            "isMuted": false,
            "isBlockedByMe": false,
            "isBlockingMe": false
        }
    ],
    "memberCount": 5,
    "joinedMemberCount": 5,
    "hiddenState": "unhidden",
    "lastMessage": {
        "_iid": "su-1113f8c2-738b-46ac-8481-b941ae5cdda5",
        "channelType": "group",
        "messageType": "user",
        "mentionType": "users",
        "mentionedUsers": [],
        "mentionedUserIds": [],
        "metaArrays": [],
        "extendedMessage": {},
        "createdAt": 1718387737826,
        "updatedAt": 0,
        "channelUrl": "sendbird_group_channel_343808000_8712fce3cf5cceffa9fd4c3399d64fffff878aa0",
        "data": "{\"blocks\":[{\"key\":\"7cm52\",\"text\":\"Even a code block is getting sent!\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}},{\"key\":\"fonsv\",\"text\":\"const rich = \\\"text\\\";\",\"type\":\"code-block\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}",
        "customType": "draft-js-rich-text",
        "mentionedMessageTemplate": "",
        "parentMessage": null,
        "silent": false,
        "isOperatorMessage": false,
        "threadInfo": null,
        "reactions": [],
        "appleCriticalAlertOptions": null,
        "scheduledInfo": null,
        "suggestedReplies": null,
        "myFeedback": null,
        "myFeedbackStatus": "NOT_APPLICABLE",
        "forms": null,
        "_isContinuousMessages": false,
        "_scheduledStatus": null,
        "messageId": 3637810993,
        "parentMessageId": 0,
        "ogMetaData": null,
        "reqId": "rq-bd832e53-5f9e-4fe2-b1d1-0de5060a1652",
        "replyToChannel": false,
        "errorCode": 0,
        "sender": {
            "_iid": "su-1113f8c2-738b-46ac-8481-b941ae5cdda5",
            "userId": "4c4209c5-dece-48fa-919d-9a6f85d32417",
            "nickname": "redacted-5",
            "plainProfileUrl": "https://file-us-1.sendbird.com/profile_images/76be1afc00da4cf3ac0b53c17473e6b9.png",
            "requireAuth": false,
            "metaData": {},
            "connectionStatus": "nonavailable",
            "isActive": true,
            "lastSeenAt": null,
            "preferredLanguages": null,
            "friendDiscoveryKey": null,
            "friendName": null,
            "isBlockedByMe": false,
            "role": "none"
        },
        "sendingStatus": "succeeded",
        "message": "Even a code block is getting sent!\nconst rich = \"text\";",
        "messageParams": null,
        "translations": {},
        "translationTargetLanguages": [],
        "messageSurvivalSeconds": -1,
        "plugins": [],
        "_poll": null
    },
    "messageOffsetTimestamp": 0,
    "messageSurvivalSeconds": -1,
    "myMemberState": "joined",
    "myRole": "none",
    "myMutedState": "unmuted",
    "myLastRead": 1718413556025,
    "myCountPreference": "all",
    "myPushTriggerOption": "default",
    "inviter": null,
    "invitedAt": 1716411346292,
    "joinedAt": 1716411346,
    "pinnedMessageIds": [],
    "lastPinnedMessage": null,
    "_pinnedMessagesUpdatedAt": 0,
    "_myMutedRemainingTime": -1,
    "url": "sendbird_group_channel_343808000_8712fce3cf5cceffa9fd4c3399d64fffff878aa0",
    "name": "Sapient Test Group",
    "createdAt": 1716411346000
}

Message:

{
    "_iid": "su-050732b5-7f0e-4dfb-bfb1-0ea93edb9062",
    "channelType": "group",
    "messageType": "user",
    "mentionType": "users",
    "mentionedUsers": [],
    "mentionedUserIds": [],
    "metaArrays": [],
    "extendedMessage": {},
    "createdAt": 1718330211241,
    "updatedAt": 0,
    "channelUrl": "sendbird_group_channel_343808000_8712fce3cf5cceffa9fd4c3399d64fffff878aa0",
    "data": "{\"blocks\":[{\"key\":\"b5d0r\",\"text\":\"sending a rich text message to test out. it won't appear as rich text to you yet!\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[{\"offset\":10,\"length\":10,\"style\":\"BOLD\"}],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}",
    "customType": "draft-js-rich-text",
    "mentionedMessageTemplate": "",
    "parentMessage": null,
    "silent": false,
    "isOperatorMessage": false,
    "threadInfo": null,
    "reactions": [],
    "appleCriticalAlertOptions": null,
    "scheduledInfo": null,
    "suggestedReplies": null,
    "myFeedback": null,
    "myFeedbackStatus": "NOT_APPLICABLE",
    "forms": null,
    "_isContinuousMessages": false,
    "_scheduledStatus": null,
    "messageId": 3636360438,
    "parentMessageId": 0,
    "ogMetaData": null,
    "reqId": "rq-f338bfc2-2fc2-4238-bdfb-83d9743e2d77",
    "replyToChannel": false,
    "errorCode": 0,
    "sender": {
        "_iid": "su-050732b5-7f0e-4dfb-bfb1-0ea93edb9062",
        "userId": "4c4209c5-dece-48fa-919d-9a6f85d32417",
        "nickname": "redacted-5",
        "plainProfileUrl": "https://file-us-1.sendbird.com/profile_images/76be1afc00da4cf3ac0b53c17473e6b9.png",
        "requireAuth": false,
        "metaData": {},
        "connectionStatus": "nonavailable",
        "isActive": true,
        "lastSeenAt": null,
        "preferredLanguages": null,
        "friendDiscoveryKey": null,
        "friendName": null,
        "isBlockedByMe": false,
        "role": "none"
    },
    "sendingStatus": "succeeded",
    "message": "sending a rich text message to test out. it won't appear as rich text to you yet!",
    "messageParams": null,
    "translations": {},
    "translationTargetLanguages": [],
    "messageSurvivalSeconds": -1,
    "plugins": [],
    "_poll": null
}

emojiKey:
"sendbird_emoji_laughing"


Relevant versions:

"@sendbird/chat": "^4.11.0"
"@sendbird/uikit-react": "^3.12.1"
"react": "^18.2.0"

Could you help me determine the issue? Thank you!

Hi @nathan_modal.io!

@sendbird/uikit-react has @sendbird/chat as a dependency, so there’s no need to install @sendbird/chat separately. Could you try removing it and testing again?

Thanks Airen; I’ve deleted the sendbird-chat from my package.json and it continues to error in the exact same way.

Also confirming that I have gone through trying to remove the package-lock.json and have done fresh installs using these new installations (and not having the redundant version of sendbird-chat). Still the same issue :confused:

Resolved.

Issue was using groupChannel via sb.groupChannel.getChannel(channelId).

Correct solution: using uikit access to currentChannel object via accessing exposed context:

const { currentChannel } = useGroupChannelContext();

And modifying the code to use currentChannel like so:

currentChannel
  ?.addReaction(message, emojiKey)
  .then((reactionEvent) => {
    if (reactionEvent) {
      message.applyReactionEvent(reactionEvent);
    }
  })
  .catch((error) => {
    console.error("ERROR", error);
  });
1 Like