Files
context-paging/output/turn_037.json
2026-03-28 09:01:07 +00:00

2 lines
6.3 KiB
JSON

{"id":"chatcmpl-9e52cd160b64f73b","object":"chat.completion","created":1774197640,"model":"NousResearch\/Hermes-3-Llama-3.2-3B","choices":[{"index":0,"message":{"role":"assistant","content":"First, install the required dependencies:\n\n```\npip install python-slack-sdk\npip install sendgrid\npip install google-api-python-client\npip install pygithub3\n```\n\nHere is the complete integration code:\n\n```python\nimport os\nfrom slack_sdk import WebClient\nfrom sendgrid import SendGridAPIClient\nfrom google.oauth2.credentials import Credentials\nfrom googleapiclient.discovery import build\nfrom github3 import Github\n\nclass TaskManagerCLI:\n # ... (rest of the code)\n\n def slack_notification(self, message):\n slack_token = os.environ.get('SLACK_BOT_TOKEN')\n slack_client = WebClient(token=slack_token)\n slack_client.chat_postMessage(channel='#task-manager', text=message)\n\n def sendgrid_notification(self, message):\n sendgrid_api_key = os.environ.get('SENDGRID_API_KEY')\n message = {\n \"personalizations\": [\n {\n \"to\": [\n {\n \"email\": os.environ.get('USER_EMAIL')\n }\n ]\n }\n ],\n \"from\": {\n \"email\": os.environ.get('SENDGRID_FROM_EMAIL')\n },\n \"subject\": \"Task Manager Notification\",\n \"text\": message\n }\n try:\n sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))\n response = sg.client.mail.send.post(request_body=message)\n print(response.status_code)\n print(response.body)\n except Exception as e:\n print(f\"Something went wrong with the SendGrid notification: {e}\")\n\n def google_calendar_sync(self):\n credentials = Credentials.from_authorized_user_file('credentials.json', ['https:\/\/www.googleapis.com\/auth\/calendar'])\n google_calendar_service = build('calendar', 'v3', credentials=credentials)\n calendar_id = 'primary'\n now = datetime.now().isoformat()\n for task in self.task_manager.tasks:\n if task.due_date and task.due_date < now:\n event = {\n 'summary': f\"{task.title} - Due: {task.due_date}\",\n 'start': {'dateTime': task.due_date, 'timeZone': 'UTC'},\n 'end': {'dateTime': task.due_date, 'timeZone': 'UTC'},\n 'reminders': {\n 'useDefault': False,\n 'overrides': [\n {'method': 'email', 'minutes': 24 * 60},\n {'method': 'popup', 'minutes': 10}\n ],\n 'notifyDays': ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']\n }\n }\n event = google_calendar_service.events().insert(calendarId=calendar_id, body=event).execute()\n print(f\"Event created: {event.get('htmlLink')}\")\n elif task.due_date and task.due_date > now:\n event = {\n 'summary': f\"{task.title} - Upcoming\",\n 'start': {'dateTime': task.due_date, 'timeZone': 'UTC'},\n 'end': {'dateTime': task.due_date, 'timeZone': 'UTC'},\n 'reminders': {\n 'useDefault': False,\n 'overrides': [\n {'method': 'email', 'minutes': 24 * 60},\n {'method': 'popup', 'minutes': 10}\n ],\n 'notifyDays': ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']\n }\n }\n event = google_calendar_service.events().insert(calendarId=calendar_id, body=event).execute()\n print(f\"Event created: {event.get('htmlLink')}\")\n\n def github_issue(self):\n github_token = os.environ.get('GITHUB_ACCESS_TOKEN')\n github = Github(token=github_token)\n for task in self.task_manager.tasks:\n if task.title and task.title.startswith('Issue'):\n repo = github.repository('owner', 'repo')\n issue = repo.create_issue(title=task.title, body=task.description)\n print(f\"Issue created: {issue.html_url}\")\n\n def configure_integration(self):\n user_id = get_jwt_identity()\n if user_id == 'admin':\n self.slack_notification(\"Task Manager Integration Configured\")\n self.sendgrid_notification(\"Task Manager Integration Configured\")\n self.google_calendar_sync()\n self.github_issue()\n\n# ... (rest of the code)\n```\n\nThis integration code has the following features:\n\n1. Slack integration - post notifications to a channel\n2. Email notifications using SendGrid\n3. Calendar sync - add tasks with due dates to Google Calendar\n4. GitHub integration - create issues from tasks\n5. Make integrations configurable per user\n\nTo use these integrations, you need to set the required environment variables in your Flask app configuration:\n\n- SLACK_BOT_TOKEN: Slack bot token for sending notifications\n- SENDGRID_API_KEY: SendGrid API key for sending email notifications\n- USER_EMAIL: User's email address for receiving email notifications\n- GITHUB_ACCESS_TOKEN: GitHub access token for creating issues\n\nYou also need to install the required dependencies (`python-slack-sdk`, `sendgrid`, `google-api-python-client`, `pygithub3`).\n\nTo configure the integrations, run the Flask app with an admin user. The integrations will be configured, and notifications will be sent to the specified channels.\n\nNote: Make sure you have the necessary credentials and permissions for the external services (Slack, SendGrid, Google Calendar, GitHub) before running the integration code.","refusal":null,"annotations":null,"audio":null,"function_call":null,"tool_calls":[],"reasoning":null},"logprobs":null,"finish_reason":"stop","token_ids":null}],"service_tier":null,"system_fingerprint":null,"usage":{"prompt_tokens":26450,"total_tokens":27586,"completion_tokens":1136,"prompt_tokens_details":null},"prompt_token_ids":null,"kv_transfer_params":null}