Skip to main content

Your first call

Two calls: list your personas, then ask one a question. You need the base URL and API key from Before you start.

export PERSONAAS_BASE_URL="https://alpha.personaas.ai" # your base URL
export PERSONAAS_API_KEY="p-…@org_…" # your key

1. List your personas​

curl "$PERSONAAS_BASE_URL/api/v1/personas/" \
-H "x-personaas-key: $PERSONAAS_API_KEY"

Keep the trailing slash. You get the personas assigned to you, each with its tasks:

[
{
"id": 12,
"name": "HR Assistant",
"tasks": [
{ "id": 40, "name": "Leave questions", "sensitive": false }
]
}
]

Note one persona id and one task id from your response. The numbers 12 and 40 below are only examples. Pick a task where sensitive is false; apps cannot run sensitive tasks yet.

An empty list [] is not an error. It means no persona is assigned to you yet; ask your Personaas administrator.

2. Ask a question​

Asking takes three calls, the same ones the Personaas app makes: create a conversation, open its stream, send the question. Put your persona id and task id in the first one. PERSONAAS_ENGINE comes from Before you start.

Create a conversation:

curl -X POST "$PERSONAAS_BASE_URL/api/v1/activity/" \
-H "x-personaas-key: $PERSONAAS_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "persona_id": 12, "task_id": 40 }'
# → { "activity_id": "0b6f6a0e-…", … }

export ACTIVITY_ID="0b6f6a0e-…" # the activity_id you got back

Open the stream and leave it running. The answer will appear here:

curl -N "$PERSONAAS_BASE_URL/api/v2/activity/$ACTIVITY_ID/stream" \
-H "x-personaas-key: $PERSONAAS_API_KEY"

In a second terminal (set the same variables there), send the question:

curl -X POST "$PERSONAAS_BASE_URL/api/$PERSONAAS_ENGINE/activity/$ACTIVITY_ID/message" \
-H "x-personaas-key: $PERSONAAS_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "input": "How many leave days can I carry over?" }'

Back in the first terminal, the answer arrives in pieces while the persona writes it, and ends with a WorkflowCompleted event that holds the whole answer:

event:RunContent
data:{"content":"You can carry ", ...}

event:WorkflowCompleted
data:{"content":"You can carry over up to 10 days…", "status":"completed", ...}

Press Ctrl+C to close the stream. The answer is also stored in the conversation:

curl "$PERSONAAS_BASE_URL/api/v1/activity/$ACTIVITY_ID/messages" \
-H "x-personaas-key: $PERSONAAS_API_KEY"

Keep activity_id: it is the conversation, and you need it for follow-up questions. In an app, read the events as described in Stream the answer.

If it did not work​

You gotLikely cause
401The key is wrong, expired, missing its @org_… part, or from another Personaas address
404The persona id or task id is not one from your own list
400 mentioning an encryption keyThe task is marked sensitive. Pick another task
503 when sendingEngine v3 has no free runner. Send the same message once on v1; see Engines
Nothing arrives on the streamThe stream was opened after the answer finished, or it was not open. Read the messages instead, and next time open the stream before sending

More in Troubleshooting.

Next​