npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hangouts-chat-api

v0.4.3

Published

Node.js wrapper for Google's Hangouts Chat REST API

Downloads

5

Readme

hangouts-chat-api

Node.js wrapper for Google's Hangouts Chat REST API

license npm Travis Dependency Status devDependency Status

What is hangouts-chat-api?

hangouts-chat-api makes sending notifications to Google Hangouts Chat rooms easy.

How do I install it?

First thing first, let's make sure you have the necessary pre-requisites.

System Dependencies

Node

Package

  • npm install hangouts-chat-api

API

HangoutsChatNotification(domain, roomId, authToken)

Creates an instance of HangoutsChatNotification

domain

Type: string

The domain the HangoutsChat server is running on. Ex: https://www.example.com

roomId

Type: string

The room id of the HangoutsChat room the notification should be posted to.

authToken

Type: string

The auth token for the HangoutsChat room the notification should be posted to.

.setFrom(name)

Sets the from name of the message

name

Type: string

A label to be shown in addition to the sender's name

.setTextMessageFormat()

Set message format to 'text' instead of 'html'.

.setColor(color)

Sets color of the message

color

Type: string

Valid values include: yellow, green, red, purple, gray, and random.

.shouldNotify()

Message notifies members of the room.

.setMessage(message)

Sets message of notfication

message

Type: string

The message body

.addCard(id, style, title)

Converts notification to card instead of a basic message.

id

Type: string

An id that will help HangoutsChat recognise the same card when it is sent multiple times.

style

Type: string

Type of the card. Valid values are file, image, application, link, and media.

title

Type: string

The title of the card.

.addCardThumbnail(url)

Adds thumbnail to card.

url

Type: string

The thumbnail url.

.addCardThumbnailDetails(url, url2x, width, height)

Adds thumbnail with retina support to card.

url

Type: string

The thumbnail url.

url2x

Type: string

The thumbnail url in retina.

width

Type: string

The original width of the image.

height

Type: string

The original height of the image.

.addActivity(html)

Adds activity to card.

html

Type: string

Html for the activity to show in one line a summary of the action that happened.

.addActivityWithIcon(html, iconUrl)

Add activity with icon to card.

html

Type: string

Html for the activity to show in one line a summary of the action that happened.

iconUrl

Type: string

The url where the icon is.

.addActivityWithIconDetails(html, iconUrl, icon2xUrl)

Adds activity with icon that has retina support to card.

html

Type: string

Html for the activity to show in one line a summary of the action that happened.

iconUrl

Type: string

The url where the icon is.

icon2xUrl

Type: string

The url for the icon in retina.

.setCardToCompactFormat()

Sets card to compact format.

.setCardToMediumFormat(id, style, title)

Sets card to medium format.

.addCardUrl(url)

Sets card url

url

Type: string

URL that should open when the card is clicked.

.addCardDescription(description, format)

Sets card description.

description

Type: string

The description in the specific format.

format

Type: string

Description format. Valid values include: html and text.

.addCardAttribute(label, description, style)

Adds an attribute to a card.

label

Type: string

Label for the attribute of the card.

description

Type: string

Value of the attribute of the card.

style

Type: string

AUI Integrations for now supporting only lozenges. Valid values: lozenge-success, lozenge-error, lozenge-current, lozenge-complete, lozenge-moved, and lozenge

.addCardAttributeWithUrl(label, description, style, url)

Adds an attribute to a card.

label

Type: string

Label for the attribute of the card.

description

Type: string

Value of the attribute of the card.

style

Type: string

AUI Integrations for now supporting only lozenges. Valid values: lozenge-success, lozenge-error, lozenge-current, lozenge-complete, lozenge-moved, and lozenge

url

Type: string

Url to be opened when a user clicks on the label

.addCardAttributeWithIcon(label, description, style, iconUrl)

Adds an attribute to a card.

label

Type: string

Label for the attribute of the card.

description

Type: string

Value of the attribute of the card.

style

Type: string

AUI Integrations for now supporting only lozenges. Valid values: lozenge-success, lozenge-error, lozenge-current, lozenge-complete, lozenge-moved, and lozenge

iconUrl

Type: string

The url where the icon is

.addCardAttributeWithIconAndUrl(label, description, style, iconUrl, url)

Adds an attribute to a card.

label

Type: string

Label for the attribute of the card.

description

Type: string

Value of the attribute of the card.

style

Type: string

AUI Integrations for now supporting only lozenges. Valid values: lozenge-success, lozenge-error, lozenge-current, lozenge-complete, lozenge-moved, and lozenge

iconUrl

Type: string

The url where the icon is

url

Type: string

Url to be opened when a user clicks on the label

.addCardIcon(iconUrl)

Add icon to card.

iconUrl

Type: string

The url where the icon is.

.addCardIconDetails(iconUrl, icon2xUrl)

Add icon to card.

iconUrl

Type: string

The url where the icon is.

icon2xUrl

Type: string

The url for the icon in retina.

.setRequestDefaults(defaults)

Sets the default options applied to all future requests.

defaults

Type: object

Default request options, see the popular request library for options.

.clearRequestDefaults()

Clears any previously set default options.

.send()

POST a message to the HangoutsChat room API

Returns a Promise. If it succeeds, a string will be returned with a value of successfully posted to hangouts-chat. If it fails, an array of errors is returned.

Examples

Basic Message

const hangoutsChatNotification = new HangoutsChatNotification('https://www.example.com', '1', 'abcd1234');

hangoutsChatNotification.setFrom('From');
hangoutsChatNotification.setColor('green');
hangoutsChatNotification.shouldNotify();
hangoutsChatNotification.setMessage('My message.');

hangoutsChatNotification.send()
  .then((result) => {

  }).catch((error) => {

  });

Simple Card

const notification = new HangoutsChatNotification('https://www.example.com', '1', 'abcd1234');

notification.setFrom('From');
notification.setColor('green');
notification.shouldNotify();
notification.setMessage('My message.');
notification.addCard('1', 'file', 'Title');

notification.send()
  .then((result) => {

  }).catch((error) => {

  });

Complex Card

const notification = new HangoutsChatNotification('https://www.example.com', '1', 'abcd1234');

notification.setFrom('From');
notification.setColor('green');
notification.shouldNotify();
notification.setMessage('My message.');
notification.addCard('1', 'file', 'Title');
notification.addCardAttribute('Size', '128kb', 'lozenge-success');
notification.addCardAttribute('Date', '12/27/2017', 'lozenge-success');

notification.send()
  .then((result) => {

  }).catch((error) => {

  });

Contributing

Please see CONTRIBUTING.md.

Release History

Please see CHANGELOG.md.

License

Copyright (c) 2018 Michael Peterson. Licensed under the MIT license.