stream-chat-js icon indicating copy to clipboard operation
stream-chat-js copied to clipboard

how to connect to a chat from server side for Bot app?

Open dcsan opened this issue 2 years ago • 0 comments

how do i connect to a chat from server side to implement a bot? I want to listen/read and send/write messages.

I tried this

    await chatClient.connectUser(
      {
        id: AppConfig.ADMIN_BOT_ID,
        allowServerSideConnect: true,
      },
      userToken
    );

but get a warning

Please do not use connectUser server side. connectUser impacts MAU and concurrent connection usage and thus your bill. If you have a valid use-case, add "allowServerSideConnect: true" to the client options to disable this warning.

is this the wrong way to do a server side connection? It seems to work. how do I add to the 'client options' ?

If I don't connectUser I get this error:

Error: StreamChat error code 4: QueryChannels failed with error: "Watch or ChatPresence requires an active websocket connection, please make sure to include your websocket connection_id"

dcsan avatar Jul 31 '23 22:07 dcsan