এই নির্দেশিকাটি ব্যাখ্যা করে কিভাবে সেইসব গ্রুপ চ্যাট খুঁজে বের করতে হয়, যেগুলিতে কলকারী ব্যবহারকারী এবং অন্যান্য ব্যবহারকারীদের একটি নির্দিষ্ট তালিকা রয়েছে। গুগল চ্যাট এপিআই-তে, গ্রুপ চ্যাট হলো Space রিসোর্স, যেগুলির spaceType GROUP_CHAT হিসেবে সেট করা থাকে। একটি গ্রুপ চ্যাট খুঁজে পেতে, Space রিসোর্সের findGroupChats ( RPC , REST ) মেথডটি ব্যবহার করুন।
পূর্বশর্ত
নোড.জেএস
- গুগল চ্যাট ব্যবহারের সুবিধাসহ একটি ব্যবসায়িক বা এন্টারপ্রাইজ গুগল ওয়ার্কস্পেস অ্যাকাউন্ট।
- আপনার পরিবেশ প্রস্তুত করুন:
- একটি গুগল ক্লাউড প্রজেক্ট তৈরি করুন ।
- OAuth সম্মতি স্ক্রিনটি কনফিগার করুন ।
- আপনার চ্যাট অ্যাপের জন্য একটি নাম, আইকন এবং বিবরণ দিয়ে গুগল চ্যাট এপিআই সক্রিয় ও কনফিগার করুন ।
- Node.js ক্লাউড ক্লায়েন্ট লাইব্রেরি ইনস্টল করুন।
- অনুমোদনের পরিধি নির্বাচন করুন ।
পাইথন
- গুগল চ্যাট ব্যবহারের সুবিধাসহ একটি ব্যবসায়িক বা এন্টারপ্রাইজ গুগল ওয়ার্কস্পেস অ্যাকাউন্ট।
- আপনার পরিবেশ প্রস্তুত করুন:
- একটি গুগল ক্লাউড প্রজেক্ট তৈরি করুন ।
- OAuth সম্মতি স্ক্রিনটি কনফিগার করুন ।
- আপনার চ্যাট অ্যাপের জন্য একটি নাম, আইকন এবং বিবরণ দিয়ে গুগল চ্যাট এপিআই সক্রিয় ও কনফিগার করুন ।
- পাইথন ক্লাউড ক্লায়েন্ট লাইব্রেরি ইনস্টল করুন।
- অনুমোদনের পরিধি নির্বাচন করুন ।
জাভা
- গুগল চ্যাট ব্যবহারের সুবিধাসহ একটি ব্যবসায়িক বা এন্টারপ্রাইজ গুগল ওয়ার্কস্পেস অ্যাকাউন্ট।
- আপনার পরিবেশ প্রস্তুত করুন:
- একটি গুগল ক্লাউড প্রজেক্ট তৈরি করুন ।
- OAuth সম্মতি স্ক্রিনটি কনফিগার করুন ।
- আপনার চ্যাট অ্যাপের জন্য একটি নাম, আইকন এবং বিবরণ দিয়ে গুগল চ্যাট এপিআই সক্রিয় ও কনফিগার করুন ।
- জাভা ক্লাউড ক্লায়েন্ট লাইব্রেরি ইনস্টল করুন।
- অনুমোদনের পরিধি নির্বাচন করুন ।
অ্যাপস স্ক্রিপ্ট
- গুগল চ্যাট ব্যবহারের সুবিধাসহ একটি ব্যবসায়িক বা এন্টারপ্রাইজ গুগল ওয়ার্কস্পেস অ্যাকাউন্ট।
- আপনার পরিবেশ প্রস্তুত করুন:
- একটি গুগল ক্লাউড প্রজেক্ট তৈরি করুন ।
- OAuth সম্মতি স্ক্রিনটি কনফিগার করুন ।
- আপনার চ্যাট অ্যাপের জন্য একটি নাম, আইকন এবং বিবরণ দিয়ে গুগল চ্যাট এপিআই সক্রিয় ও কনফিগার করুন ।
- একটি স্বতন্ত্র অ্যাপস স্ক্রিপ্ট প্রজেক্ট তৈরি করুন এবং অ্যাডভান্সড চ্যাট সার্ভিসটি চালু করুন।
- অনুমোদনের পরিধি নির্বাচন করুন ।
একটি গ্রুপ চ্যাট খুঁজুন
গুগল চ্যাটে কোনো গ্রুপ চ্যাট খুঁজে পেতে, আপনার অনুরোধে নিম্নলিখিত তথ্যগুলো দিন:
- অনুমোদনের পরিধি:
chat.memberships.readonlyঅথবাchat.memberships। - অন্যান্য ব্যবহারকারীদের রিসোর্স নামগুলো পাস করে
findGroupChats( RPC , REST ) মেথডটি কল করুন।
নির্দিষ্ট সদস্যদের নিয়ে গ্রুপ চ্যাট খুঁজে বের করার উপায় নিচে দেওয়া হলো:
নোড.জেএস
/**
* This sample shows how to find a group chat with specific members.
*
* It relies on the @google-apps/chat npm package.
*/
// Read the documentation for more details:
// https://developers.google.com/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.ChatService.FindGroupChats
const {ChatServiceClient} = require('@google-apps/chat');
const {auth} = require('google-auth-library');
async function main() {
// Create a client
const chatClient = new ChatServiceClient({
authClient: await auth.getClient({
scopes: ['https://www.googleapis.com/auth/chat.memberships.readonly']
})
});
// The users to find a group chat with.
// Don't include the caller.
const users = [
'users/123456789',
'users/987654321'
];
// Create the request
const request = {
users: users
};
// Call the API
const response = await chatClient.findGroupChats(request);
// Handle the response
if (response.spaces && response.spaces.length > 0) {
console.log('Found group chat:', response.spaces[0].name);
} else {
console.log('No group chat found.');
}
}
main().catch(console.error);
পাইথন
"""
This sample shows how to find a group chat with specific members.
"""
from google.apps import chat_v1
import google.auth
# Read the documentation for more details:
# https://developers.google.com/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.ChatService.FindGroupChats
def find_group_chat():
# Create a client
scopes = ["https://www.googleapis.com/auth/chat.memberships.readonly"]
credentials, _ = google.auth.default(scopes=scopes)
client = chat_v1.ChatServiceClient(credentials=credentials)
# The users to find a group chat with.
# Don't include the caller.
users_list = [
"users/123456789",
"users/987654321"
]
# Create the request
request = chat_v1.FindGroupChatsRequest(
users=users_list
)
# Call the API
response = client.find_group_chats(request)
# Handle the response
if response.spaces:
print(f"Found group chat: {response.spaces[0].name}")
else:
print("No group chat found.")
if __name__ == "__main__":
find_group_chat()
জাভা
/**
* This sample shows how to find a group chat with specific members.
*/
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.chat.v1.ChatServiceClient;
import com.google.chat.v1.ChatServiceSettings;
import com.google.chat.v1.FindGroupChatsRequest;
import com.google.chat.v1.FindGroupChatsResponse;
import java.util.Arrays;
import java.util.List;
// Read the documentation for more details:
// https://developers.google.com/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.ChatService.FindGroupChats
public class FindGroupChat {
public static void main(String[] args) throws Exception {
GoogleCredentials credentials = GoogleCredentials.getApplicationDefault()
.createScoped(Arrays.asList("https://www.googleapis.com/auth/chat.memberships.readonly"));
ChatServiceSettings settings = ChatServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credentials))
.build();
try (ChatServiceClient chatServiceClient = ChatServiceClient.create(settings)) {
List<String> users = Arrays.asList(
"users/123456789",
"users/987654321"
);
FindGroupChatsRequest request = FindGroupChatsRequest.newBuilder()
.addAllUsers(users)
.build();
FindGroupChatsResponse response = chatServiceClient.findGroupChats(request);
if (!response.getSpacesList().isEmpty()) {
System.out.printf("Found group chat: %s\n", response.getSpacesList().get(0).getName());
} else {
System.out.println("No group chat found.");
}
}
}
}
অ্যাপস স্ক্রিপ্ট
/**
* This sample shows how to find a group chat with specific members.
*/
// Read the documentation for more details:
// https://developers.google.com/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.ChatService.FindGroupChats
function findGroupChat() {
// The users to find a group chat with.
// Don't include the caller.
const users = [
'users/123456789',
'users/987654321'
];
try {
// Call the API
// In Apps Script, query parameters are passed as optional arguments
const response = Chat.Spaces.findGroupChats({
users: users
});
if (response.spaces && response.spaces.length > 0) {
console.log('Found group chat: ' + response.spaces[0].name);
} else {
console.log('No group chat found.');
}
} catch (err) {
// Handle error
console.log('Failed to find group chat: ' + err.message);
}
}
এই নমুনাটি চালানোর জন্য, ব্যবহারকারী রিসোর্সের নামগুলো বৈধ ইউজার আইডি দিয়ে প্রতিস্থাপন করুন। আপনি পিপল এপিআই (People API) অথবা ডিরেক্টরি এপিআই (Directory API) থেকে ইউজার আইডি সংগ্রহ করতে পারেন।
চ্যাট এপিআই FindGroupChatsResponse ( RPC , REST ) এর একটি ইনস্ট্যান্স রিটার্ন করে, যাতে খুঁজে পাওয়া স্পেসগুলোর তালিকা থাকে।
বিস্তারিত সহ একটি গ্রুপ চ্যাট খুঁজুন
ডিফল্টরূপে, findGroupChats ( RPC , REST ) Space অবজেক্ট রিটার্ন করে, যেগুলোতে শুধুমাত্র name ফিল্ড থাকে এবং এর ফরম্যাট হলো spaces/SPACE_NAME । স্পেস সম্পর্কে আরও বিস্তারিত তথ্য, যেমন displayName , spaceType , বা createTime পেতে, spaceView প্যারামিটারটি SPACE_VIEW_EXPANDED হিসেবে উল্লেখ করুন।
SPACE_VIEW_EXPANDED ব্যবহার করার জন্য একটি অতিরিক্ত অথরাইজেশন স্কোপ প্রয়োজন: https://www.googleapis.com/auth/chat.spaces অথবা https://www.googleapis.com/auth/chat.spaces.readonly ।
যেভাবে একটি গ্রুপ চ্যাট খুঁজে বের করবেন এবং তার বিবরণ সংগ্রহ করবেন:
নোড.জেএস
/**
* This sample shows how to find a group chat with specific members and return details.
*
* It relies on the @google-apps/chat npm package.
*/
// Read the documentation for more details:
// https://developers.google.com/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.ChatService.FindGroupChats
const {ChatServiceClient} = require('@google-apps/chat');
const {auth} = require('google-auth-library');
async function main() {
// Create a client
const chatClient = new ChatServiceClient({
authClient: await auth.getClient({
scopes: [
'https://www.googleapis.com/auth/chat.spaces.readonly',
'https://www.googleapis.com/auth/chat.memberships.readonly'
]
})
});
// The users to find a group chat with.
// Don't include the caller.
const users = [
'users/123456789',
'users/987654321'
];
// Create the request
const request = {
users: users,
spaceView: 'SPACE_VIEW_EXPANDED'
};
// Call the API
const response = await chatClient.findGroupChats(request);
// Handle the response
if (response.spaces && response.spaces.length > 0) {
console.log('Found group chat:', response.spaces[0].displayName);
} else {
console.log('No group chat found.');
}
}
main().catch(console.error);
পাইথন
"""
This sample shows how to find a group chat with specific members and return details.
"""
from google.apps import chat_v1
import google.auth
# Read the documentation for more details:
# https://developers.google.com/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.ChatService.FindGroupChats
def find_group_chat_with_details():
# Create a client
scopes = [
"https://www.googleapis.com/auth/chat.memberships.readonly",
"https://www.googleapis.com/auth/chat.spaces.readonly"
]
credentials, _ = google.auth.default(scopes=scopes)
client = chat_v1.ChatServiceClient(credentials=credentials)
# The users to find a group chat with.
# Don't include the caller.
users_list = [
"users/123456789",
"users/987654321"
]
# Create the request
request = chat_v1.FindGroupChatsRequest(
users=users_list,
space_view=chat_v1.SpaceView.SPACE_VIEW_EXPANDED
)
# Call the API
response = client.find_group_chats(request)
# Handle the response
if response.spaces:
print(f"Found group chat: {response.spaces[0].display_name}")
else:
print("No group chat found.")
if __name__ == "__main__":
find_group_chat_with_details()
জাভা
/**
* This sample shows how to find a group chat with specific members and return details.
*/
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.chat.v1.ChatServiceClient;
import com.google.chat.v1.ChatServiceSettings;
import com.google.chat.v1.FindGroupChatsRequest;
import com.google.chat.v1.FindGroupChatsResponse;
import com.google.chat.v1.SpaceView;
import java.util.Arrays;
import java.util.List;
// Read the documentation for more details:
// https://developers.google.com/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.ChatService.FindGroupChats
public class FindGroupChatWithDetails {
public static void main(String[] args) throws Exception {
GoogleCredentials credentials = GoogleCredentials.getApplicationDefault()
.createScoped(Arrays.asList(
"https://www.googleapis.com/auth/chat.memberships.readonly",
"https://www.googleapis.com/auth/chat.spaces.readonly"
));
ChatServiceSettings settings = ChatServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credentials))
.build();
try (ChatServiceClient chatServiceClient = ChatServiceClient.create(settings)) {
List<String> users = Arrays.asList(
"users/123456789",
"users/987654321"
);
FindGroupChatsRequest request = FindGroupChatsRequest.newBuilder()
.addAllUsers(users)
.setSpaceView(SpaceView.SPACE_VIEW_EXPANDED)
.build();
FindGroupChatsResponse response = chatServiceClient.findGroupChats(request);
if (!response.getSpacesList().isEmpty()) {
System.out.printf("Found group chat: %s\n", response.getSpacesList().get(0).getDisplayName());
} else {
System.out.println("No group chat found.");
}
}
}
}
অ্যাপস স্ক্রিপ্ট
/**
* This sample shows how to find a group chat with specific members and return details.
*/
// Read the documentation for more details:
// https://developers.google.com/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.ChatService.FindGroupChats
function findGroupChatWithDetails() {
// The users to find a group chat with.
// Don't include the caller.
const users = [
'users/123456789',
'users/987654321'
];
try {
// Call the API
// In Apps Script, query parameters are passed as optional arguments
const response = Chat.Spaces.findGroupChats({
users: users,
spaceView: 'SPACE_VIEW_EXPANDED'
});
if (response.spaces && response.spaces.length > 0) {
console.log('Found group chat: ' + response.spaces[0].displayName);
} else {
console.log('No group chat found.');
}
} catch (err) {
// Handle error
console.log('Failed to find group chat: ' + err.message);
}
}
এই নমুনাটি চালানোর জন্য, ব্যবহারকারী রিসোর্সের নামগুলো বৈধ ইউজার আইডি দিয়ে প্রতিস্থাপন করুন। আপনি পিপল এপিআই (People API) অথবা ডিরেক্টরি এপিআই (Directory API) থেকে ইউজার আইডি সংগ্রহ করতে পারেন।
চ্যাট এপিআই FindGroupChatsResponse ( RPC , REST ) এর একটি ইনস্ট্যান্স রিটার্ন করে, যাতে অতিরিক্ত spaceView বিবরণ সহ খুঁজে পাওয়া স্পেসগুলির তালিকা থাকে।
সম্পর্কিত বিষয়
- একটি জায়গা তৈরি করুন
- একটি জায়গা তৈরি করুন
- তালিকার স্থান
- একটি স্থান আপডেট করুন
- একটি স্পেস মুছে ফেলুন
- সরাসরি বার্তা খুঁজুন