Integry Docs
  • Welcome
  • Sign up for a free trial
  • Apps
    • Overview
    • Authentication
      • Access Control and Testing
    • Passthrough Requests
    • Supported Apps
      • Accelo
      • Aircall
      • Constant Contact
      • Copper
      • Elastic Email
      • Fireflies
      • Insightly
      • Instantly
      • Ontraport
      • RingCentral
      • Sendy
      • ServiceTitan
      • ActiveCampaign
      • Jotform
      • ActiveTrail
      • Agile CRM
      • Aha!
      • Airtable
      • Amazon SES
      • Asana
      • Basecamp3
      • BirdSend
      • Breezy HR
      • Brevo
      • Campaign Monitor
      • Capsule CRM
      • Chargify
      • CleverReach
      • ClickUp
      • ClickSend
      • Cliengo
      • Coda
      • Constant Contact
      • ConvertKit
      • Copper
      • Customer.io
      • Delighted
      • Demio
      • Drip
      • E-goi
      • Eventbrite
      • EverAction
      • Everhour
      • Formstack
      • Freshdesk
      • Freshworks CRM
      • Mautic
      • Customer.guru
      • Front
      • FTP
      • GetResponse
      • GitHub
      • Google Contacts
      • Google Sheets
      • GoToTraining
      • Groove
      • Help Scout
      • HubSpot
      • Keap
      • Mailchimp Transactional
      • Mailjet
      • MailUp
      • MeisterTask
      • Monday.com
      • MoonMail
      • Moosend
      • Nimble
      • Notion
      • Ontraport
      • PagerDuty
      • Pipedrive
      • Pipeline
      • Salesforce
      • SendPulse
      • Slack
      • Snappy
      • SolarWinds
      • Stripe
      • SurveySparrow
      • Teamgate
      • Unbounce
      • Zoho Books
      • Zoho Campaigns
      • Zoho CRM
      • Zoho Mail
      • Zoom
  • Flows
    • Overview
    • Flow Tutorials
      • Sync data TO another app from your app
      • Sync data FROM another app to your app
      • Create a two-way flow
    • Build a Flow
    • Trigger a Flow
      • Multiple Triggers in a Flow
    • Steps in a Flow
    • Integrations
      • Runs
  • Functions
    • Overview
    • Try Functions in 60 seconds
    • Quickstart for AI
    • Viewing Function Calls
    • Source Functions
    • Agent Frameworks
      • LangChain/LangGraph
      • CrewAI
      • AutoGen
      • LlamaIndex
      • Haystack
      • Smolagent
      • LiteLLM
      • Mistral AI
  • Embedded UI
    • Embed Integry Apps Marketplace
    • Add Integry Apps to an Existing Marketplace
    • Render modes, layouts and styling
    • Embedding FAQs
  • APIs and SDKs
    • JS SDK Reference
      • React Web Apps
    • API Reference
  • Workspaces
    • Overview
    • Workspace Variables
    • User Variables
  • Users
    • Testing with Beta Users
Powered by GitBook
On this page
  • Set up the SDK
  • Enable your users to connect apps
  • Shows apps in the Integry marketplace
  • Show apps in your own marketplace
  • Connect apps when needed
  • Predict the function to invoke
  • Predict the function with Integry AI
  • Predict the function yourself
  • Prepare the arguments
  • Predict the arguments with Integry AI
  • Predict the arguments yourself
  • Show the Function UI to the user
  • Execute the function
  • Call the function
  • Process the result
  • Next steps

Was this helpful?

Export as PDF
  1. Functions

Quickstart for AI

PreviousTry Functions in 60 secondsNextViewing Function Calls

Last updated 5 months ago

Was this helpful?

In this guide, we will use the and to enable users to connect apps and invoke functions in those apps from your AI application.

