I am currently working on implementing session entities to store custom values during the current session in Google Dialogflow CX. However, I encountered an error: Error: 5 NOT_FOUND: com.google.apps.framework.request.NotFoundException: No entity is found for this agent id '844d799-4bc6-826b-bfc38de06' and entity id 'userState'
. My objective is to persist the value associated with the key ‘userState’ across sessions. I am utilizing the Node.js client for this purpose.
async createContextSessionEntities(conversationId: string, entityTypeDisplayName: string, contextParameters: string[], environment?: string, userId?: string, entityMode?: string) {
// console.log(conversationId,entityTypeDisplayName, contextParameters, entityMode);
try {
const sessionEntityTypesClient = new dialogflow.SessionEntityTypesClient(
{
credentials: this.config as any,
apiEndpoint: this.location !== 'global' ? `${this.location}-dialogflow.googleapis.com` : 'dialogflow.googleapis.com'
});
const sessionEntityTypesClientPath = sessionEntityTypesClient.projectLocationAgentSessionPath(
this.dialogFlowProjectId,
this.location,
this.agentid,
conversationId
)
const sessionParamter = {
name: `${sessionEntityTypesClientPath}/entityTypes/${entityTypeDisplayName}`,
entityOverrideMode: entityMode || "ENTITY_OVERRIDE_MODE_SUPPLEMENT" as any,
entities: [{
name: Object.keys(contextParameters) as any,
value: Object.keys(contextParameters) as any,
}]}
const sessionEntityTypeRequest = {
parent: sessionEntityTypesClientPath,
sessionEntityType: sessionParamter,
};
const [response] = await sessionEntityTypesClient.createSessionEntityType(
sessionEntityTypeRequest
);
LogManager.EventInfoLog('SessionEntityType created:');
return response;
} catch (error) {
LogManager.EventErrorLog('df error creating session entity', error.stack)
throw new Error(error.stack);
}
}
In the context of my code, the variable entityTypeDisplayName corresponds to the value ‘userState’.
I kindly request a code review, and I am eagerly awaiting a solution.