Client library for connecting to a Furhat skill from a skill GUI
$ npm install --save furhat-gui
import FurhatGUI, { Furhat } from 'furhat-gui'
let furhat: Furhat = null
function setupSubscriptions () {
furhat.subscribe('com.myapp.MyCustomEvent', (event) => {
console.log('received event: ', event.event_name)
})
}
FurhatGUI()
.then(connection => {
furhat = connection
furhat.onConnectionError((_connection: WebSocket, ev: globalThis.Event) => {
console.error("Error occured while connecting to Furhat skill")
})
furhat.onConnectionClose(() => {
console.warn("Connection with Furhat skill has been closed")
})
setupSubscriptions()
})
.catch(console.error)
// Later somewhere in the code (after awaiting for the connection promise)
furhat.send({
event_name: 'MyEvent',
param1: 'MyParam1'
})
FurhatGUI Function which sets up a connection to the furhat skill and gives the furhat object to send and recieve events to the skill.
Returns any Promise that will return the promise with a Furhat
obkect