User events¶
Alan AI emits several types of events triggered by users’ interactions with the Agentic Interface. You can listen to these events with the onUserEvent callback.
Note
The user statistics is updated after the user dialog session is closed.
Types of events¶
Event name |
Description |
---|---|
Fired when the user clicks the Agentic Interface button in the app |
|
Fired when Alan AI connects to the Agentic Interface project and is ready to listen to the user’s input |
|
Fired when the user activates the Agentic Interface for the first time during the dialog session |
|
Fired when the user clicks the Agentic Interface button for the first time during the dialog session |
|
Fired when the user allows access to the microphone |
|
Fired when a prompt to allow access to the microphone is displayed |
|
Fired when the user clicks the close icon in the Alan AI button popup |
|
Fired during and upon the user’s input recognition |
|
Fired when a popup next to the Agentic Interface button is displayed |
In the example below, the Agentic Interface listens to the firstActivate
event and, if the last interaction with the user occurred earlier than one day ago, plays a greeting to the user.
function diffFrom(ts, units) {
let last = DateTime.fromMillis(ts);
let now = DateTime.local();
console.log(`now.diff(last): ${now.diff(last)}`);
console.log(`units: ${units}, now.diff(last).as(units): ${now.diff(last).as(units)}`);
return now.diff(last).as(units);
}
onUserEvent((p, e) => {
console.info('event', JSON.stringify(e));
if (e.event == 'firstActivate') {
if (diffFrom(e.userInfo.lastInteractionTs, 'days') > 1) {
p.play('Hi, I am Alan, your Agentic Interface. Ask any question or tell me what you would like to do');
}
}
});
buttonClicked event
Fired when the user clicks the Agentic Interface button in the app.
{
"event": "buttonClicked",
"micAllowed": false,
"ts": 1666259901446,
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666259897357
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Boolean |
Access to microphone during the dialog session: allowed ( |
|
Integer |
Timestamp of when the Agentic Interface button was clicked |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
buttonReady event
Fired when Alan AI connects to the Agentic Interface project and is ready to listen to the user’s input.
{
"event": "buttonReady",
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 0,
"lastConnectTs": 1666259897357
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
firstActivate event
Fired when the user activates the Agentic Interface for the first time during the dialog session.
{
"event": "firstActivate",
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666259138126
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
firstClick event
Fired when the user clicks the Agentic Interface button for the first time during the dialog session.
{
"event": "firstClick",
"ts": 1666259398408,
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666259395336
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Integer |
Timestamp of when the Agentic Interface button was clicked for the first time |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
micAllowed event
Fired when the user allows access to the microphone.
{
"event": "micAllowed",
"ts": 1666259399772,
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666259395336
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Integer |
Timestamp of when the microphone access was allowed |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
micPermissionPrompt event
Fired when a prompt to allow access to the microphone is displayed.
{
"event": "micPermissionPrompt",
"ts": 1666259901443,
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666259897357
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Integer |
Timestamp of when the prompt was displayed |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
recognized event
Fired during and upon the user’s input recognition. The event description contains an interim or final result for the interpreted user’s phrase and the recognition state in the final
field:
If the user’s input is still being recognized, the
final
field value isfalse
.If the user’s input has been recognized, the
final
field value istrue
.
{
"event": "recognized",
"final": false,
"text": "hello",
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666257658614
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Boolean |
User’s input recognition state: final ( |
|
String |
Interim or final result for the interpreted user’s input |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
popupCloseClicked event
Fired when the user clicks the close icon in the popup displayed next to the Agentic Interface button. For details, see Alan AI button popups.
{
"event": "popupCloseClicked",
"ts": 1666259141166,
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666259138126
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Integer |
Timestamp of when the close icon was clicked |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
showPopup event
Fired when a popup next to the Agentic Interface button is displayed. For details, see Alan button popups.
{
"event": "showPopup",
"ts": 1666259141166,
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666259138126
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Integer |
Timestamp of when the popup was displayed |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
Event name |
Description |
---|---|
Fired when Alan AI connects to the Agentic Interface project and is ready to listen to the user’s input |
|
Fired when the user clicks the Agentic Interface button for the first time during the dialog session |
|
Fired when the user allows access to the microphone |
|
Fired when a prompt to allow access to the microphone is displayed |
|
Fired during and upon the user’s input recognition |
In the example below, the Agentic Interface listens to the firstClick
event and, if the last interaction with the user occurred earlier than one day ago, plays a greeting to the user.
function diffFrom(ts, units) {
let last = DateTime.fromMillis(ts);
let now = DateTime.local();
console.log(`now.diff(last): ${now.diff(last)}`);
console.log(`units: ${units}, now.diff(last).as(units): ${now.diff(last).as(units)}`);
return now.diff(last).as(units);
}
onUserEvent((p, e) => {
console.info('event', JSON.stringify(e));
if (e.event == 'firstClick') {
if (diffFrom(e.userInfo.lastInteractionTs, 'days') > 1) {
p.play('Hi, I am Alan, your Agentic Interface. Ask any question or tell me what you would like to do');
}
}
});
buttonReady event
Fired when Alan AI connects to the Agentic Interface project and is ready to listen to the user’s input.
{
"event": "buttonReady",
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 0,
"lastConnectTs": 1666259897357
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
firstClick event
Fired when the user clicks the Agentic Interface button for the first time during the dialog session.
{
"event": "firstClick",
"ts": 1666259398408,
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666259395336
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Integer |
Timestamp of when the Agentic Interface button was clicked for the first time |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
micAllowed event
Fired when the user allows access to the microphone.
{
"event": "micAllowed",
"ts": 1666259399772,
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666259395336
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Integer |
Timestamp of when the microphone access was allowed |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
micPermissionPrompt event
Fired when a prompt to allow access to the microphone is displayed.
{
"event": "micPermissionPrompt",
"ts": 1666259901443,
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666259897357
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Integer |
Timestamp of when the prompt was displayed |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |
recognized event
Fired during and upon the user’s input recognition. The event description contains an interim or final result for the interpreted user’s phrase and the recognition state in the final
field:
If the user’s input is still being recognized, the
final
field value isfalse
.If the user’s input has been recognized, the
final
field value istrue
.
{
"event": "recognized",
"final": false,
"text": "hello",
"userInfo": {
"interactions": 25,
"recognized": 25,
"unrecognized": 0,
"lastInteractionTs": 1666255324364,
"lastConnectTs": 1666257658614
}
}
Field name |
Data type |
Description |
---|---|---|
|
String |
Event name: |
|
Boolean |
User’s input recognition state: final ( |
|
String |
Interim or final result for the interpreted user’s input |
|
Integer |
Number of interactions with the user |
|
Integer |
Number of recognized user’s interactions |
|
Integer |
Number of unrecognized user’s interactions |
|
Integer |
Timestamp of the last interaction with the Agentic Interface |
|
Integer |
Timestamp of the last connection to the Agentic Interface |