createChannel giving SendBirdException: Invalid parameter

HI Folks,

Hope u r in good health,

I am STUCK, Kindly help in any possible way

Here’s the usecase : we have users and customers, when the customer clicks on SUPPORT we check if he is new or old , if old we already have his channel url and voila, but in case of new we create a channel on the fly with the available support team users. the below code is for new user, kindly give a look and let me know why i am getting INVALID PARAMETER ERROR

import { sendBirdSelectors, useSendbirdStateContext } from '@sendbird/uikit-react';

const context = useSendbirdStateContext();
const sdkInstance = sendBirdSelectors.getSdk(context);

const getAllApplicationUsers = async () => {
    try {
        const userQuery = sdkInstance.createApplicationUserListQuery({ limit: 100 });
        const users = await userQuery.next();
        return [users, null];
    } catch (error) {
        return [null, error];
    }
  }

  const handleUsers = async () => {
    const [users, error] = await getAllApplicationUsers();
    const applicationUsers = users?.length > 0 && users.map(user => user.userId);
    return applicationUsers;
  }

const createChannel = async (groupChannelParams) => {
    try {
        const groupChannel = await sdkInstance.GroupChannel.createChannel(groupChannelParams);
        return [groupChannel, null];
    } catch (error) {
        return [null, error];
    }
  }

  const handleCreateChannel = async () => {
    const applicationUsers = await handleUsers();
    const groupChannelParams = {
      invitedUserIds: applicationUsers,
      name: 'Group Channel',
      coverUrl: 'https://media.glassdoor.com/sql/269361/welldoc-squarelogo-1609788656262.png',
      operatorUserIds: applicationUsers,
      customType: 'Case Managers',
      isDistinct: true,
    }
    const [groupChannel, error] = await createChannel(groupChannelParams);
  }

useEffect(() => {
    handleCreateChannel();
}, [sdkInstance]);

this is another ticket facing issue

Hello @shahmed, and welcome to the Sendbird Community!

I added your code to this example on codesandbox.io.

On line 31 of the Chat.jsx file, changing sdkInstance.GroupChannel.createChannel() to sdkInstance.groupChannel.createChannel() corrected the issue and created the channel with no errors.

1 Like