RocketChat / RocketChat/Rocket.Chat

Omnichannel routing error

Open
#23,941 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

External service is used as Omnichannel Routing Method along with CRM integration for RocketChat.
Guest are registered with

RocketChat(function() {
       this.registerGuest({
		token: token,
		name: name,
		email: email,
		department: department, 
	});
});

I have found that in rare occasions the registerGuest callback does not take into account the department and instead routes the chat to a random one.
I could not manage to reproduce the bug, but a common error that appears in the RochetChat logs when this is encountered is:

API ➔ debug GET: /api/v1/livechat/messages.history/XXXXXXXXXXXX?token=YYYYYYYYYYYYYYYYYYY
API ➔ debug Failure {
  statusCode: 400,
  body: errorClass [Error]: [invalid-token]
      at Object.get (app/livechat/server/api/v1/message.js:218:11)
      at app/api/server/api.js:394:82
      at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
      at Object._internalRouteActionHandler [as action] (app/api/server/api.js:394:39)
    at Route.share.Route.Route._callEndpoint (packages/nimble_restivus/lib/route.coffee:150:32)
     at packages/nimble_restivus/lib/route.coffee:59:33
     at packages/simple_json-routes.js:98:9 {
  isClientSafe: true,
    error: 'invalid-token',
    reason: undefined,
    details: undefined,
    message: '[invalid-token]',
     errorType: 'Meteor.Error',
     success: false
  }
}

Also the JSON's captured with the webhook show visitors without the department field set.

Steps to reproduce:
  1. Open livechat widget
  2. Register Guest
  3. Route chat
Expected behavior:

Chat to be routed to the predefined department.

Actual behavior:

Chat is routed to random department.

Server Setup Information:

Version of Rocket.Chat Server: 3.6.1
Operating System: Debian 9
Deployment Method: tar
Number of Running Instances: 1
NodeJS Version: 12.14.0
MongoDB Version: 4.0.19

Client Setup Information

Desktop App or Browser Version: Google Chrome and Firefox
Operating System: Debian 9 and Windows 10

Additional context

Chat routing to the correct department is very important.
If the bug is fixed in a later version I could update, but since I can't reproduce it, the problem could still be present.
Please ask about anything else which might help tracking this down or what I should try to fix it.

Best regards

Small edit

If I set no department or a bogus name, the external service receives a random department in its request.
Is this a feature or a bug?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with app/livechat/server/api/v1/message.js at the messages.history endpoint, then trace the registerGuest and department-routing flow described in the issue. Reproduce the three listed steps if possible and compare the webhook visitor data; done means chats consistently route to the predefined department and invalid-token errors are understood or addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.