google-chat-webhook
An SDK for Google Chats Incoming Webhooks. Enables you to notify Google Chat chatrooms with simple text message threads or high fidelity interactive card interfaces.
A sample text message thread. Formatting can be done just as in user interface.
A sample interactive card thread. Embed images, basic html text blocks, rows of buttons and more advanced keyValue widgets.
Other sample card with keyValue widget.
Table of contents
- Getting started
- API
- Sample
- Sources
1. Getting started
- Create or select an existing chatroom in Google Chat
- Via the settings button choose
Configure Webhooks
- Create new webhook
- Copy webhooks new URL
- Run the sample
WEBHOOK_URL=${YOUR_WEBHOOK_URL_HERE} npm run sample
- Explore the sample code in
./sample/index
2. API
- Sending text message
await client.sendText"This is a basic text thread.";
- Formatting text helper
// ~_*block struck italic text*_~; // `some inline code`; // ```// multi// line// code// ```;
- Formatting mention helper
// <users/all>;// <users/sample-user-id>;
Given you somehow know the users ID you may use the syntax described in 'Messages that @mention specific users'
- Formatting link helper
// <https://sample.com/|Sample Website>;// <https://sample.com/|https://sample.com/>;
- Sending card message
See sample below.
;await googleChat.sendCardcard;
3. Sample
; ;if !url ; /** * Send a simple text message to hangouts chat. Formatting is as * within the UI. * *bold text* * _italic text_ * ~strike text~ * `inline code` * ``` * multi-line * code * ``` */;await client.sendTextMessagesimpleMessage; /** * Send a more complex card message. */ ; await googleChat.sendCardcard;