หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
msdyn_invokeCaseProcessingAgentใช้เหตุการณ์ธุรกิจเพื่อกระตุ้นตัวแทนจัดการเคสให้ทำสิ่งต่อไปนี้:
- แยกข้อมูลจากเอนทิตีต้นทาง เช่น อีเมล และอัปเดตกรณีที่มีรายละเอียดที่เกี่ยวข้อง
- แก้ไขเคสเฉพาะ
คุณสามารถใช้สิ่งนี้เพื่อขยายการทํางานอัตโนมัติของกรณีนอกเหนือจากทริกเกอร์เริ่มต้น ตัวอย่างเช่น คุณสามารถเรียกใช้ตัวแทนการจัดการกรณีและปัญหาเมื่อลูกค้าสร้างกรณีจากพอร์ทัลภายนอก หรือเมื่อมีเหตุการณ์ CRUD เกิดขึ้นในตารางแบบกําหนดเอง เช่น ใบเสร็จใหม่ที่เพิ่มลงในกรณีและปัญหา
ข้อกำหนดเบื้องต้น
- กําหนดค่าเอเจนต์การจัดการกรณีแล้ว
- ตรวจสอบให้แน่ใจว่าได้ติดตั้ง
Microsoft.CrmSdk.CoreAssemblies,Newtonsoft.Json, และMicrosoft.Xrm.Tooling.Connector.dllจาก Microsoft.CrmSdk.CoreTools แล้ว
การร้องขอทาง HTTP
POST [Organization URI]/api/data/v9.2/msdyn_invokeCaseProcessingAgent
เนื้อหาของคำขอ
| คุณสมบัติ | ชนิด | จำเป็น | คำอธิบาย |
|---|---|---|---|
| msdyn_incidentId | สตริง | ใช่ | ID ของกรณี (เหตุการณ์) ที่ตัวแทนการจัดการเหตุการณ์ควรทํางาน ตัวอย่าง: "3895d023-a353-f011-877b-6045bd062e87" |
| msdyn_actions | อาร์เรย์ JSON ที่แปลงเป็นสตริง | ใช่ | กำหนดว่าต้องดำเนินการและใช้ความสามารถใดของ Case Management Agent ดูรายละเอียดในส่วนถัดไป |
msdyn_extraParams |
วัตถุ JSON ที่แปลงเป็นสตริง | ไม่ | ให้บริบทเพิ่มเติมและตัวเลือกการเรียกใช้ ดูพารามิเตอร์เพิ่มเติม. |
ส่ง msdyn_actions และ msdyn_extraParams เป็น JSON ที่เก็บไว้ในสตริง ไม่ใช่เป็นอาร์เรย์ JSON หรือวัตถุในเนื้อหาคำขอ
ออบเจ็กต์อาร์เรย์ msdyn_actions
| คุณสมบัติ | ชนิด | จำเป็น | คำอธิบาย |
|---|---|---|---|
| การเคลื่อนไหว | สตริง | ใช่ | กําหนดการดําเนินการประมวลผลกรณีที่จะเรียกใช้ ค่า:
|
| automationLevel | สตริง | ไม่ | สําหรับการเรียกใช้งานปกติ Case Management Agent จะใช้โหมดอัตโนมัติที่ผู้ดูแลระบบกําหนดค่าไว้ ไม่ใช่ค่า Full หรือ Semi ที่ให้ไว้ที่นี่ ถ้า msdyn_extraParams.requestProcessed เป็น true, เพย์โหลดของแอ็กชันจะถูกใช้ตามที่จัดเตรียมไว้แทนที่จะอัปเดตจากการตั้งค่าที่กำหนดไว้ |
| sourceContextEntity | สตริง | ใช่ | นี่คือค่าที่จำเป็นสำหรับการเสริมกรณีและเป็นตัวเลือกเพิ่มเติมสำหรับการแก้ไขกรณี เอนทิตีแหล่งข้อมูล เช่น อีเมลหรือการสนทนาที่ต้องใช้เพื่ออัปเดตกรณี ตัวอย่าง: "emails(0e20cf92-f663-f011-bec1-000d3a3622ba)" |
customAgentOutput |
วัตถุ JSON ที่แปลงเป็นสตริง | ไม่ | สําหรับ resolve, ให้ผลลัพธ์ของเอเจนต์ที่กําหนดเองในรูปแบบ callback แบบอะซิงโครนัส วัตถุใช้สัญญาเอาต์พุตของตัวแทนที่กำหนดเอง รวมถึง responseType, message, handlingOptions, customAgentName, และ templateId |
พารามิเตอร์เพิ่มเติม
วัตถุนี้ msdyn_extraParams รองรับคุณสมบัติดังต่อไปนี้
| คุณสมบัติ | ชนิด | จำเป็น | คำอธิบาย |
|---|---|---|---|
additionalInformation |
อาร์เรย์ของวัตถุ | ไม่ | ให้ข้อมูลจากระบบภายนอกเพื่อการตรวจจับเจตนา แต่ละอ็อบเจ็กต์ประกอบด้วย key เพื่อระบุข้อมูล value ที่มีเนื้อหา และ keyDescription ที่อธิบายว่าเนื้อหานั้นหมายถึงอะไร คุณสมบัติทั้งสามเป็นสตริง |
triggerReason |
สตริง | ไม่ | ระบุเหตุผลที่เอเจนต์ถูกเรียกใช้ ตัวอย่างเช่น ใช้ customAgentCallback เมื่อ custom agent โทรกลับไปยัง Case Management Agent |
refreshIntentFamily |
แบบบูลีน | ไม่ | เมื่อ true, กําหนดตระกูล intent อีกครั้งโดยใช้เครื่องมือกฎแทนระเบียนที่แคช msdyn_intententity ไว้ ใช้ได้เฉพาะเมื่อเปิดสวิตช์ฟีเจอร์ RefreshIntentFamilyInCMAFlow ไว้เท่านั้น |
คำขอตัวอย่าง
{
"msdyn_incidentId": "5ad2ac2c-6363-f011-bec2-6045bd026457",
"msdyn_actions": "[{\"action\":\"enrich\",\"sourceContextEntity\":\"emails(0e20cf92-f663-f011-bec1-000d3a3622ba)\"},{\"action\":\"resolve\",\"automationLevel\":\"Full\"}]"
}
การตอบสนอง
-
ความสําเร็จ: ส่งกลับ HTTP
204 No Contentด้วยเนื้อความที่ว่างเปล่า - ความล้มเหลว: การตอบกลับข้อผิดพลาดมาตรฐานของ OData
โค้ดตัวอย่าง
ในตัวอย่างต่อไปนี้ คุณจะเรียกใช้ Case Management Agent จากปลั๊กอิน Dataverse หรือโค้ดที่กําหนดเองโดยการรัน msdyn_invokeCaseProcessingAgent คําขอองค์กร เอเจนต์จะอัปเดตเคสโดยใช้อีเมลที่เกี่ยวข้อง จากนั้นจะดําเนินการแก้ไขเคสโดยใช้โหมดอัตโนมัติที่ผู้ดูแลระบบกําหนดไว้
ตัวอย่างที่ 1
CrmServiceClient GetService()
{
string orgUrl = "";
string username = "";
string connectionString = $"AuthType=OAuth;Username={username};Url={orgUrl};AppId=51f81489-12ee-4a9e-aaae-a2591f45987d;RedirectUri=http://localhost;LoginPrompt=Auto";
CrmServiceClient svc = new CrmServiceClient(connectionString);
return svc;
}
public class InvokeCaseProcessingAgentRequest
{
[JsonProperty("msdyn_incidentId")]
public string incidentid { get; set; }
[JsonProperty("msdyn_actions")]
public List<AgentAction> actions { get; set; }
}
public class AgentAction
{
[JsonProperty("action")]
public AgentActionType action { get; set; }
[JsonProperty("sourceContextEntity")]
public string sourceContextEntity { get; set; }
[JsonProperty("automationLevel")]
public AutomationLevel? automationLevel { get; set; }
}
[JsonConverter(typeof(StringEnumConverter))]
public enum AgentActionType
{
[EnumMember(Value = "enrich")]
Enrich,
[EnumMember(Value = "resolve")]
Resolve
}
[JsonConverter(typeof(StringEnumConverter))]
public enum AutomationLevel
{
[EnumMember(Value = "Full")]
Full,
[EnumMember(Value = "Semi")]
Semi
}
void Main()
{
var service = GetService();
var actions = new List<AgentAction>()
{
new AgentAction()
{
action = AgentActionType.Enrich,
sourceContextEntity = "emails(0e20cf92-f663-f011-bec1-000d3a3622ba)"
},
new AgentAction()
{
action = AgentActionType.Resolve,
automationLevel = AutomationLevel.Full
},
};
var req = new OrganizationRequest("msdyn_invokeCaseProcessingAgent")
{
["msdyn_incidentId"] = new Guid("8f2db50d-0c64-f011-bec2-000d3a3b776a"),
["msdyn_actions"] = JsonConvert.SerializeObject(actions)
};
service.Execute(req);
}
ตัวอย่างที่ 2
function invokeCaseManagementAgent() {
var data = JSON.stringify({
"msdyn_incidentId": "020edf2f-7d3f-4a69-bd26-030736604eeb",
"msdyn_actions": "[{\"action\":\"enrich\",\"sourceContextEntity\":\"emails(0e20cf92-f663-f011-bec1-000d3a3622ba)\"},{\"action\":\"resolve\",\"automationLevel\":\"Full\"}]"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", Xrm.Utility.getGlobalContext().getClientUrl()+"/api/data/v9.2/msdyn_invokeCaseProcessingAgent");
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Accept", "*/*");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
}
invokeCaseManagementAgent();
ให้ข้อมูลเพิ่มเติมจากระบบภายนอก
ใช้ additionalInformation เพื่อให้บริบท เช่น เนื้อหาไฟล์แนบหรือสถานะการรับประกัน สำหรับการตรวจจับเจตนา คําขอ Web API นี้ส่งพารามิเตอร์ทั้งสองในรูปแบบสตริงที่มีข้อมูล JSON
{
"msdyn_incidentId": "00000000-0000-0000-0000-000000000000",
"msdyn_actions": [
{ "action": "resolve", "sourceContextEntity": "emails(<email-guid>)" }
],
"msdyn_extraParams": {
"triggerReason": "customAgentCallback",
"additionalInformation": [
{ "key": "attachmentContent", "value": "This is my attachment content",
"keyDescription": "File attachment content in natural language" },
{ "key": "warrantyStatus", "value": "Fulfilled",
"keyDescription": "Current warranty fulfillment status" }
]
}
}
ส่งคืนผลลัพธ์ custom agent แบบอะซิงโครนัส
เมื่อ custom agent กลับมา WaitCase Management Agent จะว่างขณะที่ custom agent ทํางานแบบอะซิงโครนัส หากต้องการดําเนินการต่อ ให้เรียกใช้ msdyn_invokeCaseProcessingAgent ด้วย resolve การกระทําและ customAgentOutput ค่าที่ responseType ไม่ใช่ Wait. สําหรับเวิร์กโฟลว์การผสานรวม ดูที่ วิธีการทํางานของการผสานรวม
คำขอ Web API ต่อไปนี้ส่ง customAgentOutput เป็นสตริง JSON ภายในอาร์เรย์ msdyn_actions ที่ถูกแปลงเป็นสตริง แทนที่ case ID, ชื่อสคีมาเอเจนต์ และ template ID ด้วยค่าจากสภาพแวดล้อมของคุณ
{
"msdyn_incidentId": "<case-guid>",
"msdyn_actions": [ {
"action": "resolve",
"customAgentOutput": { "responseType": "Resolved", "message": "<message>",
"handlingOptions": { "needsReview": "true" },
"customAgentName": "<agent schema name>", "templateId": "<template-guid>" }
} ]
}