-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(google-chat): add Google Chat integration with OAuth #3339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
waleedlatif1
wants to merge
7
commits into
staging
Choose a base branch
from
waleedlatif1/add-google-chat
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3d56ac9
feat(google-chat): add Google Chat integration with OAuth
waleedlatif1 5cccde3
fix(google-chat): use underscore in docsLink path
waleedlatif1 30cb108
lint
waleedlatif1 f5c8c47
fix(google-chat): add OAuth provider registration to auth.ts
waleedlatif1 8d7d484
Merge remote-tracking branch 'origin/staging' into waleedlatif1/add-g…
waleedlatif1 15c3fa4
improvement(google-chat): validate tools, set optional fields to adva…
waleedlatif1 993ee30
lint
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| --- | ||
| title: Google Chat | ||
| description: Send messages and manage Google Chat spaces | ||
| --- | ||
|
|
||
| import { BlockInfoCard } from "@/components/ui/block-info-card" | ||
|
|
||
| <BlockInfoCard | ||
| type="google_chat" | ||
| color="#E0E0E0" | ||
| /> | ||
|
|
||
| ## Usage Instructions | ||
|
|
||
| Integrate with Google Chat to send messages to spaces and list available spaces using OAuth. | ||
|
|
||
|
|
||
|
|
||
| ## Tools | ||
|
|
||
| ### `google_chat_send_message` | ||
|
|
||
| Send a message to a Google Chat space | ||
|
|
||
| #### Input | ||
|
|
||
| | Parameter | Type | Required | Description | | ||
| | --------- | ---- | -------- | ----------- | | ||
| | `spaceId` | string | Yes | The Google Chat space ID \(e.g., spaces/AAAA1234\) | | ||
| | `message` | string | Yes | Message text to send | | ||
| | `threadKey` | string | No | Thread key for sending a threaded reply | | ||
|
|
||
| #### Output | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --------- | ---- | ----------- | | ||
| | `messageName` | string | Google Chat message resource name | | ||
| | `spaceName` | string | Space the message was sent to | | ||
| | `threadName` | string | Thread resource name | | ||
| | `text` | string | Message text that was sent | | ||
| | `createTime` | string | Timestamp when the message was created | | ||
|
|
||
| ### `google_chat_list_spaces` | ||
|
|
||
| List Google Chat spaces the user is a member of | ||
|
|
||
| #### Input | ||
|
|
||
| | Parameter | Type | Required | Description | | ||
| | --------- | ---- | -------- | ----------- | | ||
| | `pageSize` | number | No | Maximum number of spaces to return \(default 100, max 1000\) | | ||
| | `pageToken` | string | No | Token for fetching the next page of results | | ||
| | `filter` | string | No | Filter by space type \(e.g., spaceType = "SPACE", spaceType = "GROUP_CHAT" OR spaceType = "DIRECT_MESSAGE"\) | | ||
|
|
||
| #### Output | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --------- | ---- | ----------- | | ||
| | `spaces` | json | Array of Google Chat space objects | | ||
| | `nextPageToken` | string | Token for fetching the next page of results | | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| import { GoogleChatIcon } from '@/components/icons' | ||
| import type { BlockConfig } from '@/blocks/types' | ||
| import { AuthMode } from '@/blocks/types' | ||
| import type { GoogleChatResponse } from '@/tools/google_chat/types' | ||
|
|
||
| export const GoogleChatBlock: BlockConfig<GoogleChatResponse> = { | ||
| type: 'google_chat', | ||
| name: 'Google Chat', | ||
| description: 'Send messages and manage Google Chat spaces', | ||
| authMode: AuthMode.OAuth, | ||
| longDescription: | ||
| 'Integrate with Google Chat to send messages to spaces and list available spaces using OAuth.', | ||
| docsLink: 'https://docs.sim.ai/tools/google_chat', | ||
| category: 'tools', | ||
| bgColor: '#E0E0E0', | ||
| icon: GoogleChatIcon, | ||
| subBlocks: [ | ||
| { | ||
| id: 'operation', | ||
| title: 'Operation', | ||
| type: 'dropdown', | ||
| options: [ | ||
| { label: 'Send Message', id: 'send_message' }, | ||
| { label: 'List Spaces', id: 'list_spaces' }, | ||
| ], | ||
| value: () => 'send_message', | ||
| }, | ||
| { | ||
| id: 'credential', | ||
| title: 'Google Chat Account', | ||
| type: 'oauth-input', | ||
| canonicalParamId: 'oauthCredential', | ||
| mode: 'basic', | ||
| required: true, | ||
| serviceId: 'google-chat', | ||
| requiredScopes: [ | ||
| 'https://www.googleapis.com/auth/chat.spaces.readonly', | ||
| 'https://www.googleapis.com/auth/chat.messages.create', | ||
| ], | ||
| placeholder: 'Select Google account', | ||
| }, | ||
| { | ||
| id: 'manualCredential', | ||
| title: 'Google Chat Account', | ||
| type: 'short-input', | ||
| canonicalParamId: 'oauthCredential', | ||
| mode: 'advanced', | ||
| placeholder: 'Enter credential ID', | ||
| required: true, | ||
| }, | ||
| { | ||
| id: 'spaceId', | ||
| title: 'Space ID', | ||
| type: 'short-input', | ||
| placeholder: 'e.g., spaces/AAAA1234 or AAAA1234', | ||
| required: { field: 'operation', value: 'send_message' }, | ||
| condition: { field: 'operation', value: 'send_message' }, | ||
| }, | ||
| { | ||
| id: 'message', | ||
| title: 'Message', | ||
| type: 'long-input', | ||
| placeholder: 'Enter your message', | ||
| required: { field: 'operation', value: 'send_message' }, | ||
| condition: { field: 'operation', value: 'send_message' }, | ||
| }, | ||
| { | ||
| id: 'threadKey', | ||
| title: 'Thread Key', | ||
| type: 'short-input', | ||
| placeholder: 'Optional thread key for threaded replies', | ||
| condition: { field: 'operation', value: 'send_message' }, | ||
| }, | ||
| { | ||
| id: 'filter', | ||
| title: 'Filter', | ||
| type: 'short-input', | ||
| placeholder: 'e.g., spaceType = "SPACE"', | ||
| condition: { field: 'operation', value: 'list_spaces' }, | ||
| }, | ||
| { | ||
| id: 'pageSize', | ||
| title: 'Max Results', | ||
| type: 'short-input', | ||
| placeholder: 'Maximum spaces to return (default 100)', | ||
| condition: { field: 'operation', value: 'list_spaces' }, | ||
| }, | ||
| ], | ||
| tools: { | ||
| access: ['google_chat_send_message', 'google_chat_list_spaces'], | ||
| config: { | ||
| tool: (params) => { | ||
| switch (params.operation) { | ||
| case 'send_message': | ||
| return 'google_chat_send_message' | ||
| case 'list_spaces': | ||
| return 'google_chat_list_spaces' | ||
| default: | ||
| throw new Error(`Invalid Google Chat operation: ${params.operation}`) | ||
| } | ||
| }, | ||
| params: (params) => { | ||
| const { oauthCredential, operation, ...rest } = params | ||
|
|
||
| switch (operation) { | ||
| case 'send_message': | ||
| return { | ||
| oauthCredential, | ||
| spaceId: rest.spaceId, | ||
| message: rest.message, | ||
| threadKey: rest.threadKey, | ||
| } | ||
| case 'list_spaces': | ||
| return { | ||
| oauthCredential, | ||
| pageSize: rest.pageSize ? Number(rest.pageSize) : undefined, | ||
| filter: rest.filter, | ||
| } | ||
| default: | ||
| return { oauthCredential, ...rest } | ||
| } | ||
| }, | ||
| }, | ||
| }, | ||
| inputs: { | ||
| operation: { type: 'string', description: 'Operation to perform' }, | ||
| oauthCredential: { type: 'string', description: 'Google Chat OAuth credential' }, | ||
| spaceId: { type: 'string', description: 'Google Chat space ID' }, | ||
| message: { type: 'string', description: 'Message text to send' }, | ||
| threadKey: { type: 'string', description: 'Thread key for threaded replies' }, | ||
| filter: { type: 'string', description: 'Filter by space type' }, | ||
| pageSize: { type: 'number', description: 'Maximum number of spaces to return' }, | ||
| }, | ||
| outputs: { | ||
| messageName: { type: 'string', description: 'Message resource name' }, | ||
| spaceName: { type: 'string', description: 'Space resource name' }, | ||
| threadName: { type: 'string', description: 'Thread resource name' }, | ||
| text: { type: 'string', description: 'Message text that was sent' }, | ||
| createTime: { type: 'string', description: 'Message creation timestamp' }, | ||
| spaces: { type: 'json', description: 'Array of Google Chat space objects' }, | ||
| nextPageToken: { type: 'string', description: 'Token for next page of results' }, | ||
| }, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { listSpacesTool } from './list_spaces' | ||
| import { sendMessageTool } from './send_message' | ||
|
|
||
| export const googleChatSendMessageTool = sendMessageTool | ||
| export const googleChatListSpacesTool = listSpacesTool |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pageTokennot wired through forlist_spacespaginationThe
pageTokenparameter is defined inGoogleChatListSpacesParamsand correctly forwarded to the Google API inlist_spaces.ts, but it is silently dropped at the block level — it is absent frominputs,subBlocks, and theparamsreturn for thelist_spacescase.The block already outputs
nextPageToken, but there is no corresponding input to feed that token back into a subsequent call, making pagination non-functional through the block.Add
pageTokento the returned params:Also add
pageTokento theinputsobject:And add a subBlock (in
advancedmode) so users can wire a previous call'snextPageTokenoutput into this field: