Frappé Chat - achillesrasquinha/frappe-noob GitHub Wiki
To create a new Frappeé Chat Object, simply:
const chat = new frappe.Chat(); // appends to "body"
chat.render();
This then goes ahead and renders a frappe.Chat.Widget.Popper component onto your screen.

Frappé Chat also comes with a page view that can be rendered as follows.
const chat = new frappe.Chat({ layout: frappe.Chat.Layout.PAGE });
chat.render();
Table of Contents
Developer Guide
-
Client-Side Scripting
Chat Profile
-
Create
Creates a Chat Profile for the current logged in user.
| URL | Requires Auth |
|---|---|
/api/method/frappe.chat.doctype.chat_profile.chat_profile.create |
yes |
Payload
| Parameter | Example | Required | Default | Description |
|---|---|---|---|---|
user |
[email protected] |
Yes | The email of the session user. | |
exists_ok |
true |
No | false |
throws an error if Chat Profile already exists. |
fields |
"status" |
No | null |
The field(s) need to be retrieved. By default, retrieves all fields. |
frappe.chat.profile.create((profile) => {
// do something with "profile"
})
// ...or as a Promise
frappe.chat.profile.create().then(profile => {
// do something with "profile"
})
Retrieve optional fields you require by passing them as the very first parameter (a single field or a list of 'em).
For instance, let's retrieve the status of the user.
frappe.chat.profile.create("status", (profile) => {
// do something with "profile".
})
Or a list of 'em.
frappe.chat.profile.create(["status", "chat_background"], (profile) => {
// do something with "profile".
})
-
Update
Update the Chat Profile of a user.
const update = { status: "Offline" }
frappe.chat.profile.update(frappe.session.user, update)
-
On Update
Receives subscribed Chat Profile updates for the current logged in user.
frappe.chat.profile.on.update((user, update) => {
// user -> name of the user
// update -> field, value pair that has been updated
})
Chat Room
-
Get
Retrieves information for Chat Room(s) for the current logged in user.
| URL | Requires Auth |
|---|---|
/api/method/frappe.chat.doctype.chat_room.chat_room.get |
yes |
Payload
| Parameter | Example | Required | Default | Description |
|---|---|---|---|---|
user |
[email protected] |
Yes | The email of the session user. | |
names |
CR00001 |
No | null |
Name/List of Chat Rooms to retrieve information about. |
fields |
"room_name" |
No | null |
The field(s) need to be retrieved for each Chat Room retrieved. By default, retrieves all fields. |
frappe.chat.room.get((rooms) => {
// do something with "rooms".
})
// ...or as a Promise
frappe.chat.room.get().then(rooms => {
// do something with "room(s)"
})
The first argument is are name(s) you require to retrieve after the said Chat Profile has been created (defaults to null which retrieves you all fields).
For instance, let's retrieve the information for the room CR00001.
frappe.chat.room.get("CR00001").then(room => {
// do something with "room"
})
// ...or a list of 'em
frappe.chat.room.get(["CR00001", "CR00002"]).then(rooms => {
// do something with "rooms"
})
The second argument is are field(s) you require to retrieve after the said Chat Profile has been created (defaults to null which retrieves you all fields).
For instance, let's retrieve the avatar of all Chat Rooms.
frappe.chat.room.get(null, "avatar", (rooms) => {
// do something with "room(s)".
})
// ...or a list of 'em
frappe.chat.room.get("CR00001", ["room_name", "type"], (rooms) => {
// do something with "room(s)".
})
-
Subscribe
Subscribe to a chat room to listen to continuous updates.
frappe.chat.room.subscribe("CR00001")
// ...or a list of 'em
frappe.chat.room.subscribe(["CR00001", "CR000002"])
Chat Component
Frappé Utilities
frappe._.fuzzy_search(query, dataset, options)