Files
boss_dp/scripts/init_followup_config.py
2026-03-05 10:27:28 +08:00

148 lines
4.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
"""
初始化复聊配置示例数据
"""
import os
import sys
import django
# 设置 Django 环境
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
django.setup()
from server.models import FollowUpConfig, FollowUpScript
def create_followup_config():
"""创建复聊配置示例"""
print("=" * 60)
print("创建复聊配置")
print("=" * 60)
# 删除旧的测试配置
FollowUpConfig.objects.filter(name__contains="示例").delete()
# 创建Python开发的复聊配置
config = FollowUpConfig.objects.create(
name="Python开发复聊配置",
position="Python开发",
is_active=True
)
print(f"\n[OK] 创建配置: {config.name} (ID: {config.id})")
# 创建话术
scripts_data = [
{
"day_number": 1,
"content": "后续沟通会更及时,您方便留一下您的微信号吗?我这边加您。",
"interval_hours": 24,
"order": 1,
},
{
"day_number": 2,
"content": "您好,不知道您是否方便留个联系方式?我们这边项目很适合您。",
"interval_hours": 24,
"order": 1,
},
{
"day_number": 3,
"content": "您好,看到您的简历很符合我们的要求,期待与您进一步沟通。",
"interval_hours": 48,
"order": 1,
},
{
"day_number": 0, # 往后一直使用这个
"content": "您好,我们这边还在招聘中,如果您感兴趣可以联系我。",
"interval_hours": 72,
"order": 1,
},
]
for script_data in scripts_data:
script = FollowUpScript.objects.create(
config_id=config.id,
is_active=True,
**script_data
)
day_text = f"{script.day_number}" if script.day_number > 0 else "往后一直"
print(f" [OK] {day_text}: {script.content[:30]}... (间隔{script.interval_hours}小时)")
# 创建通用配置
print("\n" + "-" * 60)
general_config = FollowUpConfig.objects.create(
name="通用复聊配置",
position="通用",
is_active=True
)
print(f"[OK] 创建配置: {general_config.name} (ID: {general_config.id})")
general_scripts = [
{
"day_number": 1,
"content": "您好,期待与您进一步沟通,方便留个联系方式吗?",
"interval_hours": 24,
"order": 1,
},
{
"day_number": 0,
"content": "您好,如果您感兴趣可以随时联系我。",
"interval_hours": 48,
"order": 1,
},
]
for script_data in general_scripts:
script = FollowUpScript.objects.create(
config_id=general_config.id,
is_active=True,
**script_data
)
day_text = f"{script.day_number}" if script.day_number > 0 else "往后一直"
print(f" [OK] {day_text}: {script.content[:30]}... (间隔{script.interval_hours}小时)")
return config, general_config
def main():
print("\n" + "=" * 60)
print("BOSS招聘自动化 - 初始化复聊配置")
print("=" * 60 + "\n")
try:
config, general_config = create_followup_config()
print("\n" + "=" * 60)
print("初始化完成!")
print("=" * 60)
print("\n复聊配置说明:")
print("1. 第1天发送第一条话术")
print("2. 第2天如果没有回复发送第二条话术")
print("3. 第3天如果还没有回复发送第三条话术")
print("4. 往后:每隔配置的时间间隔,发送往后一直的话术")
print("\n使用方法:")
print("1. 通过 /api/followup-configs 查看和管理配置")
print("2. 通过 /api/followup-scripts 查看和管理话术")
print("3. 通过 /api/followup-records 查看复聊记录")
print("4. 运行招聘任务时会自动应用复聊配置")
print("\n自定义话术:")
print("- 可以通过API接口添加、修改、删除话术")
print("- 支持按岗位配置不同的复聊策略")
print("- 支持设置每条话术的间隔时间")
except Exception as e:
print(f"\n[ERROR] 错误: {e}")
import traceback
traceback.print_exc()
return 1
return 0
if __name__ == "__main__":
sys.exit(main())