Skip to content

Commit

Permalink
feat: update GAPIC samples to be featured in create message guide (#871)
Browse files Browse the repository at this point in the history
* feat: update GAPIC samples to be featured in create message guide

* Remove test ID

* Fix style

---------

Co-authored-by: pierrick <[email protected]>
  • Loading branch information
PierrickVoulet and pierrick authored Aug 21, 2024
1 parent 765b105 commit 7211c7e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 56 deletions.
53 changes: 0 additions & 53 deletions chat/client-libraries/cloud/create-message-app-cred-with-cards.js

This file was deleted.

44 changes: 43 additions & 1 deletion chat/client-libraries/cloud/create-message-app-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,49 @@ async function main() {
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
message: { text: 'Hello with app credential!' }
message: {
text: 'πŸ‘‹πŸŒŽ Hello world! I created this message by calling ' +
'the Chat API\'s `messages.create()` method.',
cardsV2 : [{ card: {
header: {
title: 'About this message',
imageUrl: 'https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/info/default/24px.svg'
},
sections: [{
header: 'Contents',
widgets: [{ textParagraph: {
text: 'πŸ”‘ <b>Text</b> which can include ' +
'hyperlinks πŸ”—, emojis πŸ˜„πŸŽ‰, and @mentions πŸ—£οΈ.'
}}, { textParagraph: {
text: 'πŸ–ΌοΈ A <b>card</b> to display visual elements' +
'and request information such as text πŸ”€, ' +
'dates and times πŸ“…, and selections β˜‘οΈ.'
}}, { textParagraph: {
text: 'πŸ‘‰πŸ”˜ An <b>accessory widget</b> which adds ' +
'a button to the bottom of a message.'
}}
]}, {
header: "What's next",
collapsible: true,
widgets: [{ textParagraph: {
text: "❀️ <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages.reactions/create'>Add a reaction</a>."
}}, { textParagraph: {
text: "πŸ”„ <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/patch'>Update</a> " +
"or ❌ <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/delete'>delete</a> " +
"the message."
}
}]
}
]
}}],
accessoryWidgets: [{ buttonList: { buttons: [{
text: 'View documentation',
icon: { materialIcon: { name: 'link' }},
onClick: { openLink: {
url: 'https://developers.google.com/workspace/chat/create-messages'
}}
}]}}]
}
};

// Make the request
Expand Down
11 changes: 10 additions & 1 deletion chat/client-libraries/cloud/create-message-user-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ async function main() {
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
message: { text: 'Hello with user credential!' }
message: {
text: 'πŸ‘‹πŸŒŽ Hello world!' +
'Text messages can contain things like:\n\n' +
'* Hyperlinks πŸ”—\n' +
'* Emojis πŸ˜„πŸŽ‰\n' +
'* Mentions of other Chat users `@` \n\n' +
'For details, see the ' +
'<https://developers.google.com/workspace/chat/format-messages' +
'|Chat API developer documentation>.'
}
};

// Make the request
Expand Down
1 change: 0 additions & 1 deletion chat/client-libraries/cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"scripts": {
"create-membership-user-cred-for-app.js": "node ./create-membership-user-cred-for-app.js",
"create-membership-user-cred.js": "node ./create-membership-user-cred.js",
"create-message-app-cred-with-cards.js": "node ./create-message-app-cred-with-cards.js",
"create-message-app-cred.js": "node ./create-message-app-cred.js",
"create-message-user-cred-at-mention.js": "node ./create-message-user-cred-at-mention.js",
"create-message-user-cred-message-id.js": "node ./create-message-user-cred-message-id.js",
Expand Down

0 comments on commit 7211c7e

Please sign in to comment.