-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
70 lines (62 loc) · 1.79 KB
/
main.go
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
package main
import (
"context"
"fmt"
"time"
uuid "github.com/satori/go.uuid"
"github.com/voximplant/pds-sample-client/client"
)
func main() {
//TODO: put account id and API key below
prop, err := client.NewAgentProperties(client.NewAuth(1, "api-key"))
if err != nil {
panic(err)
}
conn, err := client.NewConn(prop.Host)
if err != nil {
panic(err)
}
defer conn.Close()
pdsConfig := client.PDSConf{
RuleID: 1, //TODO: Put your rule id here
QueueID: 1, //TODO: Put SmartQueue queue id here
ReferenceIP: "69.167.178.4",
AvgTimeTalkSec: 80.0,
PercentSuccessful: 0.4,
MaximumErrorRate: 0.05, // TODO: config for Abandonment rate optimized solutions
MinimumBusyFactor: 0.8, // TODO: config for busy factor optimized solutions
PredictiveType: client.AbandonRateOptimization, // TODO: change it to switch predictive algorithm
SessionID: uuid.NewV4().String(),
ApplicationID: 1, //TODO: Put your application id here
}
//TODO: Uncommend following line to enable progressive mode instead of predictive.
//pdsConfig.TaskMultiplier = 1
agent, err := client.NewAgent(conn, prop.Auth, &pdsConfig)
if err != nil {
panic(err)
}
taskChan := agent.GetTaskChannel()
go func() {
defer close(taskChan)
for {
// send task to agent
//TODO: send actual call list data to service
tmpTask := map[string]interface{}{
"phone_number": "1234567",
}
taskChan <- tmpTask
}
}()
for repeat := 5; repeat > 0; repeat-- {
err = runAgent(context.Background(), agent)
if err != nil {
time.Sleep(2 * time.Second)
fmt.Println(err)
}
}
}
func runAgent(ctx context.Context, agent client.PDSAgent) error {
cc, cancel := context.WithCancel(ctx)
defer cancel()
return agent.Start(cc)
}