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

@relaypro/sdk

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@relaypro/sdk

Workflow SDK Relay on Node.js

  • 1.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

@relaypro/sdk / Exports

relay-js

relay-js SDK is a node.js library for interacting with Relay. For full documentation visit api-docs.relaypro.com

Installation

npm install @relaypro/sdk

Usage

The following code snippet demonstrates a very simple "Hello World" workflow. However, it does show some of the power that is available through the Relay SDK.

import { relay, Event } from '@relaypro/sdk'

const app = relay()

app.workflow(`helloworld`, workflow => {
  workflow.on(Event.START, async () => {
    const greeting = await relay.get(`greeting`)
    const name = await relay.getDeviceName()
    await relay.say(`What is your name ?`)
    const user = await relay.listen()
    await relay.say(`Hello ${user}! ${greeting} ${name}`)
    await relay.terminate()
  })
})

Features demonstrated here:

  • When the workflow is triggered, the start event is emitted and the registered start callback function is called.
  • A configuration variable greeting is retrieved as is the triggering device's name.
  • The workflow then uses text-to-speech to prompt the user for their name.
  • The workflow awaits for a response from the device user.
  • The workflow then again uses text-to-speech to reply with a dynamic message.
  • Finally, the workflow is terminated and the device is returned to its original state.

In this sample, a workflow callback function is registered with the name helloworld. This value of helloworld is used to map a WebSocket connection at the path ws://yourhost:port/helloworld to the registered workflow callback function.

It is also possible to register a "default" workflow at path / by providing the workflow callback function as the first parameter:

app.workflow(wf => {
  wf.on(Event.START, async () => {
    // handle start event
  })
})

API

The Relay JS SDK covers a broad set of use cases. Explore the various actions that can be performed in workflow event callbacks:

Workflow Registration

More thorough documentation on how toregister your workflow on a Relay device can be found at https://api-docs.relaypro.com/docs/register-workflows

In order to configure

Development

git clone git@github.com:relaypro/relay-js.git
cd relay-js
npm install
npm run build
npm run test

License

MIT

Keywords

FAQs

Package last updated on 18 Aug 2021

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