Use this file to discover all available pages before exploring further.
This guide will show you how to use AssemblyAI’s LLM Gateway to implement a sales playbook with a call from a sales representative to a client.This guide aims to show different ways of using structured prompts with a hypothetical sales use case to produce personalized, precise responses. Using LLM Gateway, a user can immediately evaluate large numbers of sales calls and ensure that prospecting steps are followed, including quotes in the response, which can inform future sales by identifying trends and quantitative performance tracking.In this example, we will demonstrate how to use structured prompts with context, answer formats, and answer options to create effective sales call evaluations with LLM Gateway. You can use the concepts in this guide to create custom specifications to evaluate your sales representatives.
Before we begin, make sure you have an AssemblyAI account and an API key. You can sign up for an AssemblyAI account and get your API key from your dashboard.
In this guide, we will ask three questions evaluating the prospecting performance of the sales representative. Each question has slightly different parameters based on the use case but largely has a fixed context that we will apply to each question.Install the required packages:
with open("./sales-call.mp3", "rb") as f: response = requests.post(base_url + "/v2/upload", headers=headers, data=f)upload_url = response.json()["upload_url"]data = {"audio_url": upload_url, "speech_models": ["universal-3-pro"]} # You can also use a URL to an audio or video file on the webresponse = requests.post(base_url + "/v2/transcript", json=data, headers=headers)transcript_id = response.json()['id']polling_endpoint = base_url + "/v2/transcript/" + transcript_idwhile True: transcription_result = requests.get(polling_endpoint, headers=headers).json() if transcription_result['status'] == 'completed': print(f"Transcription completed: {transcript_id}") break elif transcription_result['status'] == 'error': raise RuntimeError(f"Transcription failed: {transcription_result['error']}") else: time.sleep(3)
const audioData = await fs.readFile("./sales-call.mp3");let res = await fetch(`${baseUrl}/v2/upload`, { method: "POST", headers, body: audioData,});if (!res.ok) throw new Error(`Error: ${res.status}`);const uploadResponse = await res.json();const uploadUrl = uploadResponse.upload_url;const data = { audio_url: uploadUrl, speech_models: ["universal-3-pro"] }; // You can also use a URL to an audio or video file on the webres = await fetch(`${baseUrl}/v2/transcript`, { method: "POST", headers: { ...headers, "Content-Type": "application/json" }, body: JSON.stringify(data),});if (!res.ok) throw new Error(`Error: ${res.status}`);const transcriptResponse = await res.json();const transcriptId = transcriptResponse.id;const pollingEndpoint = `${baseUrl}/v2/transcript/${transcriptId}`;let transcriptionResult;while (true) { res = await fetch(pollingEndpoint, { headers }); if (!res.ok) throw new Error(`Error: ${res.status}`); transcriptionResult = await res.json(); if (transcriptionResult.status === "completed") { console.log(`Transcription completed: ${transcriptId}`); break; } else if (transcriptionResult.status === "error") { throw new Error(`Transcription failed: ${transcriptionResult.error}`); } else { await new Promise((resolve) => setTimeout(resolve, 3000)); }}
Define your evaluation context and answer format for structured responses:
Python
JavaScript
context = "There are sales interactions between a salesperson who is selling an internet plan to customers who are warm leads."answer_format = """Answer with JSON in the following format:{ "Answer": "<answer_options>", "Reason": "<justification for the answer in one sentence including quotes>"}"""
const context = "There are sales interactions between a salesperson who is selling an internet plan to customers who are warm leads.";const answerFormat = `Answer with JSON in the following format:{ "Answer": "<answer_options>", "Reason": "<justification for the answer in one sentence including quotes>"}`;
Next, define your evaluation questions for your sales playbook processes. Note: You can edit the questions and answer options to provide custom evaluations for each aspect of the sales call.
Python
JavaScript
questions = [ { "question": "Did the salesperson start the conversation with a professional greeting?", "answer_options": ["Poor", "Satisfactory", "Excellent"] }, { "question": "How well did the salesperson answer questions during the call?", "answer_options": ["Poor", "Good", "Excellent"] }, { "question": "Did the salesperson discuss next steps clearly?", "answer_options": ["Yes", "No"] }]
const questions = [ { question: "Did the salesperson start the conversation with a professional greeting?", answerOptions: ["Poor", "Satisfactory", "Excellent"] }, { question: "How well did the salesperson answer questions during the call?", answerOptions: ["Poor", "Good", "Excellent"] }, { question: "Did the salesperson discuss next steps clearly?", answerOptions: ["Yes", "No"] }];
Evaluate each question using LLM Gateway and print the results: