When to call Link?
Before your user can make authenticated tool calls, there must be credentials associated with the given user. There are two ways to gather credentials from a given user:- At query time using tool call - if your user prompts an action that requires interacting with a connector they have not authenticated to, your LLM will call the
authenticate_meta
tool for the given connector. Theauthenticate_meta
tool will respond with alinkToken
that must be used to open Merge Agent Handler Link and collect the connector credentials. - Ad-hoc using endpoint - if your user authenticates to the different systems they use prior to interacting with your agent. This method can be used if you have a Settings or Connectors page. You can call our
/link-token
API endpoint to get a linkToken, which can be used to open Merge Agent Handler Link and collect connector credentials.
How to call Link?
Step 1: Grab link token
As mentioned above, there are two ways to get a link token from Merge. It can be done through the calling of theauthenticate_meta
tool, or via the /link-token
endpoint.
- At query time using tool call:
linkToken
when the authenticate_meta
tool is called for a given user.
Sample code:
- Ad-hoc using endpoint:
link_token
from this URL:
URL: /api/registered-users/<registered-user-id>/link-token
POST Request Body:
Step 2: Make Merge Agent Handler Link appear in your product
In your frontend, use thelinkToken
from the step 1 to open Merge Agent Handler Link. The Merge Agent Handler react component can be found here.
Parameter | Type | Description |
---|---|---|
linkToken | string | Initializing token from step 1 |
onSuccess | function | Function you can define to signal when there is a successful authentication of the user |
onExit | function | Function you can define to signal when there is a failed authentication of the user |