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.
Source: This article is based on Oracle's official NetSuite documentation.
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 General
- Payment Date Prediction Feature in NetSuite
Payment Date Prediction in NetSuite utilizes machine learning to enhance financial planning by predicting invoice payment dates.
- NetSuite Ship Central Enhancements for Packing & Shipping
NetSuite Ship Central features enhance packing and shipping operations for improved efficiency and accuracy.
- New Role Setup for NetSuite AI Connector Service in 2026.1
The 2026.1 release adds a new role requirement for the NetSuite AI Connector Service, streamlining custom tool development.
- Generative AI Features in NetSuite 2026.1
Discover new generative AI features in NetSuite 2026.1, enhancing reporting, search, predictions, and development productivity.
Advertising
Reach General Professionals
Put your product in front of NetSuite experts who work with General every day.
Sponsor This Category