Connections
Learn how to connect with third-party tools and services in your BDK project.
Implementing Connections
Connections enable you to connect to third-party tools and services in your custom Book. To implement a connection, define a Python function in your Book class and decorate it with the @connect decorator. This decorated function serves as the connection handler and defines the syntax for writing a connection command.
Note: Implementing an OAuth connection in a custom BDK Book is not supported at this time.
Multiple Connections
You can define multiple connections within a Book, each with its own handler method. Use the noun_phrase
keyword argument in the @connect decorator to assign a unique label to each connection and differentiate between authentication methods.
Method Docstrings
In your connection method docstring, include the following sections in addition to a brief summary:
1. Arguments
Specify the Python function's parameters.
2. Labels
Define labels for the connection arguments (e.g., API key, credentials) that will be used in your connection command. Labels correspond to parameters in your function's definition.
When a label is provided in the docstring, the lowercase form is used in a connection command. When not provided, the label will be inferred from the Python variable name.
Example
In this example, API Key
is the label for the api_key
connection argument. The lowercase version of the label is used in a connection command (api key
):
Additional Examples
api_key: ApI kEy
In this example, the connection command uses the lowercase form of ApI kEy
:
api_key: aPi_KeY
In this example, the connection command uses the lowercase version of aPi_KeY
:
No Label
If a label is not provided in the docstring, it is inferred from the Python variable name, api_key
:
Last updated
Was this helpful?