API calls
Alhena AI provides an API that allows developers to engage with their application (knowledge base hosted on Alhena).
Getting the Access token
Reach out to team Alhena to get your access token
Terminology
A user query is the question a customer enters and the developer sends to Alhena AI. An Alhena AI Response is what Alhena AI returns after a user query is submitted.
A thread is all user queries from a specific user and all associated Alhena AI responses. All user queries and Alhena AI responses that belong to a thread will have the same unique thread_id associated to them.
For example, the user queries and Alhena AI responses below are all one thread:
user: Hello
Alhena AI: How can I help you?
user: What is Gleen AI?
Alhena AI: A customer success product
How does thread_id work?
Alhena AI api has an optional parameter thread_id. When a given user ask first question then developer needs to pass empty or simple don't pass thread_id. In this case alhena ai return the response and generate the thread_id
For the next follow up conversation, developers need to pass the thread_id. By passing thread_id, developers intent to convey that this is a follow up message rather a new conversation
Alhena AI will return the thread_id in every response. If it's a new conversation then new thread_id is returned. If it is a follow up conversation then Alhena AI return the same thread_id
Send Message
Using send message api
send_message api returns the generate response given the user's query
POST
https://api.alhena.ai/api/v1/send_message
send a query to alhena ai endpoint
Headers
ALHENA_API_KEY*
String
auth key for your gleen api
Request Body
query_text*
string
query text sent to gleen ai for the response generation
thread_id
string
thread_id for the follow up conversation
Making requests VIA CURL
You can paste the command below into your terminal to run your first API request. Make sure to replace $ALHENA_API_KEY
with your secret API key.
curl https://api.alhena.ai/api/v1/send_message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ALHENA_API_KEY" \
-d '{
"query_text": "Hi",
}'
You should get a response back that resembles the following:
{
"result_text":"Hello! How can I assist you today?",
"thread_id":"bb708939-b626-48eb-a403-2ea25bb38941"
}
Last updated