-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCallLogsChecker.cs
More file actions
255 lines (223 loc) · 11.4 KB
/
CallLogsChecker.cs
File metadata and controls
255 lines (223 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
using Azure;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using System.Text.RegularExpressions;
namespace api_process_runner_api.Util
{
internal class CallLogChecker
{
// This function is a CallLogChecker, it allows you to detect several things. the intent and take action accordingly which
// Was Caller Authenticated?: Yes, Was 3rd Party Involved? No, Was this Call Transfered?: No
// Phone # updated from 8045055319 to 2512271296
// Address updated from 6608 zW 124TH ST OKLAHOMA CITY OK 73142 to 205 qfGzfLlf fVE EVERGREEN AL 36401
private string _promptVerificationConclusion = @"PersonID: {{$personid}}
{{$query}}
Return the Verification Conclusion of the query.
The Verification Conclusion must be in the format of JSON that consists of PersonID, ActivityRelatedTo, FormOfAuthentication, Phone Number properties.
The phone number will contain 10 digits and may or may not have dashes.
If there are multiple numbers listed, identify the most recent, updated phone number.
If there is no phone number, return 'no phone number'.
If ActivityRelatedTo is not 'Inbound Call' VerificationCompleted should be set to 'No'.
ActivityRelatedTo must be set to 'Inbound Call' and FormOfAuthentication must be 'KBA' or 'ID Verification' or 'One Time Passcode' before VerficationsCompleted can be set to 'Yes'
, otherwise VerficationsCompleted must be set to 'No'. The JSON format should be:
[JSON]
{
'PersonID': '12345',
'ActivityRelatedTo' : '<activity related to>',
'FormOfAuthentication' : '<form of authentication>',
'PhoneNumber' : '<phone number>',
'VerificationsCompleted' : <verifications completed>
}
[JSON END]
[Examples for JSON Output]
{
'PersonID': '12345',
'ActivityRelatedTo' : 'Inbound Call',
'FormOfAuthentication' : 'KBA',
'PhoneNumber' : '5555555555',
'VerificationsCompleted': 'Yes'
}
{
'PersonID': '12345',
'ActivityRelatedto' : 'Inbound Call',
'FormOfAuthentication' : 'ID Verfication',
'PhoneNumber' : 'no phone number',
'VerificationsCompleted': 'Yes'
}
{
'PersonID': '12345',
'ActivityRelatedto' : 'Inbound Call',
'FormOfAuthentication' : 'Low Risk',
'PhoneNumber' : '5555555555',
'VerificationsCompleted': 'No'
}
Per user query what is the Verification Conclusion?";
private string _promptFraudConclusion = @"PersonID: {{$personid}}
InStep3a: {{$instep3a}}
PassedStep3a: {{$passedstep3a}}
{{$query}}
Return the Fraud Conclusion intent of the query.
The Fraud Conclusion must be in the format of JSON that consists of FraudConclusionNotes, FraudConclusionType, Recommendation properties.
The FraudConclusionNotes should a short summary based on your review of the query.
The FraudConclusionType should be either 'No Fraud Detected' or 'Possible Account Takeover'.
The Recommendation should be your recommendations for futher action based on your conclusions.
If InStep3a is false, then PassedStep3a has no impact on your logic.
If InStep3a is true and PassedStep3a is true,
this means the the PersonID has passed all verificaiton steps and the form of authentication was 'One Time Passcode'
and it should be noted in the FraudCOnclusionNotes that this record passed Step3a
and therefore should not be considered fraud.
If based on the settings of InStep3a and PassedStep3a it's concluded this record is NOT fraud
then this should be reflected in the Recommendation, FraudConclusionNotes and FraudConclusionType.
The JSON format should be:
[JSON]
{
'PersonID': '12345',
'FraudConclusionNotes': '<conclusion>',
'FraudConclusionType' : 'No Fraud Detected',
'Recommendation': '<recommendation>'
}
[JSON END]
[Examples for JSON Output]
{
'PersonID':'12345',
'FraudConclusionNotes': 'There are multiple red flags suggesting potential fraud, including changes in contact information, inquiries about card information and transaction history, alert updates indicating possible account takeover',
'FraudConclusionType': 'Account Takeover'
'Recommendation': 'Further investigation and monitoring of the account are warranted to confirm fraudulent activity.'
}
Per user query what is the Fraud Conclusion?";
private string _promptActionConclusion = @"PersonID: {{$personid}}
{{$query}}
Return the Action Conclusion intent of the query.
The Acton Conclusion must be in the format of JSON that consists of
PersonID, CallerAuthenticated, FormOfAuthentication, ThirdPartyInvolved, WasCallTransferred, PhoneUpdateFrom, PhoneUpdatedTo, PhoneChanged, AddressChanged, AddressUpdateFrom, AddressUpdateTo properties.
The JSON format should be:
[JSON]
{
'PersonID': '12345',
'CallerAuthenticated': '<authenticated>',
'FormOfAuthentication' : '<authform>',
'ThirdPartyInvolved': <Thirdpartyinvolved>',
'WasCallTransferred':<calltransfered>,
'PhoneUpdateFrom':<phoneupdatefrom>,
'PhoneUpdatedTo':<phoneupdateto>,
'PhoneChanged': 'Yes',
'AddressChanged':'No',
'AddressUpdateFrom':<addressupdatefrom>,
'AddressUpdateTo':<addressupdateto>
}
[JSON END]
[Examples for JSON Output]
{
'PersonID': '12345',
'CallerAuthenticated': 'Yes',
'FormOfAuthentication' : 'ID Verification',
'ThirdPartyInvolved': 'No',
'WasCallTransferred':'No',
'PhoneUpdateFrom':'8045055319',
'PhoneUpdatedTo':'2512271296',
'PhoneChanged': 'Yes',
'AddressChanged':'Yes',
'AddressUpdateFrom':'6608 zW 124TH ST OKLAHOMA CITY',
'AddressUpdateTo':'205 qfGzfLlf fVE EVERGREEN AL'
}
Per use query what is the Action Conclusion?";
public async Task<string> CheckVerificationIntentAsync(Kernel kernel, string personid, string query)
{ // This function is used for verifying step 3.
// Activities related to: Inbound call (has to happen) && (Form of Auth: Id Verification OR Form of Auth: KBA)
#pragma warning disable SKEXP0010
var executionSettings = new OpenAIPromptExecutionSettings()
{
ResponseFormat = "json_object", // setting JSON output mode
};
KernelArguments arguments2 = new(executionSettings) { { "query", query }, { "personid", personid } };
string result = "";
timerCallback = new TimerCallback(OnTimerElapsed);
var timer = new Timer(timerCallback, null, 10 * 1000, 10 * 1000);
var startTime = DateTime.UtcNow;
try
{
// KernelArguments arguments = new(new OpenAIPromptExecutionSettings { ResponseFormat = "json_object" }) { { "query", query } };
Console.WriteLine("SK ,- CheckVerificationIntent");
var response = await kernel.InvokePromptAsync(_promptVerificationConclusion, arguments2);
result = response.GetValue<string>() ?? "";
}
catch (Exception ex)
{
timer.Dispose();
Console.WriteLine(ex);
}
finally
{
timer.Dispose();
Console.WriteLine($"Duration of Semantic Kernel for CheckVerificationIntentAsync: { DateTime.UtcNow - startTime } ");
}
return result ?? "";
}
public async Task<string> CheckFraudIntentAsync(Kernel kernel, string personid, string query,bool instep3a = false, bool passedstep3a = false)
{
#pragma warning disable SKEXP0010
var executionSettings = new OpenAIPromptExecutionSettings()
{
ResponseFormat = "json_object", // setting JSON output mode
};
KernelArguments arguments2 = new(executionSettings) { { "query", query }, { "personid", personid }, { "instep3a", instep3a }, { "passedstep3a", passedstep3a } };
string result = "";
timerCallback = new TimerCallback(OnTimerElapsed);
var timer = new Timer(timerCallback, null, 10 * 1000, 10 * 1000);
var startTime = DateTime.UtcNow;
try
{
// KernelArguments arguments = new(new OpenAIPromptExecutionSettings { ResponseFormat = "json_object" }) { { "query", query } };
Console.WriteLine("SK ,- CheckFraudIntent");
var response = await kernel.InvokePromptAsync(_promptFraudConclusion, arguments2);
result = response.GetValue<string>() ?? "";
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
finally
{
timer.Dispose();
Console.WriteLine($"Duration of Semantic Kernel for CheckFraudIntentAsync: {DateTime.UtcNow - startTime} ");
}
return result ?? "";
}
public async Task<string> CheckActionConclusionAsync(Kernel kernel, string personid, string query)
{
#pragma warning disable SKEXP0010
var executionSettings = new OpenAIPromptExecutionSettings()
{
ResponseFormat = "json_object",
};
KernelArguments arguments2 = new(executionSettings) { { "query", query }, { "personid", personid } };
string result = "";
timerCallback = new TimerCallback(OnTimerElapsed);
var timer = new Timer(timerCallback, null, 10 * 1000, 10 * 1000);
var startTime = DateTime.UtcNow;
try
{
// KernelArguments arguments = new(new OpenAIPromptExecutionSettings { ResponseFormat = "json_object" }) { { "query", query } };
Console.WriteLine("SK ,- CheckActionConclusionIntent");
var response = await kernel.InvokePromptAsync(_promptActionConclusion, arguments2);
result = response.ToString() ?? "";
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
finally
{
timer.Dispose();
Console.WriteLine($"Duration of Semantic Kernel for CheckActionConclusionAsync: {DateTime.UtcNow - startTime} ");
}
return result ?? "";
}
static TimerCallback timerCallback;
static void OnTimerElapsed(object state)
{
Console.WriteLine("Still working...");
}
}
}