Skip to content

Adding global predefined custom sentences and answers

Florian Quirin edited this page Feb 18, 2020 · 4 revisions

Adding predefined sentences and answers via server files

In the previous section you've learned a bit about the Teach-UI and SDK and how to use them to add custom commands and services to SEPIA. If you use the 'assistant' user-account (default ID: uid1005) to upload SDK services or commands they will even be available to all your users which makes it possible to manage a custom set of global voice actions.
Maybe you've also noticed that custom answers can be given as 'reply' parameter in any command defined via the Teach-UI or inside services as demonstrated in several SDK examples. There is even a 3rd way using the SEPIA Control-HUB that works if you switch the answer-module from 'file' to 'elasticsearch'.
This section is about an additional way of creating custom commands and answers. If you check the folder sepia-assist-server\Xtensions\Assistant in your SEPIA-Home base folder you will see the folders 'answers' and 'commands'. These folders contain several text files that are loaded during server start-up. Let's take a closer look at both folders.

Answers

Quick start:

  • Add your own answers by creating files called 'answers_[code]_custom.txt'

Files in the 'answers' folder are typically called answers_de.txt or answers_en.txt where 'de' and 'en' are ISO-639-1 language codes. This means each supported language in SEPIA has its own file with predefined answers that can be used in services. Here are a few simple answer examples:

chat_hello_0a;; rep=0|mood=5;; Hello <user_name> ;;char=neutral
chat_hello_0a;; rep=1|mood=8;; Hello again! ;;char=neutral,polite
chat_hello_0a;; rep=2|mood=2;; Whatttt??? ;;char=rude
smart_home_0a;; rep=0|mood=5;; Switching on <1> in room <2> ;;char=rude

A rough explanation:

  • The fist part 'chat_hello_0a' is the answer tag that can be used inside a custom command or SEPIA service. You are free to choose any name. Answers with the same tag will be chosen randomly.
  • 2nd part is the repetition index (rep=1 means use this when the previous answer was from the same tag) and the mood index (mood=5 means neutral, 1 is worst and 10 is best).
  • 3rd part is the actual answer. The answer can contain certain 'variables' given in brackets and parameters like <1>, <2>, ... that can be defined by a service.
  • Finally there is a 'character' type given for each answer, simply to classify it for possible upcoming features.

Add your own answer file

You can edit the given files as needed, but if you update SEPIA you will need to restore your changes manually. The better way to add your own answers is to create a new file called answers_en_custom.txt (simply add '_custom' before the '.txt') and add them in the same format as seen above.

Predefined sentences for custom commands

Quick start:

  • Add your own sentences and commands by creating files called 'chats_[code]_custom.txt' or 'teachIt_[code]_custom.txt'

Files in the 'commands' folder are typically called chats_en.txt or teachIt_en.txt (en=English) and serve two slightly different purposes. 'Chats' files are meant to be used for small-talk sentences and 'teachIt' files for sentences that represent actual services. 'teachIt' sentences have to be matched almost exactly to trigger whereas the matching threshold for small-talk sentences is a bit lower but they are only checked if nothing else in SEPIA's NLU-chain fit before. Here are a few basic examples:

Hello;;		command=chat;;   reply=<chat_hello_0a>;;
What to buy?;;	command=lists;;  list_type=<shopping>;;  action=<show>;;  reply=Here is some stuff||Check this out!

A rough explanation:

  • Start with the sentence that you want SEPIA to understand. The format is the same as in the Teach-UI. There are NO wildcards allowed because they can easily mess with everything else =) (If you need this check the regular expressions in the SDK ^^).
  • Define the command that should be used as 2nd part.
  • Then add parameters like 'reply' to trigger a custom answer ( or free text, compare to answers above) or things needed for a specific service.

TIP: You can always use the "Assistant Testing" page inside the SEPIA Control HUB to test sentences and see what SEPIA currently understands. It is a good place as well if you want to find out parameter values for known commands ;-)

Add your own sentences

Create a new file called chats_en_custom.txt or teachIt_en_custom.txt (simply add '_custom' before the '.txt') and add sentences in the same format as seen above.