Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dopt/blocks-javascript-client

Package Overview
Dependencies
Maintainers
5
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dopt/blocks-javascript-client

A JavaScript client for the Dopt Blocks API

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

Dopt blocks JavaScript 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-client.

Installation

Via npm:

npm install @dopt/blocks-javascript-client

Via Yarn:

yarn add @dopt/blocks-javascript-client

Via pnpm:

pnpm add @dopt/blocks-javascript-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-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',
});

FAQs

Package last updated on 08 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc