LangChain Integration

Build AI applications with ContextGate and LangChain

LangChain is a framework for developing applications powered by language models. Integrate CloudSlurp to give your LangChain agents access to Salesforce, QuickBooks, HubSpot, and other business data.

This guide shows you how to create custom LangChain tools that query CloudSlurp, enabling your AI applications to work with real-time business data.

📋 Prerequisites

  • Python 3.8 or later
  • LangChain installed (pip install langchain langchain-openai)
  • ContextGate account with at least one connected app
  • ContextGate API bearer token
1

Get Your ContextGate Bearer Token

Navigate to the Install page in your ContextGate workspace. Click "View API Token" and copy your bearer token for authentication.

💡 Your token can be found on the Install page .

Keep your bearer token secure! Never commit it to version control.

2

Configure Your Toolbox (Optional)

On the Install page, you can customize which tools, connections, and datasets are available through CloudSlurp. This allows you to:

  • Limit access to specific connections (e.g., only Salesforce, not QuickBooks)
  • Enable only certain tools or operations
  • Control which datasets are accessible

Toolbox Manager Interface:

Toolbox Manager Configuration
3

Install Dependencies

Install LangChain and required packages:

4

Create ContextGate LangChain Tool

Create a custom LangChain tool that queries CloudSlurp:

5

Use Tool in LangChain Agent

Create an agent that uses the CloudSlurp tool:

6

Advanced: Query Specific Datasets

Create specialized tools for specific datasets:

7

Example Use Cases

Try these example queries with your agent:

"What are the top 5 Salesforce opportunities by amount?"

"Show me unpaid QuickBooks invoices from the last 30 days"

"Get HubSpot contacts created this month and their email addresses"

📚 ContextGate API Reference

Endpoint Method Description
/v1/queryPOSTQuery data from connected apps
/v1/connectionsGETList available connections
/v1/resourcesGETList datasets for a connection

🔧 Troubleshooting

Authentication Errors

  • Verify your bearer token is correct and not expired
  • Check the Authorization header format is correct
  • Ensure environment variable CONTEXTGATE_BEARER_TOKEN is set

Tool Not Being Called

  • Ensure tool description is clear and specific
  • Verify the agent has access to the tools list
  • Try more explicit prompts that mention specific data sources

Empty Results

  • Check connection and dataset names are correct
  • Verify data exists in your connected apps
  • Test the API directly with curl to isolate issues

🚀 Next Steps

  • Explore LangGraph: Build multi-step agent workflows with state management
  • Add Retrieval: Combine ContextGate with vector stores for RAG applications
  • Build Chains: Create complex data processing pipelines with LangChain