Skip to content

FurhatRobotics/FurhatJSCore

Repository files navigation

FurhatJSCore

Client library for connecting to and operating FurhatOS (read more at: www.furhatrobotics.com)

Usage

Install using:

npm install furhat-core

Import (ES6 import syntax) using:

import Furhat from 'furhat-core'

Initialize the connection:

let furhat = new Furhat('localhost', 80, 'api')

furhat.init()
  .then(({error, message}) => {
    if(error) {
      console.log('Something went wrong:', message)
      return
    }
    
    furhat.say('I am connected!')
  })
  .catch(({error, message}) => console.log('Something went wrong:', message))
  
// or you can use the async/await syntax
try {
  const {error, message} = await furhat.init()
  if(error) {
    console.log('Something went wrong:', message)
    return
  }
  
  furhat.say('I am connected!')
} catch({error, message}) {
  console.log('Something went wrong:', message)
}

API

Table of Contents

Furhat

Furhat main class. Maintains the websocket connection to furhatOS and has methods to send events, subscribe to events and helper methods such as say, gesture, etc.

Parameters

  • domain IP Address for furhatOS - localhost if SDK.
  • port port for RealTimeAPI module of furhatOS.
  • route route for RealTimeAPI module of furhatOS.

init

Initializes the connection and return a promise. Await for the promise to resolve before using the object

send

Sends an event to furhatOS

Parameters

  • event Object containing the event. Mandtory to have event_name parameter in the object

subscribe

Subscribes to the given event and triggers the supplied callback on event

Parameters

  • eventName Name of the event to subscribe
  • callback Function which needs to be triggered when the given event is recieved
  • dontSend [Optional][false by default] Boolean which determines wether to send the subscribe event or not. use it to set callbacks for event that are already subscribed to, for instance with group subscriptions

subscribeGroup

Subscribes to the given event group

Parameters

  • groupNumber Number(Assigned ENUM) of the group that needs to be subscribed to

say

Says a given text

Parameters

  • text Text which needs to be said by Furhat

userSpeech

Stimulates the speech of a user in the interaction space

Parameters

  • text Text which needs to be said by the user

userSpeechStart

Stimulates SenseSpeechStart event. Can be used to stimulate user speech via typing

gesture

Performs the given gesture

Parameters

  • name Name of the gesture that needs to be performed

About

Client library for connecting to and operating FurhatOS (read more at: www.furhatrobotics.com)

Resources

License

Stars

Watchers

Forks

Packages

No packages published