Create Message

This page demonstrates how to create a new message within a conversation for your AI Assistant app. Creating messages enables you to programmatically interact with your AI Assistant, send user inputs, and receive responses.

#Create Message via API

cURL

export INSTILL_API_TOKEN=********
curl -X POST 'https://api.instill.tech/v1alpha/namespaces/NAMESPACE_ID/apps/APP_ID/conversations/CONVERSATION_ID/messages' \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $INSTILL_API_TOKEN" \
--data '{
"content": "Your message content here",
"role": "user",
"type": "MESSAGE_TYPE_TEXT"
}'

Note that the NAMESPACE_ID, APP_ID, and CONVERSATION_ID path parameters must be replaced with the app owner's ID, the app ID, and the conversation ID respectively.

#Body Parameters

  • content (string, required): The text content of the message.
  • role (string, required): The role of the message sender. Use "user" for user messages and "assistant" for AI Assistant responses.
  • type (string, required): The type of the message. Currently, only "MESSAGE_TYPE_TEXT" is supported.

Note: The role field distinguishes between user messages and assistant responses. This is important for maintaining the context and flow of the conversation.

#Example Response

A successful response will return a JSON object containing the details of the newly created message.


{
"message": {
"uid": "generated-message-uid",
"appUid": "your-app-uid",
"conversationUid": "your-conversation-uid",
"content": "Hello, how can I improve my code?",
"role": "user",
"type": "MESSAGE_TYPE_TEXT",
"createTime": "2024-10-09T12:34:56Z",
"updateTime": "2024-10-09T12:34:56Z",
"msgSenderUid": "your-user-uid"
}
}

#Output Description

  • message: An object containing the details of the created message.
    • uid (string): The unique identifier of the message generated by the system.
    • appUid (string): The UID of the app the message belongs to.
    • conversationUid (string): The UID of the conversation.
    • content (string): The content of the message.
    • role (string): The role of the message sender.
    • type (string): The type of the message.
    • createTime (string): The timestamp when the message was created.
    • updateTime (string): The timestamp when the message was last updated.
    • msgSenderUid (string): The UID of the message sender.

#Create Message via Console

To create a new message within a conversation using the Instill Console, follow these steps:

  1. Launch Instill Console on Instill Cloud.
  2. Navigate to the Applications page using the navigation bar.
  3. Click on the AI Assistant card you wish to interact with.
  4. In the playground, select the existing Catalog you want to converse with.
  5. Type your message into the input field at the bottom of the chat interface.
  6. Press the Send button (represented by an arrow icon) to send your message.
  7. The console will automatically store your message and the AI Assistant's response within the conversation.

Note: The Instill Console simplifies the process by handling message creation and storage automatically when you interact with your AI Assistant.