Has anyone completed integration of chat app in their react typescript app

I am not able to create connection and channel as it is throwing me error - Uncaught (in promise) Error: Amity SDK (500000): Parameters validation error! &
xhr.js:247 POST https://api.eu.amity.co/api/v3/sessions 42

Hi @ManishDhameja

Can you please help :

  • share code snippets for reproduction
  • confirm the SDK version ?

Thank you

I am using react with typescript and all the files are in .tsx
I created a ascClient file where added connectCLient code.

import { connectClient } from ‘@amityco/ts-sdk’;

const sessionHandler: Amity.SessionHandler = {
sessionWillRenewAccessToken(renewal) {
renewal.renew();
},
};

export const handleConnect = async (userId: string, displayName: string) => {
await connectClient({ userId, displayName }, sessionHandler);
};

and in another file calling below function in handler to create channel but it is throwing error
POST https://api.eu.amity.co/api/v3/channels/conversation 422

const onConnect = async () => {
const query = await createQuery(createChannel, {
displayName: ‘chat’,
type: ‘conversation’,
userIds: [authState.userId, patientId],
metadata: {
data: ‘anything’,
},
});

    runQuery(query, result => console.log(result));
    setConnected(true);
};

And what exactly is this, it Is printing in my console -
Subscribed to topic 641026202e7580248eb41196
index.esm.js:20316 Subscribed to topic 641026202e7580248eb41196/smartfeed/6412ee74abcd767826cc2c89/channels
index.esm.js:20316 Subscribed to topic 641026202e7580248eb41196/smartfeed/6412ee74abcd767826cc2c89/messagefeeds
index.esm.js:20316 Subscribed to topic 641026202e7580248eb41196/smartfeed/6412ee74abcd767826cc2c89/messages
index.esm.js:20316 Subscribed to topic 641026202e7580248eb41196/user/6412ee74abcd767826cc2c89

Hi @ManishDhameja

  • by version, for example is it typescript 0.0.1 Beta.39?
    https://docs.amity.co/

  • thank you for the code snippet

@ManishDhameja

  1. Regarding connectClient, please check the api_key. You can only create a channel once connectClient succeeds.

  2. As for the logs, these are the topics that mqtt needs to connect to be able to receive certain RTE events that are required for the SDK. Note, these are not all the topics. For other events by domain. Ex: Channel you need to subscribe separately.

^0.0.1-beta.40 is the typescript version

Is there any sample app for react-typescript for 1-1 chat?

So to create multiple channels with different userIds, I need to disconnect client in last request and connect again to create a new channel?

I’m a little bit confused. Can you provide a use case where multiple users would use the same device to create multiple channels?

Just to clarify, I haven’t misunderstood the question.