Client SDKによる会話の管理

Product deprecation notice

Effective April 30th, 2026, Vonage In-App Messaging will no longer be available. Access for new users will be closed, and the service will be discontinued for all existing users.

If you have any questions regarding this product’s discontinuation, please contact your account manager or our support team.

このガイドでは、Vonage Client SDKで会話を管理する方法を説明します。始める前に、アプリにSDKを追加し、セッション(アンドロイド, iOS, JS).

A 会話 は、Vonage Client SDK で作業するときにチャットルームとして見ることができます。アプリケーションの ユーザー は会話に参加することができます。会話に参加すると、彼らは メンバー.メンバーはメッセージを送受信できる。

会話やイベントの削除などのアクションは、会話IDを持つユーザーであれば誰でも可能です。どのユーザーが特定のアクションを実行できるかをコントロールするには、以下の方法で制限してください。 JWTのACL.

会話を作る

について createConversation メソッドでは、いくつかのパラメータを渡すことでカンバセーションを作成することができます。会話名は一意でなければなりません。会話名や表示名を指定しなかった場合は、会話名が生成されます。

設定できる:

  • 名称
  • 表示名
  • 画像URL
  • TTL
  • カスタム・ソート・キー
  • カスタムデータ
const params = {
    name: "name",
    displayName: "displayName",
    imageUrl: "https://...",
    ttl: null, // 600 (in seconds)
    customSortKey: "customSortKey",
    customData: {key: "value"}
};

client.createConversation(params)
    .then(conversationId => {
        console.log("Id of created Conversation: ", conversationId);
    }).catch(error => {
        console.error("Error creating Conversation: ", error);
    });

会話を得る

について getConversations メソッドを使用すると、現在のユーザーがメンバーであるすべての会話を取得できます。オプションでいくつかのパラメータを渡してレスポンスを設定することができます。このメソッドは、ページ分割されたレスポンスを返します。ページ分割についてよくわからない場合は ページネーションガイド.

設定できる:

  • オーダー
  • ページサイズ
  • カーソル
  • カスタムデータを含めるかどうか
  • 何を注文するか
const params = {
    order: "asc", // "desc"
    pageSize: 100,
    cursor: null,
    includeCustomData: false,
    orderBy: null // "CUSTOM_SORT_KEY"     
};

client.getConversations(params)
    .then(({conversations, nextCursor, previousCursor}) => {
        console.log("Array of Conversations: ", conversations);
        console.log("Cursor for next set of results, if any. Could be null: ", nextCursor);
        console.log("Cursor for previous set of results, if any. Could be null: ", previousCursor);
    }).catch(error => {
        console.error("Error getting Conversations: ", error);
    });

会話を得る

会話IDを指定すると、会話オブジェクトを取得することができます。

client.getConversation(conversationId)
    .then(conversation => {
        console.log("Successfully got Conversation: ", conversation);
    }).catch(error => {
        console.error("Error getting Conversation: ", error);
    });

会話の更新

について updateConversation メソッドを使用すると、Conversation のプロパティを更新できます。3つのオプションでパラメータを渡すことができます:

  • 値の省略 - 会話に変更はない。
  • 値 (VGOption.some() AndroidとiOSの場合) - 値は会話で更新されます。
  • パス null (VGOption.some(null/nil) AndroidとiOSの場合) - 値はヌルか、会話のデフォルトに設定されます。

これらのカンバセーション・プロパティを更新することができる:

  • 名称
  • 表示名
  • 画像URL
  • TTL
  • カスタム・ソート・キー
  • カスタムデータ
// Update the conversation displayName and remove the imageUrl
const params = {
    displayName: "New Display Name",
    imageUrl: null,
};

client.updateConversation("CONV_ID", params)
    .then(conversationId => {
        console.log("ID of updated Conversation: ", conversationId);
    }).catch(error => {
        console.error("Error creating Conversation: ", error);
    });

会話のイベントを得る

会話IDを指定すると、会話のイベントを取得することができます。オプションで、レスポンスを設定するためのパラメータを渡すことができます。このメソッドはページ分割されたレスポンスを返します。ページ分割についてよくわからない場合は ページネーションガイド.

設定できる:

  • オーダー
  • ページサイズ
  • カーソル
  • フィルタリングするイベント
  • 削除されたイベントを含めるかどうか
const params = {
    order: "asc", // "desc"
    pageSize: 100,
    cursor: null,
    eventFilter: null, // ['message', 'member:joined']
    includeDeletedEvents: false,
    startId: null // 3
};

client.getConversationEvents(conversationId, params)
    .then(({events, nextCursor, previousCursor}) => {
        console.log("Array of Events: ", events);
        console.log("cursor for next set of results, if any. could be null: ", nextCursor);
        console.log("cursor for previous set of results, if any. could be null: ", previousCursor);
    }).catch(error => {
        console.error("Error getting Events: ", error);
    });

会話のイベントの削除

イベントIDと会話IDがあれば、イベントを削除することができます。

client.deleteEvent(eventId, conversationId)
    .then(() => {
        console.log("Successfully deleted EVent.");
    }).catch(error => {
        console.error("Error deleting Event: ", error);
    });

会話の削除

会話IDがあれば、その会話を削除することができます。

client.deleteConversation(conversationId)
    .then(() => {
        console.log("Successfully deleted Conversation.");
    }).catch(error => {
        console.error("Error deleting Conversation: ", error);
    });