Create Conversations and Messages

Create Conversation

Create a new conversation.

Endpoint: https://api.maiagent.ai/api/v1/conversations

Request Method: POST

Request Headers:

Authorization: Api-Key <Your API Key>
Content-Type: application/json

Request Body:

Get "Web Chat ID" from the bottom of the "AI Assistant" details page

{
    "webChat": "String"  // Web Chat ID
}

Request Example:

import requests

response = requests.post(
    url='https://api.maiagent.ai/api/v1/conversations/',
    headers={
        'Authorization': 'Api-Key <Your API Key>'
    },
    json={
        'webChat': 'Your Web Chat ID'
    }
)

Response Body:

For message integration, you only need to record the "ID". The conversation "ID" can retrieve all messages in the conversation and can be used to identify which conversation the current message Webhook belongs to.


Send Message

Create a new message

Endpoint: https://api.maiagent.ai/api/v1/messages/

Request Method: POST

Request Headers:

Request Body:

Request Parameter Description:

Parameter Name
Type
Required
Description

conversation

string

Yes

Conversation unique identifier

content

string

Yes

Message content to send

attachments

array

No

Attachments array, defaults to empty array []

Attachment Object Field Description

Attachment Field
Type
Required
Description

id

string

Yes

Attachment unique identifier

type

string

Yes

Attachment type

filename

string

Yes

Attachment filename

file

string

Yes

Attachment URL

Request Examples:

Python Example

cURL Example

Response Format:

Receiving a response indicates successful message creation. Reply messages will be provided via Webhook, please refer to the Webhook section

Response Example:

Response Field Description

Field Name
Type
Description

id

string

Message unique identifier (UUID)

conversation

string

Conversation unique identifier (UUID)

sender

object

Sender information object

number

Sender unique identifier

string

Sender name

sender.avatar

string

Sender avatar URL

type

string

Message type (incoming/outgoing)

content

string

Message content

feedback

object

null

createdAt

string

Message creation timestamp

attachments

array

Attachments list

citations

array

Citation sources list

citationNodes

array

Citation nodes list

Message Type Description

  • incoming: Received messages

  • outgoing: Sent messages

Last updated

Was this helpful?