Before you proceed, please for a free trial (if you haven't).

Set up the SDK

Follow the steps .

Enable your users to connect apps

Your users have to first connect an app before you can invoke functions in that app. You could use or more of the following options.

Shows apps in the Integry marketplace

Call the method to easily show all (or some) available apps as a marketplace. Users will simply click an app to connect.

Show apps in your own marketplace

integry.connectApp("slack").then((connectedAccountId) => {
  console.log("Connected to Slack with account ID:", connectedAccountId);
}).catch((error) => {
  console.error("Failed to connect to Slack:", error);
});

Connect apps when needed

integry.isAppConnected("slack").then((result) => {
  if(result) {
    renderFunctionUI("slack-post-message");
  } else {
    integry.connectApp("slack").then((response) => {
      renderFunctionUI("slack-post-message")
    });
  }
}).catch((error) => {
  console.error("Failed to determine auth status:", error);
});

Predict the function to invoke

Let's say your user says they want to "send a message saying hello! to the random channel on slack".

In order to execute the slack-post-message function, you have to first predict that its the most relevant function.

Predict the function with Integry AI

import requests

# Example 2: Basic Prediction
message = "send a message saying hello! to the random channel on slack"
response = requests.post(
    "https://api.integry.io/functions/predict/",
    json={"prompt": message},
    headers={
        "User-ID": "<string>",
        "App-Key": "<string>",
        "Hash": "<string>"
    },
)
function = response

Sample Response:

{
    "functions": [
        {
            "name": "slack-post-message",
            "description": "Sends a message to a channel",
            "parameters": {
                "type": "object",
                "properties": {
                    "channel": {
                        "type": "string",
                        "description": "Select channel you want to post the message to. Call `slack-list-conversations` to get available channels"
                    },
                    "text": {
                        "type": "string",
                        "description": "The message text to be posted to Slack"
                    }
                },
                "required": [
                    "channel",
                    "text"
                ]
            }
        }
    ]
}

The functions array will be empty if Integry is unable to predict the function. You can ask the user to improve the prompt and try again.

Predict the function yourself

Prepare the arguments

In order to invoke a function, you have to first prepare the arguments based on the parameters that the function requires.

Parameter vs Argument: A function parameter is the placeholder name of the type of input the function expects. The actual value passed is called the argument.

Predict the arguments with Integry AI

# Example 1: Prediction with Populated Arguments
message = "send a message saying hello! to the random channel on slack"
response = requests.post(
    "https://api.integry.io/functions/predict/",
    params={"predict_arguments": "true"},
    json={"prompt": message},
    headers={
        "User-ID": "<string>",
        "App-Key": "<string>",
        "Hash": "<string>",
    },
)
function = response

Sample Response for Prediction with Populated Arguments:

{
  "functions": [
    {
      "name": "slack-post-message",
      "description": "Sends a message to a channel",
      "parameters": {
            "type": "object",
            "properties": {
              "channel": {
                "type": "string",
                "description": "Select channel you want to post the message to. Call `slack-list-conversations` to get available channels"
              },
              "text": {
                "type": "string",
                "description": "The message text to be posted to Slack"
              }
            },
            "required": [
              "channel", "text"
            ]
          },
      "arguments": {
        "channel": "random",
        "text": "hello!"
      }
    }
  ]
}
message = "send a message saying hello! to the random channel on slack"
response = requests.post(
    "https://api.integry.io/functions/slack-post-message/get/",
    json={"prompt": message},
    headers={
        "User-ID": "<string>",
        "App-Key": "<string>",
        "Hash": "<string>",
    },
)
function = response

The response is the same as above.

Predict the arguments yourself

If you use predict the arguments with Integry AI, we handle this for you.

Show the Function UI to the user

const arguments = {
  "channel": "random",
  "text": "hello!"
}

integry.showFunctionUI("slack-post-message", arguments).then((result) => {
  console.log("Function parameters filled-in by the user:", result);
}).catch((error) => {
  console.error("Failed to load function UI:", error);
});

This will open the Function UI (with the pre-filled arguments) in a modal.

This method returns a result object with the filled-in arguments that you can use to invoke the function.

Functions that mutate data can potentially do irreversible damage. Even if you have predicted the arguments, consider always showing the Function UI to the user (with the predicted arguments) so they can confirm before you execute.

Execute the function

Call the function

const arguments = {
  "channel": "random",
  "text": "hello!"
}

integry.invokeFunction("slack-post-message", arguments).then((result) => {
  console.log("Received response from Slack:", result);
}).catch((error) => {
  console.error("Failed to invoke function:", error);
});

Process the result

The result object will have the response from the app if the function was executed (or error details if it wasn't).

In this case, you should see the following success response from Slack in the console:

That's it! You have enabled your users to connect apps and execute functions in those apps from your AI application using Integry Functions.

Next steps

Try fetching data using a function like pipedrive-get-all-persons . It supports paginated calls so the result will include a next_page cursor that you will include in the arguments in the next invocation.

Build your own apps marketplace and call the method when they click on an app.

Call method (when they try to use a function of an app) to check if the app is connected. If not, ask them to .

You can simply pass the prompt to Integry and , or (by listing all available functions).

Call the API endpoint with {"prompt: "<user_message>"} to get the most relevant function. You can also have Integry .

Retrieve a list of available functions using the endpoint and pass them to your AI model. Your model will predict the function to use.

If you need to call an endpoint that is not supported by Integry, you can make a .

Similar to predicting the function, you can simply pass the prompt to Integry and , or (using the function spec).

Call the API endpoint with predict_arguments=true to get the most relevant function with populated arguments.

Alternatively, if you predicted the function yourself and want Integry to predict the arguments, call the API endpoint with prompt in the body to get the function with populated arguments.

Call the endpoint to get the function spec and pass it to your AI model. Your model will predict and populate the arguments.

You may need to make additional calls to to fetch options. Once you have the related data from the source function, use your model to pick the most relevant value from the set.

Before you invoke the function, if you want the user to confirm the predicted arguments, or provide one (or more) required arguments that could not be predicted, you can call method to show the Function UI to the user (with pre-filled arguments, if any).

Call with the <function_name> and arguments object to execute the function.

Passthrough Request
source functions
predict the function with Integry AI
predict it yourself
predict the arguments with Integry AI
predict them yourself
Integry.JS SDK
Integry Functions API
sign up
predict the arguments
functions/predict
/functions/list
functions/predict
functions/<function_name>/get
functions/<function_name>/get
here
showApps()
connectApp()
isAppConnected()
connectApp()
showFunctionUI()
invokeFunction()