Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to update media url for Insights UI #102

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/call-score/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ func main() {
// os.Exit(1)
}

// Update Media URL for Insights Details UI
newMediaUrl := "https://publicly-accessible-audio-url.mp3"
err = asyncClient.UpdateMediaUrlForInsightsDetailsUI(ctx, conversationJob.ConversationID, newMediaUrl)
if err == nil {
fmt.Printf("Media URL for Insights Details UI updated successfully.\n")
} else {
fmt.Printf("Update Media URL for Insights Details UI failed. Err: %v\n", err)
// os.Exit(1)
}

fmt.Printf("\n\n")
fmt.Printf("\n\n")

Expand Down
61 changes: 61 additions & 0 deletions pkg/api/async/v1/summaryui.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,64 @@ func (c *Client) GetInsightsDetailsUiURI(ctx context.Context, conversationId str
klog.V(6).Infof("async.GetInsightsDetailsUiURI LEAVE\n")
return &result, nil
}

// UpdateMediaUrlForInsightsDetailsUI updates the audio/video URL that will be played in Insights UI
func (c *Client) UpdateMediaUrlForInsightsDetailsUI(ctx context.Context, conversationId string, mediaUrl string) error {
klog.V(6).Infof("async.UpdateMediaUrlForInsightsDetailsUI ENTER\n")

// checks
if ctx == nil {
ctx = context.Background()
}
if conversationId == "" {
klog.V(1).Infof("conversationId is empty\n")
klog.V(6).Infof("async.UpdateMediaUrlForInsightsDetailsUI LEAVE\n")
return ErrInvalidInput
}
if mediaUrl == "" {
klog.V(1).Infof("mediaUrl is empty\n")
klog.V(6).Infof("async.UpdateMediaUrlForInsightsDetailsUI LEAVE\n")
return ErrInvalidInput
}

// request
URI := fmt.Sprintf("%s%s",
version.GetAsyncAPI(version.UpdateMediaURI, conversationId), // You'll need to define the endpoint in your version package
c.getQueryParamFromContext(ctx))
klog.V(6).Infof("Calling %s\n", URI)

requestBody, err := json.Marshal(map[string]string{
"url": mediaUrl,
})
if err != nil {
klog.V(1).Infof("json.Marshal failed. Err: %v\n", err)
klog.V(6).Infof("async.UpdateMediaUrlForInsightsDetailsUI LEAVE\n")
return err
}

req, err := http.NewRequestWithContext(ctx, "PUT", URI, bytes.NewBuffer(requestBody))
if err != nil {
klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err)
klog.V(6).Infof("async.UpdateMediaUrlForInsightsDetailsUI LEAVE\n")
return err
}

// execute request
resp, err := c.Client.Do(req)
if err != nil {
klog.V(1).Infof("Request execution failed. Err: %v\n", err)
klog.V(6).Infof("async.UpdateMediaUrlForInsightsDetailsUI LEAVE\n")
return err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
klog.V(1).Infof("HTTP Code: %v\n", resp.StatusCode)
klog.V(6).Infof("async.UpdateMediaUrlForInsightsDetailsUI LEAVE\n")
return fmt.Errorf("HTTP Code: %v", resp.StatusCode)
}

klog.V(3).Infof("Update MediaUrl For InsightsUI succeeded\n")
klog.V(6).Infof("async.UpdateMediaUrlForInsightsDetailsUI LEAVE\n")
return nil
}
1 change: 1 addition & 0 deletions pkg/api/version/async-version.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const (
// Insights Ui
InsightsListUiURI string = "https://api.symbl.ai/%s/conversations/experiences/insights/list?includeCallScore=true"
InsightsDetailsUiURI string = "https://api.symbl.ai/%s/conversations/experiences/insights/details/%s?includeCallScore=true"
UpdateMediaURI string = "https://api.symbl.ai/%s/conversations/%s/experience/url"

// Conversations
ConversationsURI string = "https://api.symbl.ai/%s/conversations"
Expand Down