Skip to main content

Assistant Agent

It's a type of agent that allows you to interact with the user without having to deal with the complexity of the conversation flow. You just send the user's input to the agent, and it will return the response taking into account the context of the conversation.

Besides, it allows you to define a set of Skills to add specific capabilities to the agent.

Furthermore, you can add Input Parameters to alter the system definition.

Use cases

  • Customer Support Assistant: Given a customer inquiry, the agent will provide helpful responses.
  • Personal Finance Assistant: Given a user's financial data, the agent will provide budget analysis, spending recommendations, and reminders for bill payments.
  • Travel Booking Assistant: Given travel preferences and dates, the agent will search for flights, hotels, and rental cars.
  • Technical Support Assistant: Given a technical issue description, the agent will offer troubleshooting steps, solutions, and guide the user through the resolution process.
  • Health Monitoring Assistant: Given health data inputs, the agent will track vital signs, provide wellness tips, and remind the user to take medications or attend appointments.

Should I use this agent?

✅ You need to interact with the user without having to deal with the complexity of the conversation flow. The agent will handle the conversation context and provide responses based on the user's input.

⛔ You need to execute a single task in the background. In those cases, you may want to try Activity Agent.

⛔ You need to execute a complex task that may require multiple steps to be completed. In those cases, you may want to try Plan Agent.

Creating an Assistant Agent

To create an Assistant Agent, follow this guide.

Usage examples

Let's say you have a Customer Support Assistant Agent. You can interact with it as follows:

cURL

# Step 1: Generate the conversation and get the chatId
curl -X POST \
-L "https://api.serenitystar.ai/api/agent/customer-support/conversation" \
-H "Content-Type: application/json" \
-H "X-API-KEY: <YOUR_API_KEY>"

# Step 2: Execute the conversation using the chatId obtained from the first step
curl -X POST \
-L "https://api.serenitystar.ai/api/agent/customer-support/execute" \
-H "Content-Type: application/json" \
-H "X-API-KEY: <YOUR_API_KEY>" \
-d '[
{
"Key": "message",
"Value": "Hello, I need help with my order."
},
{
"Key": "chatId",
"Value": "<YOUR_CHAT_ID>"
}
]'

C#

using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

class Program
{
static async Task Main()
{
var client = new HttpClient();

// Step 1: Generate the conversation and get the chatId
var createConversationRequest = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("https://api.serenitystar.ai/api/agent/customer-support/conversation"),
Headers =
{
{ "X-API-KEY", "<YOUR_API_KEY>" },
{ "Content-Type", "application/json" },
}
};

var createConversationResponse = await client.SendAsync(createConversationRequest);
var conversationContent = await createConversationResponse.Content.ReadAsStringAsync();
var chatId = JObject.Parse(conversationContent)["chatId"].ToString();

// Step 2: Execute the conversation using the chatId obtained from the first step
var executionRequest = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("https://api.serenitystar.ai/api/agent/customer-support/execute"),
Headers =
{
{ "X-API-KEY", "<YOUR_API_KEY>" },
{ "Content-Type", "application/json" },
},
Content = new StringContent($@"[
{{
""Key"": ""message"",
""Value"": ""Hello""
}},
{{
""Key"": ""chatId"",
""Value"": ""{chatId}""
}}
]", Encoding.UTF8, "application/json"),
};

var executionResponse = await client.SendAsync(executionRequest);
var executionContent = await executionResponse.Content.ReadAsStringAsync();
Console.WriteLine(executionContent);
}
}

Python

import requests
import json

# Step 1: Generate the conversation and get the chatId
create_conversation_url = 'https://api.serenitystar.ai/api/agent/customer-support/conversation'
headers = {
'Content-Type': 'application/json',
'X-API-KEY': '<YOUR_API_KEY>'
}

create_conversation_response = requests.post(create_conversation_url, headers=headers)
conversation_content = create_conversation_response.json()
chatId = conversation_content.get('chatId')

# Step 2: Execute the conversation using the chatId obtained from the first step
execution_url = 'https://api.serenitystar.ai/api/agent/customer-support/execute'
payload = json.dumps([
{
"Key": "message",
"Value": "Hello"
},
{
"Key": "chatId",
"Value": chatId
}
])

execution_response = requests.post(execution_url, headers=headers, data=payload)
print(execution_response.text)