I am creating Google Calendar Events within Chat (1:1, group chat, and Space).
After creating and sharing the event with the invitees, an automated message is sent in the chat.
Using the spaces.messages.list method, I can retrieve the message response containing the text "Created an event" but I cannot access the Google Calendar Event card associated with the message.
Similarly, when a Google Task is created in the Chat Space, I can retrieve the text "Created a task" but not the Task resource details.
I would like to extract details from this card or obtain the Calendar Event/Task resource via the Chat API. How can I retrieve the calendar event information or card from the message in this scenario? Are there any specific fields or additional API calls I should use to get the Calendar Event/Task resource?
Is there a way to retrieve the iCalUID or id of the Google Calendar Event, or the id of the Google Task associated with this message?Are there any specific fields or API calls within the Google Chat API that could provide these details?"
Thank you. Please let me know if you need any further information.
My code(Java) for listing message in a space:
List<String> SCOPE =
Arrays.asList(
"https://www.googleapis.com/auth/chat.spaces",
"https://www.googleapis.com/auth/chat.messages",
"https://www.googleapis.com/auth/chat.memberships"
);
try (InputStream isCredential = new ByteArrayInputStream(sServiceAccountJson.getBytes())) {
GoogleCredentials googleCredentials =
ServiceAccountCredentials
.fromStream(isCredential)
.createDelegated(sAdminAddress)
.createScoped(SCOPE)
.toBuilder()
.build();
ChatServiceSettings chatServiceSettings =
ChatServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(googleCredentials))
.build();
ListMessagesRequest request = ListMessagesRequest.newBuilder()
.setParent("spaces/{space}")
.build();
for (Message message : chatServiceClient.listMessages(request).iterateAll()) {
System.out.println(JsonFormat.printer().print(message));
}
}
Message response:
{
"name": "spaces/{spaces}/messages/{message}",
"sender": {
"name": "users/{user}",
"type": "HUMAN"
},
"createTime": "2024-09-30T05:29:07.225471Z",
"text": "Created an event",
"thread": {
"name": "spaces/{spaces}/threads/{thread}"
},
"space": {
"name": "spaces/{spaces}"
},
"argumentText": "Created an event",
"formattedText": "Created an event"
}
{
"name": "spaces/{spaces}/messages/{message}",
"sender": {
"name": "users/{user}",
"type": "HUMAN"
},
"createTime": "2024-09-30T05:52:29.173567Z",
"text": "Created a task (via Tasks)",
"thread": {
"name": "spaces/{spaces}/threads/{thread}"
},
"space": {
"name": "spaces/{spaces}"
},
"argumentText": "Created a task (via Tasks)",
"formattedText": "Created a task (via Tasks)"
}