Make AI Agents
AI agent context overview

Manage shop inventory with an AI agent

8min

In the following use case, we will build an agent that helps us manage the stock inventory of a small shop. We will use Slack to submit tasks for the agent and receive responses about their completion. The agent will use and other information we provide to him to list our stock information and order new items.

In this use case, we will:

  1. Set up the AI agent.
  2. Create AI agent's tools:
    1.  to list shop inventory.
    2.  to order more stock.
  3. Create the to send tasks to the AI agent.

Prerequisites:

  • API key of the AI service provider. Check the documentation of your AI service provider to find out how to get it.

Set up the AI agent

First, we need to create the AI agent and connect it to the AI service provider. We can use the Agent settings tab to do that.

1

Go to the AI Agents tab and click the Create agent button.

Alternatively, you can create a new AI agent through the Run an agent module. In the Run an agent module settings, click the Create agent button.

2

In the Connection, select your AI service provider connection.

  1. If you don't have a connection to a AI service provider, click Add. Create a connection pop-up appears.
  2. In the Connection type drop-down, select your AI service provider.
  3. Fill in the rest of the form according to the documentation for creating a connection to the AI service provider. Check the list of AI service providers.
  4. Click Save to finish creating the connection.
3

In the Agent name field, specify the name for the agent.

4

In the Model field, select the AI service model that the agent should use for reasoning.

5

In the Agent description field, define the agent's purpose and constraints. For our shop inventory agent, fill in: "You are a stock inventory bot."

We recommend providing a short agent description for the agent and leverage the Additional agent instructions to customize the agent for a specific .

6

Click Save to confirm the agent settings.

You have created an AI agent for managing your stock inventory. However, your agent doesn't have any means to do its job. In the next section, we create that work as tools for the AI agent.

Create AI agent's tools

Each AI agent in needs tools to be able to do it's job. Agent's tools are . AI agent uses information provided by you to reason about it's tools and when it should use them. sends the following Information to the AI service provider to form the AI agent's context:

  • AI agent's description
  • the name and description of each agent's tool
  • the name and description of inputs or outputs of the tools

In addition to providing the context about the scenarios to the AI agent, each used by the agent have be scheduled to run on demand or immediately and has to be active.

In the next sections, we will create a tool for our agent to list our shop inventory and another tool to order more stock if we're low.

The following sections are a showcase of the AI agent's reasoning. The we provide to the AI agent are simplified to make their setup more streamlined.

Scenario to list shop inventory

We will provide our agent with a to list our shop inventory. Since we want to send data from the to the agent, we have to use outputs and the Scenarios > Return output module.

To create the :

1

Click the Create a new scenario button in your organization dashboard or in the list of .

2

If you don't have testing data ready, set up your shop data.

  1. Add the Data store > Search record module to your .
  2. In the Data store field, select Add to create a new data store.
  3. In the Data store name field, fill in the name for your inventory data storage.
  4. In the Data structure box, click Add to define a structure for your data store.
  5. 
    Document image
    
  6. Click Save to confirm the data structure and Save to create the data store.
  7. Go to the list of data store and open the new data store.
  8. Click the Add button to add data to your data store:
Document image

3

Update the name of the . The AI agent uses the name to decide if it should run the . Fill in: "List shop inventory".

4

Add the Tools > Text aggregator module

  1. In the Source module field, keep the data store module.
  2. Enable the Show advanced settings toggle at the bottom of the module settings.
  3. In the Row separator field, select New row.
  4. In the Text field, map the name and quantity fields from your data store:
Document image

5

Add the Scenarios > Return output module.

  1. Click Add scenario outputs to set outputs for the return data module.
  2. In the Scenario outputs tab, define the output structure and fill in the description of each item in the output:
  3. 
    Document image
    
  4. In the module settings, map the text variable to the inventory field.
  5. Confirm module settings with Save.
6

Set scheduling:

  1. Set the scheduling to On demand. The agent will run the for you when needed.
  2. Confirm the scheduling with Save.
  3. Activate the .
  4. Save your .
7

Add description for the agent:

  1. Go to the Diagram tab.
  2. Click Options > Edit description.
  3. Add description to the . The AI agent uses the name and description to decide if it should run the scenario. Fill in: "Lists the shop inventory."
  4. Click Save.

