Labeling conversation with GPT

Post conversation analysis with GPT models

You can analyze a conversation after it has been finished using when construction of the language.

Just add code below as label.dsl in your project and write import "./label.dsl" in the main dsl file.

Notes:

  • You can manage labels, by setting label_descriptions variable as the conversation input.
  • If you have a warm transfer, pass option humanName to the connect/connectSafe(in the agent leg) and don't call #disableRecognition and you will be able to label whole conversation.
library // Sets labels that GPT can apply to conversations after an analysis. // These labels help in collecting and analyzing statistics from various conversations. // You are encouraged to add any additional labels that you may find relevant. // The name of a label will be an output after the conversation ends. The description helps GPT to accurately assign a label to the conversation. context { // control of the labeling isLabellingEnabled: boolean = true; input openAiApiKey: string? = null; input label_descriptions: { name: string; description: string; } [] = [ { name: "CallBack", description: "when the conversation ends with assistant saying they will call the user back later." } , { name: "Escalation", description: "when assistant escalated or transferred the call to a human agent." } , { name: "DontCall", description: "when human ask not call any more." } , { name: "NotInterested", description: "when user is not interested in the converstation." } ]; output labels: string[] = []; } block makeLabels(openAiApiKey: string?, label_descriptions: { name: string; description: string; } []): string[] { context { analyzePrompt: string = `Instructions: Analyze the following conversation between user and assistant and label it with the following possible labels: {{labels}} None: use this label in case of there are no appropriate labels. ---conversation log start--- {{transcription}} ---conversation log end--- Reply with one and more label using ',' as a separator. `; } start node root { do { var labels: string = ""; var result: string[] = []; for (var entry in $label_descriptions) { set labels += "\n" + entry.name + ": " + entry.description; } var responses = #getTranscription(options: { channelIds: [] } ); var hasResponses = false; for (var response in responses) { if (response.source != "ai") { set hasResponses = true; } } // checks if there was any response from the human if (!hasResponses) { result.push("None"); return result; } var transcription = #getFormattedTranscription(options: { channelIds: [] } ); var res = #askGPT($analyzePrompt, gptOptions: { model: "openai/gpt-4o-mini", openai_apikey: $openAiApiKey, function_call: "none", history_length: 0 } ); for (var label in res.responseText.split(",")) { result.push(label.trim()); } return result; } } } when exiting make_labels do { if(!$isLabellingEnabled) { return; } var newLabels = blockcall makeLabels($openAiApiKey, $label_descriptions); for (var x in newLabels) { $labels.push(x); } return; }
Found a mistake? Email us, and we'll send you a free t-shirt!

Enroll in beta

Request invite to our private Beta program for developers to join the waitlist. No spam, we promise.