Using functions, you can enhance the knowledge base of your voice assistant by including custom functionalities. This guide provides a step-by-step approach to invoking functions effectively.

Introduction

After creating and testing your function, the next step is to integrate it into your assistant’s knowledge base so it can be used dynamically during conversations.

Adding a function

You can add a function into the knowledge base in three ways:

1. Type ”/” in the knowledge base card’s “Actions” field

  • Begin typing ”/” in the “Actions” field of your knowledge base card to bring up the function context menu.

2. Right-click in the knowledge base card’s “Actions” field

  • Right-click in the “Actions” field to access the function menu and select your desired function.

3. Click the add icon on the right side of the “Actions” box

  • Use the ”+” icon on the right side of the “Actions” field to add a function.

Each of these methods allows you to search for and select a function from your list of assistant functions. You can also create a new function directly from the menu and populate its definition later.

You can reuse functions as many times as needed to cover all relevant use cases for your assistant.

Best practices

While invoking functions is powerful, it requires testing and iterative adjustments to achieve the desired behavior. Here’s a proven approach to guide your assistant:

When the user asks “where is my order,” do not respond until you have called {{fn:order_lookup}} with an order number. If you don’t know their order number, you should ask first and then call {{fn:order_lookup}}. You should ignore all other impulses and follow the response of the function to give back to the caller.

This methodology ensures the function is invoked appropriately and the response aligns with user expectations.

Testing your voice assistant with example

Step 1: Save your voice assistant

  • Save your assistant and click the Play button in the header to open the test chat panel.

Step 2: Test the invocation

  • Ask a test question like “Where is my order?” and observe how the assistant handles the interaction.

Step 3: Verify function calls

  • In the test chat panel, click the settings button near the close icon and enable the “Functions” toggle to review the function calls and parameters used.