Skip to main content
Here’s a guide to create agent sessions with programmatically provisioned Knowledge Contexts. And then embed a programmatic agent in your web application using those agent sessions.

Default agent system

With the default agents system, your Mindset App admin dashboard manages access permissions for knowledge contexts assigned on an agent basis. Learn more about knowledge contexts and default agents system.

Knowledge Context Provisioning System

You may need to provision agents and knowledge contexts access based on the permission system set up in your platform. We’ve introduced the concept of an agent session: Agent sessions are programmatically provisioned on-demand for specified agents and knowledge contexts. Once an agent session is created, providing the agentSessionUid to the <mindset-agent> HTML tag will allow you to embed the agent with the specified access permissions. Learn more about AgentSession and Multi-tenancy.

Tutorial : Create agent sessions and embed an agent with provisioned knowledge contexts

Required parameters

You will need to get a few parameters before starting. YOUR-APP-UID is provided by the Mindset support team. All others parameters can be found in the Mindset Management Portal.

Step 1: Create an agent session

To create an Agent Session (and hence generate an agentSessionUid required by the SDK), you will need to call the Mindset agentSessions API. (See the Agent Sessions API documentation for more details).
You would need to manage multiple agents, knowledge contexts and users on your platform.According to your permissions and roles system, users would have specific rights to access specific agents and specific Knowledge contextsFor example:
  • A User1 has the permission to use the agent1 provisioned with the Knowledge Context 1 and knowledge context 2.
  • But a User2 has the permission to use the agent1 provisioned with the Knowledge Context 1
Based on your permissions rules you will then create agent sessions.
What we would like to achieve is :
  • to provision the agent (agentUid v8srU0hv88BeWBDcirSm)
  • with the 2 knowledge contexts (contextUids [qZJGsjytbM5fL15sfBui, 3am8rolEPXx3j0n132Bf])
  • and for a user with an externalUserId (user-x123456).
We would need to provide the following parameters in the request body:
Below is an example of an HTTP POST request to create that agent session.
The API response object will be:
The most important information that will be reused in the next step is the :
agentSessionUid (v8srU0hv88BeWBDcirSm::uFKbuW0ipk2Za4QuQ6rx).

Step 2: Embed the agent in your web application

You embed this agent using the same method that you used to embed the default agent. You will use the <mindset-agent> HTML tag in your Front-end page:
But instead of providing the agentUid you will provide the agentSessionUid you just created in the previous step. The final HTML tag will look like this:

Agent Session Access Duration

Agent Sessions are intended to be generated on demand each time you create a web page that contains an embedded agent. They become inactive after 31 days of non-use. They can also be deactivated immediately using the API. We expect that you will create multiple agent sessions for the same user with identical agent and context details. Please refer to the Agent Sessions API documentation for more details on how to manage agent sessions.

Reporting

Here’s how to set up reporting for agents. When creating an agent session through the API, you can provide tags to the parmaters:
When initiating an agent session, the tags you specify are essential for understanding the interaction between agents, contexts, and users. Adding tags enables you to view reports based on groups or filter activity according to the tags you’ve applied. Please refer to the Agent Sessions API documentation for more information on adding tags.

Back-end and Front-end scripts full example

Back-end script

Sample back-end script (using express). It shows 2 end-points you can implement:
  1. /api/getusertoken which authenticate the user with Mindset system and returns an authToken
  2. /api/getagentsessionuid which create an agent session and returns the agentSessionUid

Front-end script

A sample front-end script which:
  1. Provide a getAuthToken() method using your /api/getusertoken end-point.
  2. Provide a getAgentSessionUid() method using your /api/getagentsessionuid end-point.
  3. Build the <mindset-agent> html tag by passing the agentSessionUid returned.
  4. call mindset.init()