Getting Started

This section help you to start building your integration, so that you can send your first message.

Step 1: Get Your App ID

First of all, you need to create your application (App ID) in dashboard, by accessing Qiscus Chat Dashboard.

You can create more than one App ID within a single account. For further information regarding multiple applications in single account.

Step 2: Install Qiscus Chat SDK

  • You need to make sure to use flutter for stable version, by running this following code:
Bash
Copy
  • Add this to your package's pubspec.yaml file:
YAML
Copy
  • You can install packages from the command line:
Dart
Copy

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more

  • Now in your Dart code, you can use:
Dart
Copy

Step 3: Initialization Qiscus Chat SDK

You need to initiate your App ID for your chat app before you carry out to authentication. Initialization can be implemented in the initial startup. Here is the example on how you can do that:

Dart
Copy

Step 4: Authenticate to Qiscus

To use Qiscus Chat SDK features, first, user needs to authenticate to Qiscus Server. This authentication is done by calling setUser() function. This function will retrieve or create user credential based on the unique userId, for example:

Dart
Copy

Where:

  • userId (string): a user identifier that will be used to identify a user and used whenever another user needs to chat with this user. It can be anything, whether is is user's email, your user database index, etc. As long as it is unique and a string. This value is case sensitive.
  • userKey (string): a user key for authentication purpose. So, even if a stranger knows your userId, he cannot access the user data.
  • username (string): a username is used as a display name inside chat room.
  • avatarUrl (string, optional): to display user's avatar, fallback to default avatar if not provided.
  • extras (JSON, optional): to give additional information (metadata) to user, which consist key-value, for example key:position, and value: engineer

For further details, you might see on Authentications section.

Step 5: Create a Chat Room

There are three Chat Room types in Qiscus Chat SDK:

  • 1-on-1 Chat Room
  • Group Chat Room
  • Channel Chat Room

In this section, we will use 1-on-1 Chat Room. We assume that you already know a targeted user you want to chat with. To start a conversation with your targeted user, you can call chatUser() method. Qiscus Chat SDK, then, will serve you a new chat room, asynchronously. When the room is successfully created, Qiscus Chat SDK will return a chat room package through onSuccess listener.

Dart
Copy

Where:

  • userId (string) : a user identifier that will be used to identify a user and used whenever another user needs to chat with this user. It can be anything, whether is user's email, your user database index, etc. as long as it is unique and a string. This value is case sensitive
  • extras (map<string, dynamic> , optional) : metadata that can be as additional information to chat room, which consists key-value, for example, key: background, and value: red

Make sure that your targeted user has been registered in Qiscus Chat SDK. Otherwise you will receive error.

Step 6: Send Message

You can send any type of data through Qiscus Chat SDK, in this section let's send a "Hi" message, with type value is text. You need to pass roomId and the message value, for example:

Dart
Copy

Where:

  • roomId (long): chat room id, you can get this id in chat room object
  • text (string): text that you send to other participant
  • sender (QUser): QUser object consist of below properties, such as:
QUser PropertyDescription
idsender userId, you can get this value once you are successfully login in Qiscus Server
namesender username, you can get this value once you are successfully login in Qiscus Server
avatarUrlsender avatarUrl, you can get this value once you are successfully login in Qiscus Server

You can define any type and data, and render it to your own customised UI.

Messages can be received by the recipient target through a onMessageReceived event. This event is triggered whenever users send a message.

Dart
Copy

For further details about message, you can find at Message section and Event handler section.

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard