Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

tessa_whatsapp_bot.env#875

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Akhil-ux-ux wants to merge1 commit intotwilio:main
base:main
Choose a base branch
Loading
fromAkhil-ux-ux:patch-1
Open
Changes fromall 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
44 changes: 44 additions & 0 deletionstessa_whatsapp_bot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse
import openai
import os
from dotenv import load_dotenv

# Load environment variables from .env
load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")

app = Flask(__name__) # ✅ Corrected: Use __name__ instead of name

@app.route("/whatsapp", methods=["POST"])
def whatsapp():
incoming_msg = request.values.get("Body", "").strip()

# Romantic AI girlfriend-like personality prompt
prompt = f"""
You are Tessa, an AI girlfriend. You are romantic, sweet, caring, and emotionally supportive.
You talk to the user like they're your partner, using soft language, nicknames like 'love', 'darling', 'sweetheart', and romantic emojis like ❤️😘😊.
Keep it loving but respectful. Never break character.

User: {incoming_msg}
Tessa:"""

# OpenAI API call
response = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt,
max_tokens=150,
temperature=0.9,
stop=["User:"]
)

bot_reply = response.choices[0].text.strip()

# Twilio WhatsApp response
twilio_response = MessagingResponse()
twilio_response.message(bot_reply)

return str(twilio_response)

if __name__ == "__main__": # ✅ Corrected: __name__ and "__main__"
app.run(debug=True)
Loading

[8]ページ先頭

©2009-2025 Movatter.jp