JSON Escaping Issues in n8n Workflow for Slack Integration?

Describe the problem/error/question

Hello Teams, I have some questions/issues about an n8n workflow. Here, I’m trying to receive a webhook trigger and send a message to Slack. Everything looks good until I try to send a quoted comment, and it no longer works. Here is an example of that comment:

“Admin user Admin wrote: > Admin user Admin wrote: > > aaaa > > @joeys hello @Jimmy112

I did a quick Google search, and I think it is caused by escaped characters in JSON? and I check it those character is not illegals in JSON ? correct me if I ware wrong.

What is the error message (if any)?

n8n version

1.35.0 (Self Hosted)

Stack trace

SyntaxError: Unexpected token in JSON at position 260 at JSON.parse (<anonymous>) at jsonParse (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/utils.js:64:21) at Object.getMessageContent (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Slack/V2/GenericFunctions.js:101:52) at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Slack/V2/SlackV2.node.js:489:78) at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:724:42) at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:660:68 at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1062:20

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version:1.35.0
  • Database (default: SQLite):default
  • n8n EXECUTIONS_PROCESS setting (default: own, main):default
  • Running n8n via (Docker, npm, n8n cloud, desktop app):Docker-compose
  • Operating system:Linux

Can you share the JSON that gives the error?

This is from my Slack Node that gave me an error. If I remove {{ $('Webhook1').item.json.body.payload.journal.notes }} , it works. This is the content inside it:
Admin user Admin wrote: > Admin user Admin wrote: > > aaaa > > @joeys hello @Jimmy112

{
	"blocks": [
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "{{ $json.match }} *Has Been Tagged * \n *In Subject:* {{ $('Webhook1').first().json.body.payload.issue.subject }}\n *By : * {{ $('Webhook1').item.json.body.payload.issue.author.login }}\n*URL :* {{ $('Webhook1').first().json.body.payload.url }} \n*Noted :*{{ $('Webhook1').item.json.body.payload.journal.notes }} "
			}
		},
		{
			"type": "divider"
		}
	]
}     

@bartv Any Idea why I get this error ?

I’d start by looking at the full JSON payload you’re sending to Slack and validating that with a JSON validator - this may point you to the issue.

To get the full payload, run the previous nodes, and in the Slack node click on the Blocks expression. This will open a drop-down with resulting value of the expression. copy that, and validate it.

Hope that helps!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.