Conversational Plugins
A Plugin enables the connection of a Digital Human to an external API or service. For instance, a plugin can facilitate integration with a conversational AI solution, utilize a specific LLM, access knowledge bases, or conduct internet searches.
A plugin communicates with the Unith Digital Humans Backend system to provide responses to user messages.
Plugin webhook
Unith plugins communicate with the backend following a webhook communication pattern.
The plugin should implement a specific POST endpoint /conversation/{userid}/message. The Unith backend will send events to this endpoint for each user message. The body of the POST request follows this format:
{
[
{
"type": "text",
"payload": {"type": "message", "message": "Hello World!"}
}
]
} The plugin should respond to the POST request with an equivalent json format:
{
[
{
"type": "text",
"payload": {
"type": "text",
"message": "this is the response from plugin"
}
}
]
} Note that the POST body and the response are formatted as a List. The aim of this List is to support several parts for each message, potentially of different type, like "images" or other types of data or metadata. At the moment the API only supports text.
Options
The plugin events can include optional parameters in the payload. These parameters can be used to provide extra metadata needed for the plugin. The options is a json object that is added to the payload
{
[
{
"type": "text",
"payload": {
"type": "text",
"message": "Hello World!"
"options": {
"example_param": "foo"
}
}
}
]
} UNITH also sends options and session_metadata. The metadata has the organisation id, the head id, the session id and the username.
How to register a plugin with a Digital Human
A plugin can be registered with a Digital Human using the operationMode="plugin" through the API. In the Digital Human creation process, use the following parameters in the POST /head/create endpoint.
{
...
"operationMode": "plugin",
"pluginOperationalModeConfig": {
"name": "<plugin name>",
"url": "<plugin url>",
"options": {
"<optional param>": "option value"
...
}
}
...
} The parameter pluginOperationalModeConfig.url should be the full base path of the url preceding /conversation/{userid}/message. For instance, if the the plugin endpoint path is
https://myservice.example.com/api/conversation/{userid}/message
you have to set the url field as
"pluginOperationalModeConfig": {
"name": "example",
"url": "https://myservice.example.com/api"
}Do not end the URL with a slash. UNITH adds /conversation/{user_id}/message to the URL as it is. A trailing slash gives // in the path, and your plugin answers 404.
UNITH does not send an Authorization header to your plugin, so the plugin endpoint must be public.
UNITH makes one attempt only. The connect timeout is 10 seconds and the read timeout is 75 seconds.
If the call fails, the digital human says: "I'm sorry, I'm having trouble answering right now."
Please see How to create a custom pluginHow to create a custom plugin, where we provide a step by step tutorial that explains how to create a custom plugin using python.