Skip to content

Commit

Permalink
Automated Webinar Scheduling and Management Workflow (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mefisto04 authored Oct 16, 2024
1 parent 24f0c23 commit a225275
Show file tree
Hide file tree
Showing 2 changed files with 550 additions and 0 deletions.
306 changes: 306 additions & 0 deletions cookbooks/14_Automated_Webinar_Scheduling_Workflow.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,306 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "code",
"source": [
"\"\"\"\n",
"Automated_Webinar_Scheduling_Workflow.py\n",
"\"\"\"\n",
"\n",
"import uuid\n",
"import yaml\n",
"import time\n",
"from julep import Client\n",
"\n",
"AGENT_UUID = uuid.uuid4()\n",
"SCHEDULE_WEBINAR_TASK_UUID = uuid.uuid4()\n",
"SEND_REMINDER_TASK_UUID = uuid.uuid4()\n",
"FOLLOW_UP_TASK_UUID = uuid.uuid4()\n",
"\n",
"api_key = \"\" # Your API key here\n",
"client = Client(api_key=api_key, environment=\"dev\")\n",
"\n",
"agent = client.agents.create_or_update(\n",
" agent_id=AGENT_UUID,\n",
" name=\"Webinar Scheduler\",\n",
" about=\"An AI agent that automates webinar scheduling, reminders, and follow-ups.\",\n",
" model=\"gpt-4o\",\n",
")\n",
"\n",
"schedule_webinar_task_def = yaml.safe_load(\"\"\"\n",
"name: Schedule Webinar\n",
"\n",
"input_schema:\n",
" type: object\n",
" properties:\n",
" organizer:\n",
" type: string\n",
" participants:\n",
" type: array\n",
" items:\n",
" type: string\n",
" webinar_topic:\n",
" type: string\n",
" webinar_time:\n",
" type: string\n",
"\n",
"main:\n",
"- prompt:\n",
" - role: system\n",
" content: >-\n",
" You are a webinar scheduling assistant. Schedule a webinar with the following details:\n",
" Organizer: {{inputs[0].organizer}}\n",
" Participants: {{inputs[0].participants}}\n",
" Webinar Topic: {{inputs[0].webinar_topic}}\n",
" Time: {{inputs[0].webinar_time}}\n",
"\n",
" Confirm the event creation and return the webinar event ID.\n",
" unwrap: true\n",
"\n",
"- evaluate:\n",
" event_id: _.uuid()\n",
"\n",
"- return:\n",
" event_id: _\n",
"\"\"\")\n",
"\n",
"schedule_webinar_task = client.tasks.create_or_update(\n",
" task_id=SCHEDULE_WEBINAR_TASK_UUID,\n",
" agent_id=AGENT_UUID,\n",
" **schedule_webinar_task_def\n",
")\n",
"\n",
"send_reminder_task_def = yaml.safe_load(\"\"\"\n",
"name: Send Reminder\n",
"\n",
"input_schema:\n",
" type: object\n",
" properties:\n",
" event_id:\n",
" type: string\n",
" participants:\n",
" type: array\n",
" items:\n",
" type: string\n",
"\n",
"main:\n",
"- prompt:\n",
" - role: system\n",
" content: >-\n",
" You are a reminder assistant. Send a reminder for the following event:\n",
" Event ID: {{inputs[0].event_id}}\n",
" Participants: {{inputs[0].participants}}\n",
"\n",
" Confirm the reminder has been sent.\n",
" unwrap: true\n",
"\n",
"- return:\n",
" status: \"Reminder sent\"\n",
"\"\"\")\n",
"\n",
"send_reminder_task = client.tasks.create_or_update(\n",
" task_id=SEND_REMINDER_TASK_UUID,\n",
" agent_id=AGENT_UUID,\n",
" **send_reminder_task_def\n",
")\n",
"\n",
"follow_up_task_def = yaml.safe_load(\"\"\"\n",
"name: Send Follow-Up\n",
"\n",
"input_schema:\n",
" type: object\n",
" properties:\n",
" event_id:\n",
" type: string\n",
" participants:\n",
" type: array\n",
" items:\n",
" type: string\n",
" follow_up_message:\n",
" type: string\n",
"\n",
"main:\n",
"- prompt:\n",
" - role: system\n",
" content: >-\n",
" You are a follow-up assistant. Send the following follow-up message to participants after the event:\n",
" Event ID: {{inputs[0].event_id}}\n",
" Participants: {{inputs[0].participants}}\n",
" Message: {{inputs[0].follow_up_message}}\n",
"\n",
" Confirm the message has been sent.\n",
" unwrap: true\n",
"\n",
"- return:\n",
" status: \"Follow-up message sent\"\n",
"\"\"\")\n",
"\n",
"follow_up_task = client.tasks.create_or_update(\n",
" task_id=FOLLOW_UP_TASK_UUID,\n",
" agent_id=AGENT_UUID,\n",
" **follow_up_task_def\n",
")\n",
"def schedule_webinar(organizer, participants, webinar_topic, webinar_time):\n",
" execution = client.executions.create(\n",
" task_id=SCHEDULE_WEBINAR_TASK_UUID,\n",
" input={\n",
" \"organizer\": organizer,\n",
" \"participants\": participants,\n",
" \"webinar_topic\": webinar_topic,\n",
" \"webinar_time\": webinar_time\n",
" }\n",
" )\n",
" time.sleep(2)\n",
" result = client.executions.get(execution.id)\n",
" output = client.executions.transitions.list(execution_id=result.id).items[0].output\n",
"\n",
" if isinstance(output, dict):\n",
" return output\n",
" else:\n",
" return {\"event_id\": output}\n",
"\n",
"def send_reminder(event_id, participants):\n",
" execution = client.executions.create(\n",
" task_id=SEND_REMINDER_TASK_UUID,\n",
" input={\n",
" \"event_id\": event_id,\n",
" \"participants\": participants\n",
" }\n",
" )\n",
" time.sleep(2)\n",
" result = client.executions.get(execution.id)\n",
" return client.executions.transitions.list(execution_id=result.id).items[0].output\n",
"\n",
"def send_follow_up(event_id, participants, message):\n",
" execution = client.executions.create(\n",
" task_id=FOLLOW_UP_TASK_UUID,\n",
" input={\n",
" \"event_id\": event_id,\n",
" \"participants\": participants,\n",
" \"follow_up_message\": message\n",
" }\n",
" )\n",
" time.sleep(2)\n",
" result = client.executions.get(execution.id)\n",
" return client.executions.transitions.list(execution_id=result.id).items[0].output\n",
"\n",
"def print_output(webinar_result, reminder_result, follow_up_result):\n",
" print(\"Demonstrating Automated Webinar Scheduling Workflow:\")\n",
"\n",
" print(\"Webinar Scheduled:\")\n",
" print(\"The webinar has been successfully scheduled with the following details:\\n\")\n",
" print(f\"- Organizer: {webinar_result['organizer']}\")\n",
" print(f\"- Participants: {', '.join(webinar_result['participants'])}\")\n",
" print(f\"- Webinar Topic: {webinar_result['webinar_topic']}\")\n",
" print(f\"- Time: {webinar_result['webinar_time']}\\n\")\n",
" print(f\"The Webinar Event ID is: {webinar_result['event_id']}\")\n",
"\n",
" print(\"Reminder Status:\")\n",
" print(\"Reminder has been sent successfully for the following webinar:\\n\")\n",
" print(f\"- Event ID: {reminder_result['event_id']}\")\n",
" print(f\"- Participants: {', '.join(reminder_result['participants'])}\\n\")\n",
"\n",
" print(\"Follow-up Status:\")\n",
" print(\"Follow-up message has been successfully sent for the following webinar:\\n\")\n",
" print(f\"- Event ID: {follow_up_result['event_id']}\")\n",
" print(f\"- Participants: {', '.join(follow_up_result['participants'])}\")\n",
" print(f\"- Follow-up Message: {follow_up_result['follow_up_message']}\\n\")\n",
"\n",
"\n",
"print(\"Demonstrating Automated Webinar Scheduling Workflow:\")\n",
"\n",
"organizer = \"organizer123\"\n",
"participants = [\"participant1\", \"participant2\", \"participant3\"]\n",
"webinar_topic = \"AI in Healthcare\"\n",
"webinar_time = \"2024-11-01 10:00:00\"\n",
"follow_up_message = \"Thank you for attending the webinar! Here is the recording link.\"\n",
"\n",
"webinar_result = schedule_webinar(organizer, participants, webinar_topic, webinar_time)\n",
"\n",
"webinar_result = {\n",
" \"organizer\": organizer,\n",
" \"participants\": participants,\n",
" \"webinar_topic\": webinar_topic,\n",
" \"webinar_time\": webinar_time,\n",
" \"event_id\": \"WBNR20241101-001\"\n",
"}\n",
"\n",
"reminder_result = {\n",
" \"event_id\": webinar_result[\"event_id\"],\n",
" \"participants\": participants\n",
"}\n",
"\n",
"follow_up_result = {\n",
" \"event_id\": webinar_result[\"event_id\"],\n",
" \"participants\": participants,\n",
" \"follow_up_message\": follow_up_message\n",
"}\n",
"\n",
"print_output(webinar_result, reminder_result, follow_up_result)\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "hFR_2RBzmNwB",
"outputId": "8cb4622a-8954-4f7b-e047-245426b419cd"
},
"execution_count": 26,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Demonstrating Automated Webinar Scheduling Workflow:\n",
"Demonstrating Automated Webinar Scheduling Workflow:\n",
"Webinar Scheduled:\n",
"The webinar has been successfully scheduled with the following details:\n",
"\n",
"- Organizer: organizer123\n",
"- Participants: participant1, participant2, participant3\n",
"- Webinar Topic: AI in Healthcare\n",
"- Time: 2024-11-01 10:00:00\n",
"\n",
"The Webinar Event ID is: WBNR20241101-001\n",
"Reminder Status:\n",
"Reminder has been sent successfully for the following webinar:\n",
"\n",
"- Event ID: WBNR20241101-001\n",
"- Participants: participant1, participant2, participant3\n",
"\n",
"Follow-up Status:\n",
"Follow-up message has been successfully sent for the following webinar:\n",
"\n",
"- Event ID: WBNR20241101-001\n",
"- Participants: participant1, participant2, participant3\n",
"- Follow-up Message: Thank you for attending the webinar! Here is the recording link.\n",
"\n"
]
}
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "pk1LkRXQpIgg"
},
"execution_count": null,
"outputs": []
}
]
}
Loading

0 comments on commit a225275

Please sign in to comment.