Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@relaypro/sdk
Advanced tools
relay-js SDK is a node.js library for interacting with Relay. For full documentation visit api-docs.relaypro.com
npm install @relaypro/sdk
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 pkg from '@relaypro/sdk'
const { relay, Event, createWorkflow, Uri } = pkg
const app = relay()
app.workflow(`helloworld`, helloworld)
const helloworld = createWorkflow(wf => {
wf.on(Event.START, async (event) => {
const { trigger: { args: { source_uri } } } = event
wf.startInteraction([source_uri], `hello world`)
})
wf.on(Event.INTERACTION_STARTED, async ({ source_uri }) => {
const deviceName = Uri.parseDeviceName(source_uri)
console.log(`interaction start ${source_uri}`)
await wf.sayAndWait(source_uri, `What is your name ?`)
const { text: userProvidedName } = await wf.listen(source_uri)
const greeting = await wf.getVar(`greeting`)
await wf.sayAndWait(source_uri, `${greeting} ${userProvidedName}! You are currently using ${deviceName}`)
await wf.terminate()
})
})
Features demonstrated here:
start
event is emitted and the registered start callback
function is called.sayAndWait
action. The device user will hear text-to-speech.listen
action.greeting
is retrieved as is the triggering device's name.Using the Relay CLI, the workflow can be registered with the following command:
relay workflow:create:phrase --name my-test-workflow --uri wss://yourhost:port/helloworld --trigger test -i 99000XXXXXXXXXX
In the above sample 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 wss://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
})
})
The Relay JS SDK covers a broad set of use cases. Explore the various actions that can be performed in workflow event callbacks:
More thorough documentation on how to register your workflow on a Relay device can be found at https://api-docs.relaypro.com/docs/register-workflows
git clone git@github.com:relaypro/relay-js.git
cd relay-js
npm install
npm run build
npm run test
FAQs
Workflow SDK Relay on Node.js
We found that @relaypro/sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.