Featured

Tools & Actions

Tools and Actions is currently in Beta. Expect breaking changes and improvements.

What are tools and actions?

Tools & Actions enhance the AI's functionality by enabling it to access data from various tool integrations and perform actions. An agent router decides whether to use a tool based on criteria, executes the tool's API request, and checks if the query is complete or if additional tools are needed.

How to activate tools and actions?

Tools & Actions are inactive by default. To activate them, go to the Tools & Actions tab in the dashboard and click the 'Enable Tools' button. You can also enable/disable individual tools by clicking the toggle next to the tool name after enabling tools.

Tools & Actions Tab

Choose from Template or create your own

You can choose from a list of templates or create your own tool. The templates are pre-configured with the most common tools and actions. You can also create your own tool by clicking the 'Add Custom' button.

Templates

Choosing a Template

When you choose a template, you will be prompted to enter the required information for the tool.

AI Input

The 'AI Input' tells the AI that it needs to fill that input at request time. This means that it will try to automatically fill the input with the correct data. For example, if you choose a 'Get User' template, the AI will try to fill the input with the user's email address that the user would have provided in the chat.

To have the AI fill the input value at request time, use <ai-generated-value> as the input value or press the 'AI Input' button. This is valid for query, header and body fields.

Template

Creating a Custom Tool

You can also create custom tools. The most important part of a custom tool is the API request. The API request is what the AI will execute when it needs to use the tool. The API request can be of any type and also take advantage of the AI Input feature.

Make sure to wrap the AI Input with <ai-generated-value> in quotes if using in the body, header or query parms.

Mendable provides an API request builder to help you build your API request.

Currently, only users in paid plans can create custom tools.

API Request

Tool criteria

The second most important aspect of a tool is the criteria. The criteria is the tool description and what the AI uses to decide whether to use the tool or not. The criteria should be a complete description of the tool and what it does.

If you are facing issues with the AI not using the tool, you can check the criteria to see if it is accurate and detailed.

Example:

  • Tool Name: Recent News

    Here is what a good criteria would look like:

    Use this tool to get the most recent news about any topic. The tool will return the most recent news article about the topic provided.

Using the tool

After you created the tool and is enabled, the AI use it when it needs to. It works with all the components and the API.

Here is an example of using a tool to achieve a task:

Tool Example

In the example above, the AI used the "Web Search Tool" to find what the latest funding round for "Conta Simples" was.

Tool Chaining

The AI uses tools in an agentic flow. This means that the AI will use as many tools as it needs to complete the task. That also mean that it can take advantage of tool chaining which is when the output of one tool is used as the input of another tool.

Here is an example where after doing the research, the AI uses the Slack tool to send the results to the channel:

Tool Chaining

Using via API

You can use tools and actions normally via the API, but you can't create tools via the API yet.

If you use /mendableChat with streaming disabled, you will receive an addional payload on your response showing the tools used.

Learn more about it over in the API Reference.

{
     // ...
    "tools_used": [
        {
        "id": "eb2b1c99-8e9b-4697-82ca-6151a7f3c0b5",
        "internal_run_id": "9263987",
        "tool_name": "Web Search",
        "has_error": false,
        "date": "2024-01-11T22:07:05.932Z"
        }
    ],
}

If you use straming, you will get the following chunks:

  • Chunk <|loading_tools|> only shows if "Tools and Actions" is enabled. That chunk will contain "true" if AI is looking for tools to take action on the user's request.

  • Chunk <|tool_called|> only shows if "Tools and Actions" is enabled. That chunk will contain an object with the name of the tool that was called {name: tool_name}.

  • Chunk <|tool_output|> only shows if "Tools and Actions" is enabled. That chunk will contain an object with the tool output that was used.

  • Chunk <|tool_error|> only shows if "Tools and Actions" is enabled. That chunk will contain a string with the error message.

Learn more about it over in the API Reference.

Previous
Showcase