Chat service interfaces provide complete chat functionality integration capabilities, including message sending and receiving, session management, voice conversion and other core functions. All interfaces require a valid API key for authentication. Use the DifyChat
interface instance.
ChatMessageSendResponse send(ChatMessageSendRequest sendRequest);
ChatMessageSendRequest
Parameter name | Type | Required | Description |
---|
apiKey | String | Yes | apiKey |
userId | String | Yes | User id |
conversationId | String | No | Chat session number |
content | String | Yes | Message content |
files | List<ChatMessageFile> | No | file |
inputs | Map<String, Object> | No | Customized parameters |
ChatMessageSendResponse
Parameter name | Type | Description |
---|
conversationId | String | Chat session number |
messageId | String | Message id |
createdAt | Long | Creating timestamps |
taskId | String | Task id |
id | String | id |
answer | String | answer |
Flux<ChatMessageSendResponse> sendChatMessageStream(ChatMessageSendRequest sendRequest);
Same as the Send Message interface
Returns a stream of messages, each of which is formatted in the same way as the send message response
void stopMessagesStream(String apiKey, String taskId, String userId);
Parameter name | Type | Required | Description |
---|
apiKey | String | Yes | apiKey |
taskId | String | Yes | taskId |
userId | String | Yes | userId |
MessageFeedbackResponse messageFeedback(MessageFeedbackRequest messageFeedbackRequest);
Parameter name | Type | Required | Description |
---|
apiKey | String | Yes | apiKey |
userId | String | Yes | userId |
messageId | String | Yes | messageId |
rating | Rating | Yes | rating |
content | String | Yes | Message Feedback Specific Information |
MessageFeedbackResponse
Parameter name | Type | Description |
---|
result | String | Fixed return success |
DifyPageResult<MessagesResponseVO> messages(MessagesRequest request);
Parameter name | Type | Required | Description |
---|
apiKey | String | Yes | apiKey |
userId | String | Yes | userId |
conversationId | String | Yes | Chat session number |
firstId | String | No | First record id |
limit | Integer | No | Number of records per page, default 20条 |
List<String> messagesSuggested(String messageId, String apiKey, String userId);
Parameter name | Type | Required | Description |
---|
messageId | String | Yes | messageId |
apiKey | String | Yes | apiKey |
userId | String | Yes | userId |
Return to the list of suggested response texts
DifyPageResult<MessageConversationsResponse> conversations(MessageConversationsRequest request);
Parameter name | Type | Required | Description |
---|
apiKey | String | Yes | apiKey |
userId | String | Yes | userId |
lastId | String | No | Last record id |
limit | Integer | No | Number of records per page, default 20 |
sortBy | String | No | Sort field, default -updated_at |
MessageConversationsResponse
Parameter name | Type | Description |
---|
id | String | Chat session number |
name | String | Session name |
inputs | Map<String,Object> | Input parameter |
status | String | Session state |
introduction | String | Opening remarks |
createdAt | Long | Creating timestamps |
updatedAt | Long | Updating timestamps |
void deleteConversation(String conversationId, String apiKey, String userId);
Parameter name | Type | Required | Description |
---|
conversationId | String | Yes | Chat session number |
apiKey | String | Yes | apiKey |
userId | String | Yes | userId |
MessageConversationsResponse renameConversation(RenameConversationRequest renameConversationRequest);
Parameter name | Type | Required | Description |
---|
conversationId | String | Yes | Chat session number |
name | String | Yes | Session name |
autoGenerate | String | No | Auto-generated title, default false |
apiKey | String | Yes | apiKey |
userId | String | Yes | userId |
MessageConversationsResponse
Parameter name | Type | Description |
---|
id | String | Chat session number |
name | String | Session name |
inputs | Map<String,Object> | Input parameter |
status | String | Session state |
introduction | String | Opening remarks |
createdAt | Long | Creating timestamps |
updatedAt | Long | Updating timestamps |
void textToAudio(TextToAudioRequest request, HttpServletResponse response);
Parameter name | Type | Required | Description |
---|
apiKey | String | Yes | apiKey |
userId | String | Yes | userId |
text | String | Yes | Convert Text |
messageId | String | No | messageId |
Returns an audio file stream
DifyTextVO audioToText(AudioToTextRequest request);
Parameter name | Type | Required | Description |
---|
apiKey | String | Yes | apiKey |
userId | String | Yes | userId |
file | MultipartFile | Yes | Audio file |
Parameter name | Type | Description |
---|
text | String | Convert Text |
AppParametersResponseVO parameters(String apiKey);
Parameter name | Type | Required | Description |
---|
apiKey | String | Yes | apiKey |
AppParametersResponseVO
Parameter name | Type | Description |
---|
openingStatement | String | Opening statement |
suggestedQuestions | List<String> | Opening recommended questions |
suggestedQuestionsAfterAnswer | Enabled | Enable recommended questions after answer |
speechToText | Enabled | Speech-to-text feature config |
textToSpeech | TextToSpeech | Text-to-speech feature config |
retrieverResource | Enabled | Reference and attribution config |
annotationReply | Enabled | Annotation reply config |
moreLikeThis | Enabled | More like this feature config |
userInputForm | List<UserInputForm> | User input form config |
sensitiveWordAvoidance | Enabled | Sensitive word avoidance config |
fileUpload | FileUpload | File upload config |
systemParameters | FileUploadConfig | System parameters config |
Enabled Object Structure:
Parameter name | Type | Description |
---|
enabled | Boolean | Whether enabled |
TextToSpeech Object Structure:
Parameter name | Type | Description |
---|
enabled | Boolean | Whether enabled |
voice | String | Voice type |
FileUpload Object Structure:
Parameter name | Type | Description |
---|
enabled | Boolean | Whether file upload is enabled |
image | FileUploadImage | Image upload configuration |
allowedFileTypes | List<String> | Allowed file types list |
allowedFileExtensions | List<String> | Allowed file extensions list |
allowedFileUploadMethods | List<String> | Allowed upload methods list |
numberLimits | Integer | File count limit |
fileUploadConfig | FileUploadConfig | Detailed upload configuration |
FileUploadImage Object Structure:
Parameter name | Type | Description |
---|
enabled | Boolean | Whether image upload is enabled |
numberLimits | Integer | Image count limit, default 3 |
transferMethods | List<String> | Transfer methods: remote_url, local_file |
FileUploadConfig Object Structure:
Parameter name | Type | Description |
---|
fileSizeLimit | Integer | File size limit (MB) |
batchCountLimit | Integer | Batch upload count limit |
imageFileSizeLimit | Integer | Image file size limit (MB) |
videoFileSizeLimit | Integer | Video file size limit (MB) |
audioFileSizeLimit | Integer | Audio file size limit (MB) |
workflowFileUploadLimit | Integer | Workflow file upload limit |
UserInputForm Object Structure:
Parameter name | Type | Description |
---|
textInput | TextInput | Text input control config |
paragraph | Paragraph | Paragraph text input config |
select | Select | Dropdown control config |
TextInput Object Structure:
Parameter name | Type | Description |
---|
label | String | Control display label |
variable | String | Control ID |
required | Boolean | Whether required |
maxLength | Integer | Maximum length limit |
defaultValue | String | Default value |
Paragraph Object Structure: Inherits from TextInput, has the same field structure
Select Object Structure:
Parameter name | Type | Description |
---|
label | String | Control display label |
variable | String | Control ID |
required | Boolean | Whether required |
maxLength | Integer | Maximum length limit |
defaultValue | String | Default value |
type | String | Dropdown type |
options | List<String> | Options list |