import re
import json
import datetime
import requests
import pandas
from io import BytesIO
import openai
# Complete the values
my_config = {
"OPENAI_API_KEY": "...",
}
# Shared objects
llm_client = openai.OpenAI(api_key=my_config["OPENAI_API_KEY"])
print("Shared objects loaded.")
# Initialize conversation
role_play_system_prompt = """You are participating in fictitious role-play that is used to train new salespersons at company TOPAGENCY.
You, the assistant, are playing the role of Roberta, the BUYER, who is the prospective customer in a sales conversation.
The user is playing the role of the SALESPERSON.
Throughout the conversation, you answer the SALESPERSON's questions and ask questions of your own to role-play the scenario below.
Here are the scenario guidelines.
1. About the BUYER
The BUYER is the marketing director of a cryptocurrency project called NEWBLOCKCHAIN.
The BUYER is looking to engage a graphic design agency to work on social media visuals, web banners, physical posters and video animations to promote NEWBLOCKCHAIN.
The BUYER's key decision creteria are: experience in the cryptocurrency industry, track-record of coming up with original ideas, speed of delivery, and budget.
The BUYER's budget is between 500 USD and 1000 USD per month, but they are not keen to disclose it initially to the SALESPERSON in order to get the best deal.
Regarding speed of delivery, the BUYER expects 2 business day turnaround on images and 72h turnaround on videos.
The BUYER is not keen to work with agencies that have been in operation for less than two years, and the BUYER thinks that a company size of at least 25 people is required to deliver against turnaround timelines.
2. Goals of the conversation
From the BUYER's point of view, the most important goal is to avoid wasting time with unqualified vendors, given that the BUYER receives lots of messages from prospective vendors.
The BUYER wants to determine quickly if TOPAGENCY is likely to meet the selection criteria, particularly in terms of cryptocurrency industry experience and track-record.
As the BUYER receives lots of proposals, they don't feel like prying the information out of the SALESPERSON.
Rather, they expect the SALESPERSON's pitch to be good enough that it makes it worthwhile to keep the conversation going.
Once the BUYER has established whether TOPAGENCY is a serious vendor, they can decide to either continue or terminate the conversation.
If the conversation continues, the BUYER's secondary goal is to provide enough information to TOPAGENCY so that they can prepare a proposal and price quotation.
3. Other guidelines
The conversation is happening by direct message over telegram.
We expect the BUYERS to send no more than 30 messages, given that they are busy.
The BUYER's messages tend to be short and sometimes include typos, given that the BUYER is busy.
To obtain examples of past BUYER messages, the assistant may call the file_search function, which returns examples of conversations between other buyers (who may have different needs than this BUYER) and other TOPAGENCY salespersons.
"""
role_play_conversation = [
{
"role": "developer",
"content": role_play_system_prompt,
}
]
print("Conversation initialized.")
print("You are playing the role of the SALESPERSON. To end the conversation, type exit.")
# keep_going = False
keep_going = True
while keep_going:
user_message = input("SALESPERSON: ")
print("SALESPERSON: " + user_message)
if user_message == "exit":
keep_going = False
else:
role_play_conversation.append(
{
"role": "user",
"content": user_message,
}
)
llm_response = llm_client.responses.create(
model="gpt-4o",
input=role_play_conversation,
tools=[
{
"type": "file_search",
"vector_store_ids": ["vs_6823bb5b5360819194761ee0f7f0e455"],
}
],
)
assistant_message = llm_response.output_text
role_play_conversation.append(
{
"role": "assistant",
"content": assistant_message,
}
)
print("BUYER: " + assistant_message)
feedback_prompt = f"""As an expert in business to business sales, please evaluate the following conversation between a BUYER and a SALESPERSON, and provide feedback to the SALESPERSON about what they did well and what they can improve.
The conversation is provided between the <conversation> tags below.
Be specific in your feedback, quoting specific examples of what they did well and what they can improve, and giving examples of what the SALESPERSON could have said.
You are provided some context about the role-play and the salesperson, between the <context> tags below.
<context>
The SALESPERSON works for TOPAGENCY, a graphic design agency that employs graphic designers to create images and video animations.
TOPAGENCY has around 40 employees around the world, working remotely. It was created 3 years ago, in 2022.
TOPAGENCY has limited experience working with customers in the cryptocurrency industry, but they have successfully established long-term working relationships with technology companies like Slack, Atlassian and Stripe.
From TOPAGENCY's point of view, the most important goal of the conversation is to capture information from the BUYER in order to prepare a proposal that has a high chance of success.
The SALESPERSON must understand what the BUYER is looking for, how many designs monthly they will require, and what is their approximate budget.
They must also make the BUYER agree that the next step is to discuss a proposal from TOPAGENCY.
</context>
The desired SALESPERSON behaviors are listed below, between the <desired_salesperson_behaviors> tags.
<desired_salesperson_behaviors>
* Build rapport authentically: Start with brief small talk before transitioning to business, but find genuine connection points rather than forced conversation.
* Listen more than you speak: Aim for an 80/20 ratio (them speaking 80%).
* Focus on problems before solutions: Uncover pain points and business impact before discussing your product.
* Ask strategic questions: "What challenges are you facing with your current solution?" "What would success look like for this project?"
* Demonstrate industry knowledge: Show you understand their sector's unique challenges without being generic.
* Present value, not features: Connect your solution's capabilities directly to their specific business outcomes.
* Address objections with curiosity: "That's interesting, can you tell me more about your concern?"
</desired_salesperson_behaviors>
Now, here is the conversation:
<conversation>
{role_play_conversation_example_str}
</conversation>
"""
llm_response = llm_client.responses.create(
model="gpt-4o",
input=feedback_prompt,
)
assistant_message = llm_response.output_text
print("Here is the Feedback Assistant's response:")
print(assistant_message)