Skip to content

Commit cad240a

Browse files
PierrickVouletpierrick
and
pierrick
authored
feat: update GAPIC samples to be featured in create message guide (#1690)
* feat: update GAPIC samples to be featured in create message guide * nit fix --------- Co-authored-by: pierrick <pierrick@google.com>
1 parent 823468e commit cad240a

File tree

4 files changed

+50
-79
lines changed

4 files changed

+50
-79
lines changed

β€Žchat/client-libraries/cloud/create_message_app_cred.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,47 @@ def create_message_with_app_cred():
3232
# Replace SPACE_NAME here.
3333
parent = "spaces/SPACE_NAME",
3434
message = {
35-
"text" : "Hello with app credential!"
35+
"text": 'πŸ‘‹πŸŒŽ Hello world! I created this message by calling ' +
36+
'the Chat API\'s `messages.create()` method.',
37+
"cards_v2" : [{ "card": {
38+
"header": {
39+
"title": 'About this message',
40+
"image_url": 'https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/info/default/24px.svg'
41+
},
42+
"sections": [{
43+
"header": "Contents",
44+
"widgets": [{ "text_paragraph": {
45+
"text": 'πŸ”‘ <b>Text</b> which can include ' +
46+
'hyperlinks πŸ”—, emojis πŸ˜„πŸŽ‰, and @mentions πŸ—£οΈ.'
47+
}}, { "text_paragraph": {
48+
"text": 'πŸ–ΌοΈ A <b>card</b> to display visual elements' +
49+
'and request information such as text πŸ”€, ' +
50+
'dates and times πŸ“…, and selections β˜‘οΈ.'
51+
}}, { "text_paragraph": {
52+
"text": 'πŸ‘‰πŸ”˜ An <b>accessory widget</b> which adds ' +
53+
'a button to the bottom of a message.'
54+
}}
55+
]}, {
56+
"header": "What's next",
57+
"collapsible": True,
58+
"widgets": [{ "text_paragraph": {
59+
"text": "❀️ <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages.reactions/create'>Add a reaction</a>."
60+
}}, { "text_paragraph": {
61+
"text": "πŸ”„ <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/patch'>Update</a> " +
62+
"or ❌ <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/delete'>delete</a> " +
63+
"the message."
64+
}
65+
}]
66+
}
67+
]
68+
}}],
69+
"accessory_widgets": [{ "button_list": { "buttons": [{
70+
"text": 'View documentation',
71+
"icon": { "material_icon": { "name": 'link' }},
72+
"on_click": { "open_link": {
73+
"url": 'https://developers.google.com/workspace/chat/create-messages'
74+
}}
75+
}]}}]
3676
}
3777
)
3878

β€Žchat/client-libraries/cloud/create_message_app_cred_with_cards.py

Lines changed: 0 additions & 76 deletions
This file was deleted.

β€Žchat/client-libraries/cloud/create_message_user_cred.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ def create_message_with_user_cred():
3333
# Replace SPACE_NAME here.
3434
parent = "spaces/SPACE_NAME",
3535
message = {
36-
"text": "Hello with user credential!"
36+
"text": 'πŸ‘‹πŸŒŽ Hello world!' +
37+
'Text messages can contain things like:\n\n' +
38+
'* Hyperlinks πŸ”—\n' +
39+
'* Emojis πŸ˜„πŸŽ‰\n' +
40+
'* Mentions of other Chat users `@` \n\n' +
41+
'For details, see the ' +
42+
'<https://developers.google.com/workspace/chat/format-messages' +
43+
'|Chat API developer documentation>.'
3744
}
3845
)
3946

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
google_auth_oauthlib==1.2.0
22
protobuf==4.21.12
3-
google-apps-chat==0.1.0
3+
google-apps-chat==0.1.9

0 commit comments

Comments
Β (0)