BYOB Workers

Type: BYOB Worker

A BYOB worker takes user input and sends it over the ServisBOT BaaS to an external application for processing. This means that any service that can accept or responde in natural language, and can be accessed over API calls, can be used as a bot inside ServisBOT. A BYOB worker can be created through the CLI or through the Add Resource button on a bot’s detail page.

BYOB fields

  • api: A ServisBOT API Connector alias that is called every time the worker received input
  • newConversationApi: [Optional] A ServisBOT API Connector alias that is called every time a user starts a new conversation with a bot
  • fallbackConfiguration: [Optional] An optional regex method for detecting when the remote bot service is not understanding the user. Usefull for bot APIs that do not return confidence scores.
  • confidence: You can use this as an override of the returned detected intent confidence. If this value is higher than that returned from the nlu provider it will change the response to be a fallback.
  • NluConfidenceThresholdOverride [Optional] You can use this as an override of the returned detected intent confidence. If this value is higher than that returned from the nlu provider it will change the response to be a fallback, this value defaults to 0.

Creating BYOB worker through cli

Save this json to a file and create a worker using the cli command sb-cli worker create file.json

{
  "Config": {},
  "Data": {
    "api": "some-baas-alias",                      
    "newConversationApi": "some-baas-alias",
    "nluConfidenceThresholdOverride": 0.8,                       
    "fallbackConfiguration": {                     
      "regexes": ["\\w+", "sorry can you repeat that"]
    }
  },
  "Description": "Sage maker worker",
  "Enabled": true,
  "Name": "MikesByobWorker",
  "Status": "published",
  "Type": "r2-byob-worker"
}

The BYOB worker will call an API connector with a message. The worker will expected at message back with an optional confidence score

Call to API Connector

{
    message: 'response from external api'
}

Response back from API Connector

{
    message: 'Client message / utternace',
    confidence: 80
}

Sample BAAS Api configuration

You will also need a BAAS Api configured below in order for the worker to successfully talk to an external API.

{
	"Alias": "ByobApi",
	"Endpoint": "https://some-url",
	"RequestMapping": {
		"Message": {
			"type": "requestBody",
			"inputPath": "$.message",
			"requestBodyPath": "$.message"
		}
	},
	"ResponseMapping": {
		"Message": {
			"type": "responseBody",
			"responseBodyPath": "$.message",
			"outputPath": "$.message"
		}
	},
	"Headers": {},
	"Method": "POST",
	"Body": {}
}

Once you have created the worker using the CLI, it will return an ID for you. You need to then update/create a bot and place the filter worker at the top with the id and the type of r2-byob-worker