🧠 What the system does
• Sends content from Salesforce (Case, EmailMessage, or MessagingSession) to Toqan for AI interpretation, and retrieves results such as: category, subcategory, and other extra fields defined in the prompt.
• Works with MessagingSession, EmailMessage, or Case objects.
🚀 How to use it (Quick overview)
1) Conversation Creation Flow (Start)
Trigger: Preferably After Save, when there is content to send and the Toqan context is not already populated.
Conditions:
- MessagingSession:
Body__cis filled. - EmailMessage / Case:
SubjectandDescriptionorBodyare filled.
In the Apex action (creation class), set:
recordId= Id of the Case / EmailMessage / MessagingSessioncustomLabelAPI= API name of the Custom Label containing the Toqan key (e.g.,Toqan_Agent_Key)isCase = truefor Case; otherwisefalseisEmail = truefor EmailMessage; otherwisefalse- If both
isCaseandisEmailarefalse⇒ treated as MessagingSession
What it does:
Sends the content to Toqan and saves the conversation context (as returned by Toqan’s create_conversation endpoint) — including conversationId, requestId, and agent — into the field Toqan_Conversation_JSON__c.
2) Response Retrieval Flow (Continuation)
Trigger: Preferably After Save, when Toqan_Conversation_JSON__c is populated or updated.
In the Apex action (get class), set:
recordId= Id of the Case / EmailMessage / MessagingSessionjsonInput= conversation data (conversationId, requestId, agent, etc.) from the create conversation API response
What it does:
Requests the result from Toqan and writes back:
CR1AI_T__c→ Category [Main fields]CR2AI_T__c→ Subcategory [Main fields]Toqan_response_log__c→ Final response or error log [Main + any secondary fields if present]
3) Parsing / Mapping Flow (Optional)
Trigger: After Save, when Toqan_response_log__c is populated or updated.
What it does:
Reads the response and maps values into desired custom fields (this can be extended without modifying Apex code).
Example:
If Toqan_response_log__c contains additional fields besides category and subcategory, you can parse the JSON to extract those values and populate custom fields on the object.
⚙️ Object-specific configurations (When call the apex class)
| Object | isCase | isEmail | Text Source |
|---|---|---|---|
| MessagingSession | false | false | Body__c |
| EmailMessage | false | true | Subject + Email body |
| Case | true | false | Subject + Description |
📊 Where to see the results
| Field | Description |
|---|---|
Toqan_response_log__c | Final full response / errors |
Toqan_Conversation_JSON__c | Conversation context (conversationId, requestId, agent, type of object) |
CR1AI_T__c | Category |
CR2AI_T__c | Subcategory |

