1.1.7 • Published 2 months ago

@dopt/blocks-javascript-node-client v1.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Dopt blocks JavaScript Node.js client

Overview

The Dopt blocks JavaScript client is a friendly server-side package for accessing the Dopt blocks API to access and updates block and flow state for a particular user in Dopt.

It is published to npm as @dopt/blocks-javascript-node-client.

Installation

Via npm:

npm install @dopt/blocks-javascript-node-client

Via Yarn:

yarn add @dopt/blocks-javascript-node-client

Via pnpm:

pnpm add @dopt/blocks-javascript-node-client

Configuration

To configure the blocks JavaScript client you will need

  1. A blocks API key (generated in Dopt)
  2. A block uid

Usage

Initialization

import { DoptApiClient } from '@dopt/blocks-javascript-node-client';

const client = new DoptApiClient({
  apiKey: process.env.DOPT_BLOCKS_API_KEY as string,
});

Blocks

Get block data using the getBlock method:

const block = await client.blocks.getBlock('model-block-1', {
  version: 3,
  userIdentifier: 'example-user-idenitifer',
});

Transition a block using the transition method:

await client.blocks.transition('model-block-1', {
  version: 3,
  userIdentifier: 'example-user-identifier',
  transitions: 'complete',
});

Flows

Get flow data using the getFlow method:

const flow = await client.flows.getFlow('example-flow-identifier', {
  version: 2,
  userIdentifier: 'example-user-identifier',
});

Transition a flow using the flowIntent method:

await client.flows.intent('example-flow-identifier', 'finish', {
  version: 3,
  userIdentifier: 'example-user-identifier',
});
1.1.7

2 months ago

1.1.6

2 months ago

1.1.5

3 months ago

1.1.4

7 months ago

1.1.3

7 months ago

1.1.2

8 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago