Question regarding adding participants
NamitYadav opened this issue ยท 2 comments
Hello,
I have a use case where I need to add a new participant to an existing chat only when they click on the chat icon(I am using the popup). However i get this message when i try to do that:
You are trying to read a conversation, which doesn't exist or doesn't belong to you. Make sure that the conversation exists or you call conversation.setParticipant(me) before mounting the TalkJS UI.
Is there a way to add a new participant after the Chat component has mounted?
Thanks in advance!
Yes, there is! You're looking for the setParticipant method. Used as follows:
var conversation = session.getOrCreateConversation(<your_conversation_ID>);
conversation.setParticipant(<current_user>);
var popup = session.createPopup(conversation);
popup.mount();
Or, if the popup is already mounted, you just go through the same motions but you select the conversation:
var conversation = session.getOrCreateConversation(<your_conversation_ID>);
conversation.setParticipant(<current_user>);
var popup = session.createPopup(conversation);
popup.select(conversation);
Note: we recommend using the chat on talkjs.com for support - you'll usually get an answer there faster than here. We prefer to use these issues for actual problems with the examples in this repo. Let us know if this helsp!
Thanks for your help! I will keep in mind to use chat for further support ๐