btnexus-node-python.btHook module

Blackout Nexus hook. Base class for all hooks

class btHook.Hook(connectHash=None, **kwargs)[source]

Bases: btNode.Node

Blackout Nexus hook. Base class for all hooks

Constructor for the hook. extracting all important infos from the connectHash (either given as parameter, via environment variable CONNECT_HASH or in the .btnexusrc(prioritized in this order))

cleanUp()[source]

Unregister the hook and send exit state

load(key, callback=None)[source]

load a value to a specific key in the NexusData Api

Parameters
  • key (String) – the key to which the value should be saved

  • callback (function pointer) – callback to handle the api response

onConnected()[source]

Setup all Callbacks

onInit(**kwargs)[source]

Initilize what you need before the hook connected - you can pass kwargs in the constructor to use them here

onMessage(originalTxt, intent, language, entities, slots, branchName, peer)[source]

Overload for your custum hook! - it needs to trigger say

React on a message forwarded to the hook.

Parameters
  • originalTxt (String) – the original text

  • intent (String) – the classified intent

  • language (String) – the (classified) language

  • entities (List of (String)) – List of used entities

  • slots (List of (String)) – List of used slots

  • branchName (String) – Name of the Branch

  • peer (dict) – param to indentify message origin

onReady(**kwargs)[source]

Initilize what you need after the hook connected - you can pass kwargs in the constructor to use them here

put(key, value, callback=None)[source]

add a value to a specific key in the NexusData Api - the value must be a list otherwise it will be overwritten

Parameters
  • key (String) – the key to which the value should be saved

  • value (Object) – the object which should be saved

  • callback (function pointer) – callback to handle the api response

save(key, value, callback=None)[source]

save a value to a specific key in the NexusData Api

Parameters
  • key (String) – the key to which the value should be saved

  • value (Object) – the object which should be saved

  • callback (function pointer) – callback to handle the api response

say(peer, message)[source]

publishes the hooks response.

Parameters
  • message (dict) – the message dict with at least the field ‘answer’

  • peer (Object) – the peer object handed from onMessage

setUp()[source]

Register the hook in the system

state()[source]

publish the state of the hook