Sentius

Quick Start for AI Agents

Integrating Sentius Copilot+ with Browser Agent API

Quick Start Guide for Sentius Copilot+ and Browser Agent

This guide will walk you through the steps to quickly integrate the Sentius Copilot+ Browser Agent API into your application. After completing this tutorial, you'll be able to control a web browser to perform tasks on a specific web page using the Browser Agent API.

Prerequisites

Before starting, ensure you have the following:

  1. Sentius Copilot+ Installed
    Download and install the Sentius Copilot+ application. The app interacts with a Chromium-based browser and must be installed on the machine where the tasks will be executed.

  2. Join the Waitlist
    Sign up for the Sentius Teach & Repeat Platform in the developer role by clicking Join Waitlist when running the Sentius Copilot+ Application.

  3. API Key
    Obtain an API Key from your Sentius Copilot+ application by navigating to Settings API.

Step 1: Start a Dialog Session

A dialog session represents a conversation with the Browser Agent. You must create or retrieve a dialog session before sending tasks.

Create a New Dialog Session

If no session exists, create a new one by using the POST request:

curl -X POST "https://api.sentius.ai/dialog_sessions?api_key=<your_api_key>" \
     -H "Content-Type: application/json"
import requests

url = "https://api.sentius.ai/dialog_sessions"
params = {"api_key": "<your_api_key>"}
response = requests.post(url, params=params)
print(response.json())

After creating or retrieving a session, you'll receive a <dialog_session_id>, which you’ll use for future interactions.

Retrieve an Active Dialog Session

To retrieve an existing session, use the following GET request:

curl -X GET "https://api.sentius.ai/dialog_sessions?api_key=<your_api_key>" \
     -H "Content-Type: application/json"
import requests

url = "https://api.sentius.ai/dialog_sessions"
params = {"api_key": "<your_api_key>"}
response = requests.get(url, params=params)
print(response.json())

Step 2: Send a Task to the Browser Agent

With an active dialog session, you can now send a task for the Browser Agent to perform. Here's an example of sending a task to open a web page and perform an action.

Send a Task to Open a Web Page

Use the following POST request to send a message with the task. You can specify the task in the text field and (optional) choose an instruction for handling the task in the <instruction_id> field.

curl -X POST "https://api.sentius.ai/dialog_sessions/<dialog_session_id>/chat?api_key=<your_api_key>" \
     -H "Content-Type: application/json" \
     -d '{
       "text": "Open https://example.com and click on the sign-up button",
       "instruction_id": "AeOfd32"
     }'
import requests

url = f"https://api.sentius.ai/dialog_sessions/<dialog_session_id>/chat"
params = {"api_key": "<your_api_key>"}
data = {
    "text": "Open https://example.com and click on the sign-up button",
    "instruction_id": "AeOfd32"  # Optional, specify an instruction if needed
}
response = requests.post(url, json=data, params=params)
print(response.json())

In this example, the task is to open a specific web page (https://example.com) and click a button. The <instruction_id> is optional, but if specified, the agent will use a pre-recorded instruction to complete the task.

Step 3: Monitor the Task Progress and Retrieve Session History

You can retrieve the dialog session history to check how the agent performed the task.

Retrieve Session History

To fetch the history of a particular dialog session:

curl -X GET "https://api.sentius.ai/dialog_sessions/<dialog_session_id>/history?api_key=<your_api_key>" \
     -H "Content-Type: application/json"
import requests

url = f"https://api.sentius.ai/dialog_sessions/<dialog_session_id>/history"
params = {"api_key": "<your_api_key>"}
response = requests.get(url, params=params)
print(response.json())

Step 4: Customize the Task with Instructions (Optional)

You can also record custom instructions in the Sentius Copilot+ application to handle specific tasks in a predefined manner.

Record and Use Instructions

To record an instruction:

  1. Open the Sentius Copilot+ app and go to the "Library" tab.
  2. Click on the "Record" button to start recording a custom instruction.

After recording, you can obtain the Instruction ID and use it in your API calls by specifying it in the <instruction_id> field.

Using a Particular Instruction in the Task

Here's how to specify a particular instruction in your API request:

import requests

url = f"https://api.sentius.ai/dialog_sessions/<dialog_session_id>/chat"
params = {"api_key": "<your_api_key>"}
data = {
    "text": "Open https://example.com and perform the custom task",
    "instruction_id": "<Instruction_id>"  # Replace with your custom instruction ID
}
response = requests.post(url, json=data, params=params)
print(response.json())

Conclusion

You have now set up your Browser Agent to perform tasks on a web page. By integrating with the Sentius Copilot+ platform, you can extend this functionality to automate complex workflows, manage sessions, and reuse instructions for repetitive tasks.

For additional details, check out the full documentation on Dialog Sessions and Instructions.