Hi everyone,
I am building a real-time Arabic ↔ English translation bot using Botpress Cloud and the official Discord Integration.
⚙️ My Workflow Architecture:
Trigger: Message Created (Discord integration).
Execute Code (Prepare Translation): Extracts the channelId and message text, performs loop-prevention filters (ignoring bots and outgoing events), and determines the workflow.targetChannel.
AI Generate Text: Processes the translation.
Execute Code (Normalize): Cleans up the AI output, strips wrapping quotes, and constructs a JSON string payload mapped to workflow.discordMessageBody.
Discord Call API: Sends a POST request using the path /channels/{{workflow.targetChannel}}/messages.
❌ The Errors I Encountered:
API Path Pattern Error:
Initially, I received an invalid input error: data/path must match pattern "^/". I fixed this by ensuring the API path explicitly starts with a forward slash: /channels/{{workflow.targetChannel}}/messages.
JSON Parse Error (Bad Control Character):
When trying to pass the raw AI text into a custom body inside the Call API card, any newlines (\n) generated by the AI broke the JSON format, throwing:
"Failed to parse JSON input body: Bad control character in string literal in JSON".
💻 Current Script Inside my "Normalize" Node:
To resolve the control character issue and upgrade to embeds, I am currently using this code to stringify
❓ My Question:
While the workflow completes without errors (Conversation Ended status in the Emulator), the payload is sometimes not reaching the actual Discord channel or the targetChannel parameter registers as empty during local testing.
Are there any underlying issues with how event tags like channelId are parsed from live Discord events versus the Emulator? Any guidance on ensuring the stringified embed payload safely executes through the integrated Discord Call API action would be highly appreciated!
Thanks in advance!
https://cdn.discordapp.com/attachments/1508923177550479451/1508923177777233990/169.png?ex=6a174db8&is=6a15fc38&hm=2870f5de9ac6c9b0792842048a5f95ffec49c21c6cb9ea7e721e516eef45e38b&
https://cdn.discordapp.com/attachments/1508923177550479451/1508923178272035066/message.txt?ex=6a174db8&is=6a15fc38&hm=3494028ba982142f6b8d20dfc28aa1a74c8f4f9283182920b4fe03f7d7b38c41&