Your bot will either need to send connection requests to external contacts, accept their incoming connection requests, or both, depending on what your workflow is. You can use the connections client's create or accept calls. If you want to accept connection requests as they arrive in real-time, you can create a connections listener and call accept with the incoming user id, but you will want to build some sort of governance to ensure that you are not accepting anyone who asks. You can validate against the incoming request's email, for example, and maybe restrict it to a domain name.
# Python BDK Example
class MyConnectionsListener(RealTimeEventListener):
def __init__(self, connections: ConnectionService):
self._connections = connections
async def on_connection_requested(self, initiator: V4Initiator, event: V4ConnectionRequested):
email = initiator.user.email
if (email.endswith("@my-trusted-bank.com")):
self._connections.accept_connection(initiator.user.user_id)
logging.info(f"Accepted connection request from {email}")
else:
logging.info(f"Rejected connection request from {email}")