{"record":{"id":"f0d8c7e473bb6edf","repo":"RocketChat/Rocket.Chat","slug":"message-length-exceeds-character-limit-f0d8c7","errorCode":"message-length-exceeds-character-limit","errorMessage":"message-length-exceeds-character-limit","messagePattern":"message-length-exceeds-character-limit","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/omnichannel/sendMessageLivechat.ts","lineNumber":60,"sourceCode":"\t\t\tusername: String,\n\t\t}),\n\t);\n\n\tconst guest = await LivechatVisitors.getVisitorByToken(token, {\n\t\tprojection: {\n\t\t\tname: 1,\n\t\t\tusername: 1,\n\t\t\tdepartment: 1,\n\t\t\ttoken: 1,\n\t\t},\n\t});\n\n\tif (!guest) {\n\t\tthrow new Meteor.Error('invalid-token');\n\t}\n\n\tif (settings.get('Livechat_enable_message_character_limit') && msg.length > parseInt(settings.get('Livechat_message_character_limit'))) {\n\t\tthrow new Meteor.Error('message-length-exceeds-character-limit');\n\t}\n\n\treturn sendMessage({\n\t\tguest,\n\t\tmessage: {\n\t\t\t_id,\n\t\t\trid,\n\t\t\tmsg,\n\t\t\ttoken,\n\t\t\tfile,\n\t\t\tfiles,\n\t\t\tattachments,\n\t\t},\n\t\tagent,\n\t\troomInfo: {\n\t\t\tsource: {\n\t\t\t\ttype: OmnichannelSourceType.API,\n\t\t\t},","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/omnichannel/sendMessageLivechat.ts#L42-L78","documentation":"Livechat messages are length-checked when Livechat_enable_message_character_limit is enabled: if msg.length exceeds parseInt(Livechat_message_character_limit) the send aborts with message-length-exceeds-character-limit. The limit applies only to the livechat guest message body, checked before the message is stored.","triggerScenarios":"A visitor sending a message longer than Livechat_message_character_limit while Livechat_enable_message_character_limit is on; integrations forwarding long transcripts or email bodies into livechat without truncation.","commonSituations":"Admins enable a low character cap for spam control; support widgets fed by automated systems that send unbounded text; the limit lowered after go-live, breaking previously working integrations.","solutions":["Truncate or split the message client-side before sending, respecting the configured limit","Raise Livechat_message_character_limit or disable Livechat_enable_message_character_limit if the workflow needs longer messages","Show a character counter in the widget so guests see the cap before sending"],"exampleFix":"// before\nMeteor.call('sendMessageLivechat', { token, _id, rid, msg: fullText });\n\n// after\nconst limit = parseInt(settings.get('Livechat_message_character_limit'), 10);\nconst msg = fullText.slice(0, limit);\nMeteor.call('sendMessageLivechat', { token, _id, rid, msg });","handlingStrategy":"validation","validationCode":"const limitOn = settings.get('Livechat_enable_message_character_limit');\nconst limit = parseInt(settings.get('Livechat_message_character_limit'), 10);\nif (limitOn && text.length > limit) {\n  text = text.slice(0, limit); // or surface a counter and block submission\n}","typeGuard":"const isLengthExceeded = (e: unknown): e is Meteor.Error =>\n  typeof e === 'object' && e !== null && (e as { error?: string }).error === 'message-length-exceeds-character-limit';","tryCatchPattern":"try {\n  await send(text);\n} catch (e) {\n  if (isLengthExceeded(e)) {\n    for (let i = 0; i < text.length; i += limit) {\n      await send(text.slice(i, i + limit)); // chunked resend\n    }\n    return;\n  }\n  throw e;\n}","preventionTips":["Read the livechat limit settings in the widget and enforce them in the input (maxLength + counter)","Chunk long integration payloads before they reach the livechat send path","Re-read settings after admin changes — limits can change at runtime"],"tags":["rocket-chat","livechat","omnichannel","message-length","validation","settings"],"backgroundTag":"message-too-long","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}