Ilana Docs
SDK

Querying

query()

Send a message to the runtime API and receive a governed response.

const result = await client.query(input: QueryInput): Promise<QueryResult>;

QueryInput

PropertyTypeRequiredDescription
botIdstringYesThe agent ID to query
inputstringYesThe user's message
conversationIdstringNoConversation ID for multi-turn chats

QueryOutput

A successful response contains:

PropertyTypeDescription
conversationIdstringConversation ID — pass this back for follow-up queries
responsestringThe AI-generated response
intentDetectedstring | undefinedThe intent classified by the runtime, if any
metadataResponseMetadataGovernance and enforcement metadata

ResponseMetadata

PropertyTypeDescription
capabilityAllowedbooleanWhether the intent was allowed by the Capability Profile
enforcementReasonEnforcementReason | undefinedWhy the request was restricted
schemaEnforcedbooleanWhether output schema enforcement was applied
schemaFallbackUsedbooleanWhether a fallback response was used due to schema failure
schemaValidationErrorstring | undefinedSchema validation error details

EnforcementReason

ValueMeaning
'DENY_LIST'Intent is on the Capability Profile deny list
'NOT_IN_ALLOW_LIST'Intent is not on the Capability Profile allow list
'no_intent_match'No intent could be classified from the input
'schema_fallback'Response didn't match the output schema; fallback used

Multi-turn Conversations

The conversationId returned in the first response should be passed back in subsequent queries to maintain conversation context:

// First message
const first = await client.query({
  botId: 'bot-123',
  input: 'What plans do you offer?',
});

if (!first.ok) return;

// Follow-up in the same conversation
const second = await client.query({
  botId: 'bot-123',
  input: 'What does the Growth plan include?',
  conversationId: first.data.conversationId,
});

Full Example

import { IlanaClient } from '@ilana/sdk';

const client = new IlanaClient({
  runtimeUrl: 'https://api.getilana.ai',
  token: 'your-embed-token',
});

const result = await client.query({
  botId: 'bot-123',
  input: 'How do I set up SSO?',
});

if (result.ok) {
  console.log('Response:', result.data.response);
  console.log('Intent:', result.data.intentDetected);
  console.log('Allowed:', result.data.metadata.capabilityAllowed);
} else {
  console.error(`[${result.error.code}] ${result.error.message}`);
}