Find the right persona for a question
Use this when the app has one input box and the user should not have to pick a persona or a task first. You send the question; Personaas looks at the personas assigned to the user, picks the one and the task that fit the question best, and creates a conversation with them.
Request
curl -X POST "$PERSONAAS_BASE_URL/api/v1/activity/resolve" \
-H "x-personaas-key: $PERSONAAS_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "input": "How many leave days can I carry over?" }'
Response
{
"activity_id": "0b6f6a0e-…",
"persona_id": 12,
"persona_name": "HR Assistant",
"task_id": 40,
"task_name": "Leave questions"
}
This is the persona and task that will answer, and the conversation it created for them. The question has not been answered yet.
Then send the question
Open the conversation's stream as in Ask a persona a question, then send the same text to it:
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?" }'
Then read the answer from the stream, as in
Ask a persona a question.
Follow-ups go to the same activity_id.
Show persona_name and task_name to the user so they can see who is answering.
Failures
| Status | detail | What to do |
|---|---|---|
400 | No personas assigned to the user | Show the "ask your administrator" message |
400 | No tasks configured for this persona | Show a plain error; nothing the user can fix |
Mistakes to avoid
- Expecting the answer from
/resolve. It only picks the persona and task and creates the conversation. - Calling
/resolvefor every follow-up. That creates a new conversation each time. Call it once, then reuseactivity_id. - Skipping the sensitive check. If the chosen task is sensitive (look the
task_idup in the persona list from List personas and tasks), tell the user this app cannot handle that request.