AWS Chime Messaging: How to add a new user to a channel using the JavaScript SDK

547 Views Asked by At

I'm building the back-end of a meeting app that will use AWS Chime Messaging SDK for JavaScript. The idea is that when a user enters a meeting, an AppInstanceUser is created and associated with the Channel of that meeting.

Creating the channel and associating the user with it looks quite simple with the JavaScript SDK, however I can't find a way to create the user other than through the CLI, which I don't think is the correct way, because I need to create a new AppInstanceUser for each new user.

How should I do this? Is there a method to create the AppInstanceUser using the SDK that I didn't find? Or is there a way to add the new user to the channel without creating a new AppInstanceUser?

2

There are 2 best solutions below

0
On

I am not very familiar with how chime sdk meeting works.

But If you application requires users to log in to the application, You would create an AppInstanceUser for the user during their onboarding using their userId (example : sub if you're using cognito or database primary key) and associate that user with the AppInstanceUser. (example : by storing this in a database column and/or a cognito attribute)

So whenever a meeting is created you could add all the AppInstanceUsers of the meeting a ChannelMembership for the meeting channel.

https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-chime-sdk-messaging/index.html - Chime Messaging Client allows you to do things like Adding Channel Membership

https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-chime-sdk-identity/index.html - Chime Identity Client allows you to do things like creating AppInstanceUsers

0
On

AWS SDK provides a client for creating AppInstanceUser's. If you are using NodeJS, you can access it with aws-sdk/clients/chime. After you initialize the client, you can call createAppInstanceUser, provide it your AppInstanceArn, AppInstanceUserId and create your users, associate them to channels with createChannelMembership, etc.

Last note, you still have to save your AppInstanceUserArn in your user data, then use the stored ARNs in your application, client or server (at least that is my experience).