67 lines
1.5 KiB
Go
67 lines
1.5 KiB
Go
package banking
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/explorer/virtual-banker/backend/tools"
|
|
)
|
|
|
|
// CreateTicketTool creates a support ticket
|
|
type CreateTicketTool struct {
|
|
client *BankingClient
|
|
}
|
|
|
|
// NewCreateTicketTool creates a new create ticket tool
|
|
func NewCreateTicketTool() *CreateTicketTool {
|
|
return &CreateTicketTool{
|
|
client: NewBankingClient(getBankingAPIURL()),
|
|
}
|
|
}
|
|
|
|
// Name returns the tool name
|
|
func (t *CreateTicketTool) Name() string {
|
|
return "create_support_ticket"
|
|
}
|
|
|
|
// Description returns the tool description
|
|
func (t *CreateTicketTool) Description() string {
|
|
return "Create a support ticket for customer service"
|
|
}
|
|
|
|
// Execute executes the tool
|
|
func (t *CreateTicketTool) Execute(ctx context.Context, params map[string]interface{}) (*tools.ToolResult, error) {
|
|
subject, _ := params["subject"].(string)
|
|
details, _ := params["details"].(string)
|
|
|
|
if subject == "" {
|
|
return &tools.ToolResult{
|
|
Success: false,
|
|
Error: "subject is required",
|
|
}, nil
|
|
}
|
|
|
|
// Call banking service
|
|
data, err := t.client.CreateTicket(ctx, subject, details)
|
|
if err != nil {
|
|
// Fallback to mock data if service unavailable
|
|
return &tools.ToolResult{
|
|
Success: true,
|
|
Data: map[string]interface{}{
|
|
"ticket_id": fmt.Sprintf("TKT-%d", 12345),
|
|
"subject": subject,
|
|
"status": "open",
|
|
"note": "Using fallback data - banking service unavailable",
|
|
},
|
|
RequiresConfirmation: false,
|
|
}, nil
|
|
}
|
|
|
|
return &tools.ToolResult{
|
|
Success: true,
|
|
Data: data,
|
|
RequiresConfirmation: false,
|
|
}, nil
|
|
}
|
|
|