RocketChat / Rocket.Chat.js.SDK

Utility for apps and bots to interact with Rocket.Chat via DDP and/or API
MIT License
136 stars 95 forks source link

Ignore livechat messages if you're not the room participant #30

Closed nsdev0 closed 6 years ago

nsdev0 commented 6 years ago

Case: When a new Livechat starts, it is redirected directly to the bot. The bot can transfer chat to a live person on demand. But after this transfer he continues to listen this room and try to respond to clients messages.

Solve: Ignore messages in Livechat room if bot is not the room participant.

timkinnane commented 6 years ago

@nsdev0 So the bot has RESPOND_TO_LIVECHAT=true but after the handover, it's removed from the room, but continues to receive messages?

Are you just using the bot in livechat? If so, you could try LISTEN_ON_ALL_PUBLIC=false - I have a feeling that if that's true, the logic just doesn't filter based on if the bot is in the room, instead applying only the other filters.

If that's the problem here, we probably either need to change the logic or the env variable name to make sure it's more clear.

nsdev0 commented 6 years ago

@timkinnane yes, the bot has RESPOND_TO_LIVECHAT=true He can answer to direct messages RESPOND_TO_DM=true too. In the some cases he can transfer livechat room to the another agent through callMethod('livechat:transfer', ...)

So if variable is not defined in .env file than value = false, isn't it?

LISTEN_ON_ALL_PUBLIC | Stream callbacks receive messages from all public channels (true/false). Defaults to false (only rooms the bot has joined).

Anyway even after I explicitly set this variable, the bot continued to respond for messages in this room.

nsdev0 commented 6 years ago

@timkinnane My bad I can't remember for what but I gave him the livechat's manager role. That's why he kept getting messages in the transferred room,

timkinnane commented 6 years ago

No probs @nsdev0 - That's really useful info. The project needs better docs for the bot livechat process. Thanks for closing the issue, but would you mind adding any key points you've learnt like this one to my issue on the docs repo: https://github.com/RocketChat/docs/issues/779

I think this confusion will repeat itself many times before we have clearer directions and I'm not using livechat personally so I don't know the finer points.