def generate_log()

in ccai-insights-sample-data/generate-call-logs.py [0:0]


def generate_log():
    # Select a device that the user is having trouble with
    device = random.choice(devices)

    # Generate timestamps within the last 30 days in microseconds of epoch time
    dt = datetime.datetime.today() - random.random() * datetime.timedelta(days=30)
    timestamp = int(round(dt.timestamp()) * 1e6)
    response_delay = int(random.randint(10, 30) * 1e6)

    # Generate JSON object of conversation
    call_log = {
        "entries": [
            {
                "start_timestamp_usec": timestamp + response_delay * 0,
                "text": random.choice(greetings),
                "role": "AGENT",
                "user_id": 2,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 1,
                "text": "Hi, I'm having an issue with my " + device,
                "role": "CUSTOMER",
                "user_id": 1,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 2,
                "text": "Sorry to hear. Can you tell me what the problem is?",
                "role": "AGENT",
                "user_id": 2,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 3,
                "text": random.choice(problems).format(device),
                "role": "CUSTOMER",
                "user_id": 1,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 4,
                "text": "Can you give me more details about the problem with your {0}?".format(device),
                "role": "AGENT",
                "user_id": 2,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 5,
                "text": random.choice(problem_detail).format(device),
                "role": "CUSTOMER",
                "user_id": 1,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 6,
                "text": "And what is the status shown in the settings on the {0}?".format(device),
                "role": "AGENT",
                "user_id": 2,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 7,
                "text": random.choice(statuses),
                "role": "CUSTOMER",
                "user_id": 1,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 8,
                "text": "Can you tell me your account number?",
                "role": "AGENT",
                "user_id": 2,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 9,
                "text": "Sure, it's " + str(random.randint(100000000, 999999999)),
                "role": "CUSTOMER",
                "user_id": 1,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 10,
                "text": random.choice(solutions).format(device),
                "role": "AGENT",
                "user_id": 2,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 11,
                "text": "I see, thanks for the information, I will give that a try.",
                "role": "CUSTOMER",
                "user_id": 1,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 12,
                "text": random.choice(check_solved),
                "role": "AGENT",
                "user_id": 2,
            },
            {
                "start_timestamp_usec": timestamp + response_delay * 13,
                "text": random.choice(problem_solved).format(device),
                "role": "CUSTOMER",
                "user_id": 1,
            },
        ]
    }

    json_object = json.dumps(call_log, indent=4)
    return json_object