Overview
Installation
To get started, you will need to install MinChat Javascript SDK in your Javascript front-end project.
The MinChat SDK needs to be initialized with the MINCHAT_API_KEY
as a parameter as well as a User object representing the current user logged in. The API Key can be found on the Minchat dashboard.
Event Listeners
Listen for conversations
This is called whenever a new message is received in a conversation, new or old.
Response
Field | Type | Description |
---|---|---|
| The chat object that has received a new message. |
Functions
Create User
You should create users in your MinChat application to initiate conversations with. Users are at the core of all conversations. MinChat applications are made up of users who chat in either group chats or one-to-one conversations.
in MinChat, a User is a person that uses your app. Typically, you will have one MinChat User for each user in your own database.
Usually, you would create users based on the data from your database. A User is represented by a JSON object.
You can view more details about the user parameters here.
note: createUser(...)
automatically creates a new user in the system, if a user with the same username already exists then it will reuse that user.
Fetching a user
You can fetch an already existing user using either their username or their id.
Updating a user
You can update an existing user's information
You can view more details about the user parameters here.
Get Conversations
You can get a list of the conversations of the current user. conversations retrieved are paginated to 25 messages at a time.
Parameters
Field | Type | State | Description |
---|---|---|---|
|
| optional | query a specific page of chats, each page contains 25 chats. if |
Response
Field | Type | Description |
---|---|---|
| array of Chat objects | |
|
| shows the current page of chats. each page contains 25 chats |
|
| shows the total number of chats that exist |
|
| shows the total number of pages of chats that exist. each page contains 25 chats |
Delete a user
Delete a user by username
Or delete a user by user id
Start One-to-One Conversation
Field | Type | State | Description |
---|---|---|---|
|
| required | The username of the user to start a conversation with. (note: this user must already be created) |
Start Group Chat
Field | Type | State | Description |
---|---|---|---|
|
| optional | The name of the group chat. |
|
| required | username list of participants of the group chat. |
avatar |
| optional | the avatar of the group chat |
Last updated