Last active
August 2, 2024 20:32
-
-
Save jeffehobbs/ccbfd314599dc8f2618d1c9292caf086 to your computer and use it in GitHub Desktop.
Goat2Meeting -- waste the caller's time via Twilio API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# goat2meeting.py | [email protected] | |
# waste the caller's time | |
import os, configparser | |
from flask import Flask | |
from twilio.twiml.voice_response import VoiceResponse | |
from openai import OpenAI | |
SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__)) | |
config = configparser.ConfigParser() | |
config.read(SCRIPT_PATH +'/secrets.txt') | |
OPENAI_API_KEY = config.get('openai', 'apikey') | |
MODEL = "gpt-4o-mini" | |
app = Flask(__name__) | |
@app.route("/answer", methods=['GET', 'POST']) | |
def answer_call(): | |
resp = VoiceResponse() | |
greeting = generate_text() | |
resp.say(greeting) | |
resp.record(playBeep=False) | |
resp.hangup() | |
return str(resp) | |
def generate_text(): | |
client = OpenAI( | |
api_key=OPENAI_API_KEY | |
) | |
chat_completion = client.chat.completions.create( | |
messages=[ | |
{ | |
"role": "user", | |
"content": "Say hello like you are picking up a phone, but say it in a way that wastes people's time. \ | |
Go off on weird digressions. Do not mention that you are wasting people's time. \ | |
Do mention that you are looking for your checkbook, or that you are having trouble hearing. \ | |
Make up a credit card number but leave off several digits. \ | |
Very occasionally, mention a goat that you knew when you were younger. \ | |
At the end of your statement, ask a question about the caller." | |
} | |
], | |
model="gpt-4o-mini", | |
) | |
response = chat_completion.choices[0].message.content | |
print(response) | |
return(response) | |
if __name__ == "__main__": | |
app.run(debug=True) | |
# fin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment