Connection to Our TSG Connector

Example: Connection to our TSG connector

Last update: 2024-01-27

This request sets up a connection to your TSG connector by loading environment variables from an .env file and initializing a TSGController instance with the provided API key, connector ID, access URL, and agent ID.

The following operations are demonstrated:

  1. Load environment variables (your connector configs) from a .env file.

  2. Establish a connection to your TSG connector.

  3. Print connection details.

Important

  • Ensure that the required environment variables (Your Connector API_KEY, CONNECTOR_ID, ACCESS_URL and AGENT_ID) are set in the .env file before using this request.

  • The connector API_KEY can be retrieved by loging into the TSG connector UI and navigating to the ‘API Keys’ tab.

Execute the code below to set up a connector to your TSG Connector.

 1if __name__ == "__main__":
 2    from loguru import logger
 3    from dotenv import dotenv_values
 4    from tsg_client.controllers import TSGController
 5
 6    # Comment the line below to enable internal logger:
 7    logger.disable("")
 8
 9    # Load environment variables:
10    config = dotenv_values('.env')
11
12    # Set up the TSG connector:
13    conn = TSGController(
14        api_key=config['API_KEY'],
15        connector_id=config['CONNECTOR_ID'],
16        access_url=config['ACCESS_URL'],
17        agent_id=config['AGENT_ID']
18    )
19
20    print("Successfully connected to the TSG connector!")
21    print(conn)  # print connection details