Repository navigation
Expand file tree
/
Copy pathTapExample.java
More file actions
66 lines (57 loc) · 2.73 KB
/
Copy pathTapExample.java
File metadata and controls
66 lines (57 loc) · 2.73 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
/**
* Tap Example.
*
* Demonstrates using the FunctionResult tap helpers for:
* - WebSocket and RTP audio streaming
* - Compliance and quality monitoring
* - Starting and stopping tap sessions by control ID
*/
import com.signalwire.sdk.agent.AgentBase;
import com.signalwire.sdk.swaig.FunctionResult;
import java.util.List;
import java.util.Map;
public class TapExample {
public static void main(String[] args) throws Exception {
var agent = AgentBase.builder()
.name("tap-agent")
.route("/")
.port(3000)
.build();
agent.promptAddSection("Role",
"You are a call center supervisor assistant that manages call monitoring.");
agent.promptAddSection("Instructions", "", List.of(
"Use start_monitoring to begin monitoring a call",
"Use stop_monitoring to end monitoring",
"Use start_compliance_tap for compliance recording"
));
// Start WebSocket tap
agent.defineTool("start_monitoring", "Start monitoring a call via WebSocket",
Map.of("type", "object", "properties", Map.of()),
(toolArgs, raw) -> new FunctionResult("Starting call monitoring")
.tap("wss://monitoring.company.com/audio-stream",
"monitor_001", "both", "PCMU")
.setMetadata(Map.of("monitoring", true))
.say("Call monitoring is now active."));
// Stop tap
agent.defineTool("stop_monitoring", "Stop the active monitoring session",
Map.of("type", "object", "properties", Map.of()),
(toolArgs, raw) -> new FunctionResult("Ending monitoring session")
.stopTap("monitor_001")
.setMetadata(Map.of("monitoring", false))
.say("Call monitoring has been stopped."));
// Compliance tap
agent.defineTool("start_compliance_tap",
"Start compliance monitoring with RTP streaming",
Map.of("type", "object", "properties", Map.of()),
(toolArgs, raw) -> new FunctionResult("Setting up compliance monitoring")
.tap("rtp://compliance.company.com:6000",
"compliance_001", "both", "PCMA")
.setMetadata(Map.of(
"compliance_session", true,
"recording_purpose", "regulatory_compliance"
))
.say("This call is being monitored for compliance purposes."));
System.out.println("Starting Tap monitoring agent on port 3000...");
agent.run();
}
}