ChatMessage Object Members in SuiteScript 2.1
The ChatMessage object in SuiteScript 2.1 allows interaction with chat messages, including author roles and text content.
The ChatMessage object in SuiteScript 2.1 provides a method for creating and managing chat messages within scripts, facilitating interaction with chatbots and other messaging tools.
ChatMessage Object Members
The ChatMessage object includes several important members that define the structure and purpose of chat messages. Below are the key members you should be aware of:
| Member | Type | Return Type / Value Type | Supported Script Types | Description |
|---|---|---|---|---|
ChatMessage.role | Property | string | Server scripts | The author (role) of the chat message. |
ChatMessage.text | Property | string | Server scripts | Text of the chat message, either the prompt sent by the script or the response returned by the LLM. |
Property Descriptions
- Role: This property indicates who authored the chat message. It's a
stringtype and is utilized predominantly by server scripts. - Text: This property contains the actual text of the chat message, which can either be user input or chat bot outputs. It is also a
stringtype and is used in server scripts.
Error Handling
If you attempt to set a property that is read-only, you will encounter the following error:
- Error Code:
READ_ONLY - Thrown If: An attempt is made to set the property value of a read-only member.
Syntax Example
Here's a syntax example demonstrating how to create a new chat message using the ChatMessage object:
// Adding a chat message to the historychatHistory.push({ role: llm.ChatRole.CHATBOT, text: chatBotMessage // this is a previously defined string});For a more comprehensive script example related to creating chat messages, you can refer to the N/llm Module Script Samples.
Who This Affects
This article is primarily directed towards:
- Developers: Those implementing server scripts using the SuiteScript framework.
- Administrators: Admins overseeing chat functionalities and integrations within their NetSuite instance.
Key Takeaways
- The
ChatMessageobject facilitates chat message management in SuiteScript. - It includes properties like
roleandtext, critical for message definition. - Be mindful of read-only properties to avoid errors during implementation.
Frequently Asked Questions (4)
What script types are supported for using the ChatMessage object in SuiteScript 2.1?
How is the 'role' property of the ChatMessage object utilized?
Can the text property of a ChatMessage object include both user input and chatbot outputs?
What error might occur if you attempt to modify a read-only property in a ChatMessage object?
Was this article helpful?
More in AI
- Natural Language Queries in NetSuite AI
Updated for NetSuite 2026.1, featuring enhancements in natural language queries. The MCP Standard Tools SuiteApp offers enhanced AI-driven interaction with
- Support for Consolidated Reports and SuiteQL Tool
Updated to reflect the latest features added in NetSuite 2026.1. Starting with the latest updates in NetSuite 2026.1, NetSuite enhances reporting capabilities
- Intelligent Close Manager Portlet in NetSuite
The Intelligent Close Manager portlet offers a centralized view for managing tasks and exceptions in NetSuite, enhancing close processes.
- New SuiteCloud Agent Skills for NetSuite 2026.1
NetSuite 2026.1 introduces new SuiteCloud Agent Skills, enhancing security and development workflows.
Advertising
Reach AI Professionals
Put your product in front of NetSuite experts who work with AI every day.
Sponsor This Category