@atomist/automation-client
Atomist automation client for running command and event handlers
Last updated a year ago by atomist .
SEE LICENSE IN LICENSE · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @atomist/automation-client 
SYNC missed versions from official npm registry.

@atomist/automation-client

atomist sdm goals npm version

Node module @atomist/automation-client for creating Atomist development automations. Development automations take the following forms:

  • Bot commands - create bot commands using command handlers
  • Respond to events - use event handlers to automatically take action when events, like someone commenting on an issue, happen
  • Ingestors - define your own, custom events that you can then take action on

The automation-client provide the ability to run a client that connects to the Atomist API so it can receive and act on commands and events.

See atomist.com and docs.atomist.com for more detailed information.

Concepts

Atomist is a service and API that enables development automation. The Atomist service builds and maintains a model of the things that matter to your development team. You can then use out of the box automations or build your own automations acting on this model.

For more information, please read Concepts.

Getting Started

Please install Node.js. To verify that the right versions are installed, please run:

$ node -v
v8.4.0
$ npm -v
5.4.1

Using the automation-client module from your project

To start using this module in your Node.js application, you have to add a dependency to it to your package.json by running the following command:

$ npm install @atomist/automation-client --save

You can find reference documentation at https://atomist.github.io/automation-client-ts/ .

Starting from a Sample

We also provide a working project with some basic automations that you can use to get started quickly. The repository is at atomist/automation-seed-ts.

To get started run the following commands:

$ git clone git@github.com:atomist/automation-seed-ts.git
$ cd automation-seed-ts
$ npm install

See the automation-seed-ts README for further instructions.

Implementing Automations

Command Handlers

Commands are automations that can be invoked via a Chat bot, curl or web interface.

To create a command take a look at the following example:

import { CommandHandler, Parameter} from "@atomist/automation-client/decorators";
import { HandleCommand, HandlerContext, HandlerResult } from "@atomist/automation-client/Handlers";

@CommandHandler("Sends a hello back to the client", "hello world")
//                                                   ^ -- defines the command to trigger
//                      "                                 this handler from the bot
export class HelloWorld implements HandleCommand {
//                                 ^ -- a command handler implements the HandleCommand
//                                      interface

    @Parameter({ pattern: /^.*$/, required: true })
//  ^            ^                ^ -- parameters can be marked required or optional
//  ^            ^ -- the parameter can be validated against a RegExp pattern
//  ^ -- this defines a user-provided parameter named 'name'
    public name: string;


    public handle(ctx: HandlerContext): Promise<HandlerResult> {
//  ^             ^ -- HandlerContext provides access to a 'MessageClient' for sending
//  ^                  messages to the bot as well as a 'GraphClient' to query your
//  ^                  data using GraphQL
//  ^ -- this method is the body of the handler and where the actual code goes
        return ctx.messageClient.respond(`Hello ${this.name}`)
//                               ^ -- Calling 'respond' on the 'MessageClient' will
//                                    send a message back to