I am new to Talk.js and am learning currently. I ran into an error where I use the classic inbox and every user that goes on uses the same account in the 1:1 chat. I loaded the library in my HTML already.
Talk.ready.then(function () {
var me = new Talk.User({
id: '111112',
name: 'sus',
email: '[email protected]',
photoUrl: 'https://demo.talkjs.com/img/alice.jpg',
welcomeMessage: 'Hello',
});
window.talkSession = new Talk.Session({
appId: 'HIDDEN',
me: me,
});
var other = new Talk.User({
id: '111111',
name: 'sussy',
email: '[email protected]',
photoUrl: 'https://demo.talkjs.com/img/sebastian.jpg',
welcomeMessage: "Hello"
});
var conversation = talkSession.getOrCreateConversation(
Talk.oneOnOneId(me, other)
);
conversation.setParticipant(me);
conversation.setParticipant(other);
var inbox = talkSession.createInbox({ selected: conversation });
inbox.mount(document.getElementById('talkjs-container'));
});
<!-- minified snippet to load TalkJS without delaying your page this is basicly the contaner and the loading-->
<script>
(function(t,a,l,k,j,s){
s=a.createElement('script');s.async=1;s.src="https://cdn.talkjs.com/talk.js";a.head.appendChild(s)
;k=t.Promise;t.Talk={v:3,ready:{then:function(f){if(k)return new k(function(r,e){l.push([f,r,e])});l
.push([f])},catch:function(){return k&&new k()},c:l}};})(window,document,[]);
</script>
<!-- container element in which TalkJS will display a chat UI -->
<div id="talkjs-container" style="width: 90%; margin: 30px; height: 500px">
<i>Loading chat...</i>
</div>
<script src="script.js"></script>
It doesn't work because I did not put in my real application id, If you want to run it yourself, sign up or sign in to talkJs and insert your id in. (test app id where "BLOCKED " is)
CodePudding user response:
