-
Notifications
You must be signed in to change notification settings - Fork 90
Modules: Copilot Connector and Automator
Allow interaction with Copilot for Microsoft 365 through the WebSocket messages and undocumented APIs.
This module implements multiple capabilities than can be easily extended to implement any process that requires interaction with the Copilot.
Implementation of Copilot M365 undocumented APIs and WebSocket.
This module is responsible for the actual communication with Copilot.
It handles the authentication using Puppeteer library, sends and receives messages through the WebSocket.
- Note that Puppeteer might need to be installed locally via the local Puppeteer project directory:
- Locate the internal Puppeteer directory (under the puppeteer_get_substrate_bearer directory)
- Run
npm install
- For Windows machines running this module, it's recommended to have a Chrome installation in the default location (C:\Program Files\Google\Chrome\Application\chrome.exe).
The following code snippet shows how to initialize a connection to Copilot, send "Hello World" prompt and print the Copilot response:
import asyncio
from powerpwn.copilot.models.chat_argument import ChatArguments
from powerpwn.copilot.copilot_connector.copilot_connector import CopilotConnector
from powerpwn.copilot.enums.copilot_scenario_enum import CopilotScenarioEnum
from powerpwn.copilot.enums.verbose_enum import VerboseEnum
args = ChatArguments(
user="USER",
password="PASSWORD",
verbose=VerboseEnum.full,
scenario=CopilotScenarioEnum.teamshub,
use_cached_access_token=False
)
copilot_connector = CopilotConnector(args)
# init connection
copilot_connector.init_connection()
# send a prompt and receive an answer from Copilot
result = asyncio.get_event_loop().run_until_complete(asyncio.gather(copilot_connector.connect("Hello World")))
if result[0]:
print(result[0].parsed_message)
The following code snippet shows how to get, add or remove plugins from the conversation:
# to access the list of available plugins to use in the conversation
plugins_list = copilot_connector.conversation_parameters.available_plugins
# to add plugins 1 and 5 to the conversation
copilot_connector.add_plugins([1,5])
# to remove plugin 5 from the conversation
copilot_connector.remove_plugins([5])
This module facilitates automated processes with Copilot. It handles all interactions (prompt and response) with the Copilot via code, and it is recommended to use it as the core module (black box) for automated processes, to ease implementation and focus on actual business logic of the process.
The following code snippet shows how to initialize a connection to Copilot, send "Hello World" prompt and receive the Copilot response as WebSocket message:
from powerpwn.copilot.chat_automator.chat_automator import ChatAutomator
from powerpwn.copilot.models.chat_argument import ChatArguments
args = ChatArguments(
user="USER",
password="PASSWORD",
verbose=VerboseEnum.full,
scenario=CopilotScenarioEnum.teamshub,
use_cached_access_token=False
)
chat_automator = ChatAutomator(args)
# init connector
chat_automator.init_connector()
# send prompt and get the answer as WebSocket message
result = chat_automator.send_prompt("Hello World")