How to send response from AI as string value in JSON field

I send link to OpenAI and I get response like below. However, when I send this long text to step “Line : Reply with token” and I set JSON like this then {{ $json.output }} “the response from ChatGPT” is convert “\n” to new line. How can I send this long text as string in JSON value in “text” field.
{
“replyToken”: “xxxxxxxx”,
“messages”: [
{
“type”: “text”,
“text”: “{{ $json.output }}”
}
]
}

LINE Bot MCP Server Summary\n\nOverview\nThe LINE Bot MCP Server is an open-source project developed and maintained by LINE Corporation. It serves as a middleware platform that facilitates integration between LINE Messaging API and hardware components or systems, especially in the context of robotics applications such as the LINE Mars Cat Project (MCP). The server acts as a management bridge, handling bot interactions and dispatching user commands from LINE users to backend systems or connected devices.\n\nPurpose\nThe main goal of this project is to demonstrate how developers can build interactive LINE bot applications that communicate with physical hardware devices (e.g., robots) using a modular, scalable approach. It is designed to manage conversations, route messages, handle authentication, and channel LINE message data to multiple target endpoints.\n\nFeatures\n\nWebhook Integration\nThe MCP Server receives requests from the LINE Messaging API via webhook and efficiently dispatches user input to connected robot/controller endpoints based on predefined routing rules.\n\nToken-Based Authorization\nIt supports token-authenticated communication to ensure secure connections between clients (robots/IoT devices) and the server.\n\nConversation Management\nManages and stores conversation contexts using Redis, enabling stateful interactions between users and connected devices.\n\nModular Command Routing\nCommands sent from LINE are parsed and routed to the appropriate targets through a pluggable module structure, supporting a multi-robot or multi-system environment.\n\nExtensible Architecture\nDesigned with flexibility in mind, allowing developers to extend or customize message handling behavior, add new target systems, or change routing logic through middleware and configuration changes.\n\nArchitecture and Components\n\n1. Key Components\n\napp.py\nThe main entry point. It initializes the web server using Flask, sets up the endpoint handlers, and loads configuration settings.\n\ndispatcher\nResponsible for routing messages from LINE users to the appropriate command targets. It uses message content, user identity, and routing strategies to determine the message path.\n\nrouter\nDetermines which robot or device should receive a given command based on user ID and room/content context. It adjusts dynamically according to usage patterns or system states.\n\nclient\nHandles sending commands from the MCP Server to external systems or robots that are registered and authorized.\n\nstore\nImplements caching and persistence mechanisms using Redis for managing conversations and user-to-device bindings.\n\nconfig\nDefines environment and runtime configurations, such as access tokens, Redis settings, and other runtime parameters.\n\n2. External Dependencies\n\nLINE Messaging API\nUsed to receive messages from and send replies to LINE users.\n\nRedis\nUsed as the backend store for maintaining session information, user bindings, and conversation history.\n\nFlask\nProvides the RESTful web service functionality that acts as the LINE webhook endpoint.\n\nUsage\n\nLocal Setup\nDevelopers can clone the repository and configure environment variables (e.g., LINE access token and secret, Redis URL) to run the server locally.\n\nRegistration\nDevices or applications that want to respond to LINE bot commands must register with the server using a shared token mechanism. Upon registration, these endpoints are listed as potential recipients for incoming messages.\n\nTesting\nThe repository includes sample endpoints and command formats to facilitate local or cloud-based testing of bot interactions.\n\nExtending the Project\n\nCustom Middleware\nDevelopers can insert custom middleware to preprocess messages or add additional logging, metrics, or authentication layers.\n\nCustom Router\nThe routing logic is pluggable and can be replaced or extended to support use-cases such as load-balancing, priority queues, or location-based routing.\n\nEnhancing Conversations\nSupport for richer message types (e.g., carousels, buttons) can be added using the LINE Messaging API client.\n\nSecurity\n\nToken-Based Access\nThe system authenticates communicating endpoints (such as devices or robot controllers) using pre-shared tokens to protect commands and prevent unauthorized access.\n\nRate Limiting and Abuse Protection\nAlthough not built-in, the server architecture makes it possible to implement such protections using external middleware or API gateways.\n\nDeployment\n\nCloud Deployment\nThe MCP Server can be deployed to any cloud platform that supports Python and Flask, such as Heroku, AWS, or GCP.\n\nScalability\nSupports horizontal scalability through stateless service design and reliance on Redis for session management.\n\nDocker Support\nWhile a Dockerfile is not explicitly provided, the project can be containerized for streamlined deployment in Kubernetes or Docker-based infrastructures.\n\nLicense\n\nThis project is licensed under the Apache License 2.0, permitting both personal and commercial use with proper credit and adherence to license terms.\n\nTarget Audience\n\nThe MCP Server is best suited for developers building LINE bot integrations with robotics or IoT systems, educational institutions demonstrating chat-driven control architectures, or hobbyists looking to explore conversational interfaces for programmable devices.\n\nConclusion\n\nThe LINE Bot MCP Server provides a practical and flexible example for bridging conversational interfaces with physical systems. Its modular architecture, support for secure routing, and use of widely adopted technologies (Flask, Redis, LINE Messaging API) make it a solid starting point for bot-to-hardware integration. Through its extensible and scalable design, developers can create robust, real-time chat-based control systems for a variety of applications involving smart devices, robots, or services requiring user interaction through LINE.

The only way to do it is to stringify the json object. {{ JSON.stringify($json.output) }}

1 Like

how about special character in json. Is there any function to solve this one?

Do you have some examples of these special chars?

Maybe if you can also share your workflow in a code block and add some context of what you’re trying to do with the data, where are you sending it to, etc?