Get First Message
curl --request GET \
--url https://api.eigi.ai/v1/public/agents/{agent_id}/first-message \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.eigi.ai/v1/public/agents/{agent_id}/first-message"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.eigi.ai/v1/public/agents/{agent_id}/first-message', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.eigi.ai/v1/public/agents/{agent_id}/first-message",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.eigi.ai/v1/public/agents/{agent_id}/first-message"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.eigi.ai/v1/public/agents/{agent_id}/first-message")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.eigi.ai/v1/public/agents/{agent_id}/first-message")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"session_id": "<string>",
"first_message": "<string>",
"agent_id": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}Chat
Get First Message
Retrieve the agent’s greeting message to initialize a chat session
GET
/
v1
/
public
/
agents
/
{agent_id}
/
first-message
Get First Message
curl --request GET \
--url https://api.eigi.ai/v1/public/agents/{agent_id}/first-message \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.eigi.ai/v1/public/agents/{agent_id}/first-message"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.eigi.ai/v1/public/agents/{agent_id}/first-message', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.eigi.ai/v1/public/agents/{agent_id}/first-message",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.eigi.ai/v1/public/agents/{agent_id}/first-message"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.eigi.ai/v1/public/agents/{agent_id}/first-message")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.eigi.ai/v1/public/agents/{agent_id}/first-message")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"session_id": "<string>",
"first_message": "<string>",
"agent_id": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}Overview
This endpoint retrieves the agent’s first/greeting message that should be displayed when starting a new chat. Use this to initialize your chat UI before the user sends their first message, providing a welcoming experience.Authentication
string
required
Your eigi.ai API key. Must be prefixed with
vk_.Path Parameters
string
required
The unique identifier of the agent. Example:
68ea2517dbb84c09bae1ba0aResponse
string
A new session ID created for this chat. Use this for subsequent messages.
string
The agent’s greeting/welcome message configured in the agent settings.
string
The agent ID (same as the request parameter).
Examples
Get Agent’s First Message
curl -X GET "https://api.eigi.ai/v1/public/agents/68ea2517dbb84c09bae1ba0a/first-message" \
-H "X-API-Key: vk_your_api_key_here"
import requests
agent_id = "68ea2517dbb84c09bae1ba0a"
response = requests.get(
f"https://api.eigi.ai/v1/public/agents/{agent_id}/first-message",
headers={"X-API-Key": "vk_your_api_key_here"}
)
data = response.json()
print(f"Agent says: {data['first_message']}")
print(f"Session ID: {data['session_id']}")
const agentId = "68ea2517dbb84c09bae1ba0a";
const response = await fetch(
`https://api.eigi.ai/v1/public/agents/${agentId}/first-message`,
{
headers: {
"X-API-Key": "vk_your_api_key_here",
},
}
);
const data = await response.json();
console.log(`Agent says: ${data.first_message}`);
console.log(`Session ID: ${data.session_id}`);
Response Example
{
"session_id": "58a6b549-ef07-4a31-86bc-0eb0e026840a",
"first_message": "Hello! Welcome to Acme Corp support. I'm your AI assistant, ready to help with any questions about our products, services, or your account. How can I assist you today?",
"agent_id": "68ea2517dbb84c09bae1ba0a"
}
Typical Workflow
Here’s how to properly initialize a chat conversation:1
Get First Message
Call this endpoint when a user opens your chat interface.
2
Display Greeting
Show the
first_message to the user in your chat UI.3
Store Session ID
Save the
session_id for use in subsequent messages.4
Continue Chat
When the user sends a message, use the stored
session_id with the chat
endpoint.Complete Chat Flow Example
JavaScript
class ChatClient {
constructor(apiKey, agentId) {
this.apiKey = apiKey;
this.agentId = agentId;
this.sessionId = null;
this.messages = [];
}
async initialize() {
// Step 1: Get the agent's greeting
const response = await fetch(
`https://api.eigi.ai/v1/public/agents/${this.agentId}/first-message`,
{
headers: { "X-API-Key": this.apiKey },
}
);
const data = await response.json();
// Step 2: Store session and display greeting
this.sessionId = data.session_id;
this.messages.push({
role: "assistant",
content: data.first_message,
});
return data.first_message;
}
async sendMessage(userMessage) {
// Step 3: Send user message with session ID
this.messages.push({ role: "user", content: userMessage });
const response = await fetch("https://api.eigi.ai/v1/public/chat", {
method: "POST",
headers: {
"X-API-Key": this.apiKey,
"Content-Type": "application/json",
},
body: JSON.stringify({
agent_id: this.agentId,
session_id: this.sessionId,
message: userMessage,
streaming: false,
}),
});
const data = await response.json();
this.messages.push({
role: "assistant",
content: data.response,
});
return data.response;
}
}
// Usage
const chat = new ChatClient("vk_your_api_key", "68ea2517dbb84c09bae1ba0a");
const greeting = await chat.initialize();
console.log("Bot:", greeting);
const reply = await chat.sendMessage("I need help with my order");
console.log("Bot:", reply);
Error Responses
| Status Code | Description |
|---|---|
| 401 Unauthorized | Missing, invalid, inactive, or expired API key |
| 403 Forbidden | API key owner doesn’t have access to this agent |
| 404 Not Found | Agent not found with the given ID |
Example Error Response
{
"detail": "Agent not found"
}
Best Practices
Always Initialize First: Call this endpoint before displaying your chat UI
to ensure a proper greeting and valid session.
Cache When Appropriate: If you’re opening multiple chats to the same
agent, you can cache the first message content (but not the session ID).
Handle Errors Gracefully: Have a fallback greeting message in case this
endpoint fails.
Authorizations
API key for authentication. Get your API key from the eigi.ai Dashboard under Settings → API Keys.
Path Parameters
The unique agent ID