You created the for your agent to list the shop inventory. We will make the available to your agent in the following sections.

Scenario to order more stock

We will provide the agent with another tool -- a to order more items for our shop inventory. The will receive order information from the agent with inputs.

For our testing purposes, the will just send messages to a selected chat.

To create the :

1

Click the Create a new scenario button in your organization dashboard or in the list of .

2

In Scenario inputs and outputs in the Scenario inputs tab, set the inputs structure and description:

Document image

Document image

3

Add the Slack > Create a message module.

4

Set up the Create a message module:

  1. In the Connection selection box, select your connection. If you don't have a connection, click the Add button to create it.
  2. Select the channel where you want to receive the messages about new orders created by the agent.
  3. In the module settings, use the scenario input in the Text field. For example:
Document image

5

Update the name of the . The AI agent uses the name to decide if it should run the . Fill in: "Create buy stock order."

6

Set scheduling:

  1. Set the scheduling to On demand. The agent will run the for you when needed.
  2. Confirm the scheduling with Save.
  3. Activate the .
  4. Save your .
7

Add description for the agent:

  1. Go to the Diagram tab.
  2. Click Options > Edit description.
  3. Add description to the . The AI agent uses the name and description to decide if it should run the . Fill in: "Creates orders to refill the shop inventory."
  4. Click Save.

You created the for your agent to create orders to refill the shop inventory. We will make the available to your agent in following sections.

Create the scenario to send tasks to the AI agent

In this final step of creating our use case we create the to communicate with our agent. We will equip the agent with as tools to perform the agent's tasks: list our shop inventory and order more items. We will use Slack to send tasks to our agent.

1

Click the Create a new scenario button in your organization dashboard or in the list of .

2

Add the Slack > Watch new events module to the .

3

Set up the module:

  1. In the Webhook field, select a Slack event webhook or click Add to create a new one.
  2. In the Event type drop-down, select New channel message.
  3. In the Connection field, select your Slack connection.
  4. In the Channel field, select a channel you can use for testing the AI agent.
  5. Set the scheduling to Immediately when data arrives.
  6. Click Save to confirm the module settings.
4

Click the module placeholder to add a new module to your . Search "ai agent" to get the Make AI agent > Run an agent module and add it to your .

5

In the Agent field, select the agent you created in the previous section.

6

In the Additional tools, click Add tool.

7

Add the to the AI agent's tools:

  1. Click the empty drop-down under Select scenario. The list of in your team rolls down. Select the "List shop inventory" we created in the previous section.

Use the search row at the top of the selection list to find the . Note the description that appears under the name of the and the name of the folder.

Document image

  1. Click OK to confirm the selection.
  2. Add the "Create buy stock order" created in the previous section in the same way.
  3. Click Save.
8

Finish setting up the Run an agent module:

  1. In the Thread ID field, map a unique identifier to keep the same thread for all communication with the agent. This optimizes the context sent to the agent with each module run and allows the agent to keep the history of previous conversations.
  2. In the Message 1 field, map the Text from the Watch new events module.
  3. Click Save to confirm changes.
9

Add the Ignore error handler to the Run an agent module. Sometimes, the agent can take time to respond.

If the response time gets longer than 180 seconds, the module outputs the ModuleTimeoutError and stops the .

There are more sophisticated options to prevent the ModuleTimeoutError, but they are not part of this use case. If you want to learn more, check the module settings reference.

10

Add the Slack > Create a message module after the Run an agent module.

11

Set up the module:

  1. In the Connection field, select your connection.
  2. In the Enter a channel ID or name and Channel type fields, select values relevant for the channel where you want to send agent's replies and pick the channel in the next field.
  3. In the Text field, map the response from the AI agent.
  4. Click Save to confirm changes.
12

Update the name of your .

13

Save the .

You should now test your agent. Send a message to the channel that is watched by the Watch new events module that contains the intent for the agent to either send the inventory information or order new stock. For example, request the agent to list the current shop inventory.

Check the channel where is the Create a message module sending agent's replies. You should see a reply from the agent listing the same data as we defined in the data store when we were setting up the available to the agent.