Loading

How to pass knowledge answer result to apex from Einstein Bot ?

Julkaisupäivä: Nov 12, 2024
Kuvaus

This article helps us to understand how can we leverage Apex Wrapper Class to store the Article Answer selected by the end user in a Bot Conversation.

The Answer Selected Result Object has a different structure so you won't be able to pass it to the apex class and map to Knowledge__kav object.


The structure of Answer Selected Result Object is as follow:

{

"question": "abc",
"answer": "test",
"confidence": 0.817549,
"id": "kaQ1q0000008OJXEA2",
"title": "test",
"type": "FAQ"

}


Below is an example which explains the creation of object and passing the selected variable to the apex class :

Create a class example;

public class objectArt {
public string question;
public string answer;
public double confidence;
public string id;
public string title;
public string type;
}

and then use this object in an invocable variable example:

public class Requests {
@InvocableVariable(label='Records for Input' description='yourDescription' required=true)
public objectArt article;
}

and the Answer Selected Result object will be mapped Successfully and you can able access the id of the knowledge selected.

The invocable method should accept this invocable variable as input for example,
@InvocableMethod(label='Get article')
public static List<Results> getSkillId(List<Requests> sobj) {....}


Please review these relevant help articles:


InvocableVariable Annotation 

InvocableMethod Annotation

Einstein Bots System Limitations(Apex action time limit - 10 seconds)

 

Knowledge-artikkelin numero

003789771

 
Ladataan
Salesforce Help | Article