JS SDK Reference
This reference documents every object and method available in Integry’s browser-side JavaScript library, Integry.js.
Setting Up
Including Integry.js
To use the Integry JS SDK, you need to include it in your project. You can install it via npm:
Or include it via a script tag:
Authentication
The Integry JS SDK requires an App-Key
and a hash of App-Secret
and User-ID
to authenticate calls.
You can view and copy your App-Key
and App-Secret
from the Integry app.
User-ID
is a unique string identifier for a user in your app. Function Calls and Integrations are associated to a user ID.
If your app has workspaces/accounts and you want integrations to be shared across all users in a workspace/account, use the workspace/account ID as the user ID.
Calculating the hash
Calculate the hash server-side using HMAC SHA256.
Initializing IntegryJS()
Call IntegryJS(authentication)
with theApp-Key
, computed hash and User-ID
to create an instance of the Integry object.
Emits event
This method emits a ready
event if the access credentials are valid.
Listening to Events
Some SDK methods emit events (eg. ready
, app-connected
) that you can leverage to manipulate the user journey.
Subscribe to an event
Call eventEmitter.on('<event_name>')
method.
Events emitted by the SDK are scoped to the instance on which the eventEmitter
object is configured. There is no possibility of naming collision with global events, or even with the same event subscribed on multiple SDK instances.
Unsubscribe from an event
Call eventEmitter.unsub('<event_name>')
method.
Error Handling
All methods in the Integry JS SDK return Promises
. It is recommended to always include .catch()
to handle errors gracefully. Here is an example:
Apps
Integry supports many apps like Slack, Hubspot, or Jira.
Show apps
showApps(renderMode, containerID, layout)
Renders a marketplace-style listing of apps. You can customize the render mode, layouts and styling.
Note: If you want to directly connect an app, use connectApp()
.
Method parameters
renderMode
string
Specifies the mode in which the marketplace will be rendered. Allowed values: IntegryJS.RenderModes.MODAL
, IntegryJS.RenderModes.INLINE
. Defaults to MODAL
if not specified.
false
containerId
string
The ID of the HTML container in which the marketplace content will be rendered.
true if renderMode=IntegryJS.RenderModes.INLINE
layout
string
Specifies the layout. Allowed values: IntegryJS.Layouts.WIDE
, IntegryJS.Layouts.NARROW
. Defaults to WIDE
if not specified.
false
Emits events
app-connected
Fired when the user successfully connects an app. It includes the app details along with an array of connected_accounts
sorted by modified_at
in descending order.
app-disconnected
Fired when the user disconnects an app. It includes the app details along with an array of remaining connected_accounts
(if any) sorted by modified_at
in descending order.
Show an app
showApp(appName, renderMode, containerID, layout)
Renders the app page with connected accounts and flows. You can customize the render mode, layouts and styling.
Method parameters
appName
string
Name of the app to show. Eg. Hubspot
true
renderMode
string
Specifies the mode in which the marketplace will be rendered. Allowed values: IntegryJS.RenderModes.MODAL
, IntegryJS.RenderModes.INLINE
. Defaults to MODAL
if not specified.
false
containerId
string
The ID of the HTML container in which the marketplace content will be rendered.
true if renderMode=IntegryJS.RenderModes.INLINE
layout
string
Specifies the layout. Allowed values: IntegryJS.Layouts.WIDE
, IntegryJS.Layouts.NARROW
. Defaults to WIDE
if not specified.
false
Emits events
app-connected
Fired when the user successfully connects an app. It includes the app details along with an array of connected_accounts
sorted by modified_at
in descending order.
app-disconnected
Fired when the user disconnects an app. It includes the app details along with an array of remaining connected_accounts
(if any) sorted by modified_at
in descending order.
Connect an app
connectApp(appName)
Invokes a UI flow to prompt the user to authenticate with the specified app. After the user connects, Integry verifies that it can access their account. It also refreshes the token, if needed.
Use this to connect apps if you are not using showApps() .
Method parameters
appName
string
The name of the app you want the user to connect.
slack
true
Returns
This method returns a connectedAccountId
(string).
If you use connectApp()
to enable your users to connect multiple accounts for an app, you will need to use this ID when you disconnectApp(), showFunctionUI() and invokeFunction().
Disconnect an app
disconnectApp(appName, connectedAccountId)
Disconnects the user's connected account for an app.
Method parameters
appName
string
The name of the app to disconnect.
slack
true
connectedAccountId
string
The ID of the connected account to delete.
1234
true if the user has multiple connected accounts of this app
Returns
This method returns a Promise
which resolves if the account is disconnected.
Check if app is connected
isAppConnected(appName)
Checks if the user has connected the specified app.
Method parameters
appName
string
The name of the app.
slack
true
Returns
This method returns a boolean result
. It will be true if the user has one (or more) connected account(s) with this app.
If your users have connected multiple accounts, use getConnectedAccounts() to get their IDs.
Get connected accounts of an app
getConnectedAccounts(appName)
Returns a user's connected accounts for an app.
Method parameters
appName
string
The name of the app.
slack
true
Returns
This method returns an array of connected_accounts
.
Show connected accounts of an app (Coming soon)
showConnectedAccounts(appName, renderMode, containerID, layout)
Renders a user's connected accounts for an app. Coming soon!
Functions
Show functions (Coming soon)
showFunctions(renderMode, containerID, layout, appName)
Renders a list of functions. You can filter by app. Coming soon!
Show a function
showFunction(functionName, params, connectedAccountId)
Shows a function's parameters (with pre-filled values, if provided). The user can provide/modify the values. Take the output of this method to call the function.
Method parameters
functionName
string
The name of the function to render.
slack-post-message
true
params
object
An object containing the function parameters.
{"limit":5}
true
connectedAccountId
string
The connected account to use for executing the action. Only use if the user has connected multiple accounts.
12456
false
Returns
This method returns a result
object with the filled-in arguments.
Use it as params
to invokeFunction().
Call a function
invokeFunction(functionName, params, connectedAccountId)
Invokes the specified function of an app with the provided parameters. Integry will automatically include your user's authentication credentials when making the onwards API call.
Integry will execute the function if the user has already connected their account for the function app, and all required parameters (if any) are provided in params
. These function calls will show in the Function Calls log in the Integry app.
Integry will not execute the function if the user has not connected an account, or the parameters passed are invalid. These function calls will not show in the Function Calls log.
Method parameters
functionName
string
The name of the function to execute
slack-post-message
true
params
object
An object containing the function parameters.
{"limit":5}
true
connectedAccountId
string
The connected account to use for executing the action. Only use if the user has connected multiple accounts.
43654
false
Sample params
object for pipedrive-add-a-person
function call:
The functions which fetch data from an app will often return pages of data and allow you to fetch further data by making subsequent calls. These functions use cursor-based pagination via the next_page
parameter that is returned in the result
(if there are more pages).
Sample params
object for pipedrive-get-all-persons
function call with next_page
:
Returns
If Integry executes the function, this method returns a result
object with following keys:
network_code
: HTTP response status code of the onwards API call made by Integry.output
: HTTP response body of the onwards API call made by Integry.next_page
: The cursor for the next page. It will only be present in responses of functions that support paginated calls. If there are no more pages, it will be empty.
If Integry does not execute the function, this method returns a result
object with following keys:
error
: Summary of the error.error_details[]
: Detailed errors for individual fields (if applicable).
Sample responses for pipedrive-add-a-person
and pipedrive-get-all-persons
:
In rare cases where Integry is unable to determine if there are more pages, it will respond with a next_page
cursor. Your subsequent call will return an empty output[]
and next_page
cursor since there are no more pages.
Get a function
getFunction(functionName)
Gets the signature for a specific function to understand the parameters.
Method parameters
functionName
string
The name of the function to execute
slack-post-message
true
Returns
This method returns a result
object with the function's signature.
Flows
Show flows (Coming soon)
showFlows(renderMode, containerID, layout, appName)
Show flows in your workspace. You can filter by app. Coming soon!
Show a flow (Coming soon)
showFlow(flowID, renderMode, containerID, layout)
Show a flow in your workspace. Coming soon!
Create an integration (Coming soon)
createIntegration(flowID, mappings)
Create an integration of a flow in your workspace. Coming soon!
Edit an integration (Coming soon)
editIntegration(flowID)
Edit an integration of a flow in your workspace. Coming soon!
Trigger an integration (Coming soon)
triggerIntegration(integrationID, payload)
Trigger an integration of a flow in your workspace. Coming soon!
Last updated