[NEW] Additional Livechat iFrame API's#10918
Conversation
|
Hi guys, any ETA for this? |
|
@Leen15 it will be released on 0.66 |
|
@renatobecker can you please add the new events to our docs as well? https://github.com/RocketChat/docs/tree/master/developer-guides/livechat-api |
# Conflicts: # package-lock.json
|
@sampaiodiego, |
| }, | ||
|
|
||
| registerGuest(data) { | ||
| if (!(typeof data === 'object')) { |
There was a problem hiding this comment.
please change to if (typeof data !== 'object') { to help readability
| }, | ||
|
|
||
| setToken(token) { | ||
| if ((!token) || (token == this.token.get())) { |
There was a problem hiding this comment.
you don't need to use this much parenthesis.. without them the code looks much clearer:
if (!token || token === this.token.get()) {| return { | ||
| userId | ||
| userId, | ||
| token |
There was a problem hiding this comment.
on pull request #10767 this method will return the whole visitor object, I think you can to the same here (it should avoid future conflicts)
| Livechat.guestName = null; | ||
| Livechat.guestEmail = null; | ||
|
|
||
| msgStream.unsubscribe('room-messages'); |
There was a problem hiding this comment.
this does not have the desired effect. on my tests after changing the token using setGuestToken, I'm still receiving messages from the old room/token and being notified as well.
…at/Rocket.Chat into livechat-additional-iframe-apis
# Conflicts: # packages/rocketchat-livechat/server/methods/registerGuest.js
|
@sampaiodiego, the changes requested has been submitted. |
|
|
||
| this.guestName = new ReactiveVar(null); | ||
| this.autorun(() => { | ||
| this.guestName.set(Livechat.guestName); |
There was a problem hiding this comment.
any reason to not use Livechat.guestName directly on helper instead of creating this reactive var?
| } | ||
| }, | ||
| getName() { | ||
| return Template.instance().guestName.get(); |
There was a problem hiding this comment.
you can use Livechat.guestName directly here, instead of using the reactive var
|
@sampaiodiego, I fixed the usage of |
| }, | ||
| agentData() { | ||
| const agent = Livechat.agent; | ||
| const agent = Template.instance().agentData.get(); |
There was a problem hiding this comment.
I think this is the same case as Livechat.guestName I've talked before (sry for not have seen this before). Any reason to use a ReactiveVar here instead of keeping Livechat. agent ?
|
Hi @sampaiodiego! |
|
Please, we need this too: |

Closes #10866
This PR adds new Livechat iFrame API's, as described below:
setGuestToken(token):
Using this method a new Livechat session will be created using a
external token(e.g.):RocketChat(function() { this.setGuestToken('FHwaLnp8fzjMupSAj'); });setGuestName(name):
This method assigns a name to the Livechat active session visitor. If the visitor is already registered, its name will be updated in the database. If the visitor is not yet registered, its name will be assigned when the registration method is called.(e.g.):
RocketChat(function() { this.setGuestName('Rocket.Chat visitor name'); });setGuestEmail(email):
This method assigns an email to the Livechat active session visitor. If the visitor is already registered, its email will be updated in the database. If the visitor is not yet registered, its email will be assigned when the registration method is called.(e.g.):
RocketChat(function() { this.setGuestEmail('[email protected]'); });registerGuest(data):
This method checks if there is a Livechat visitor with the same token passed by the object. If a Livechat visitor does not exist, a new Livechat visitor will be created or, if one exists, will be updated. After that, a new Livechat session will be started.(e.g.):
RocketChat(function() { this.registerGuest({token: 'pSjpaw46CeL6Zu9f9', name: 'Rocket.Chat visitor name', email: '[email protected]'}); });Or without a token:
RocketChat(function() { this.registerGuest({name: 'Rocket.Chat visitor name', email: '[email protected]'}); });