Skip to content

Connect Sendoso to AI Agents: Scale Digital and Physical Gifting

A step-by-step engineering guide to connecting Sendoso to AI agents using Truto. Learn how to fetch Sendoso tools and automate gifting workflows.

Uday Gajavalli Uday Gajavalli · · 9 min read
Connect Sendoso to AI Agents: Scale Digital and Physical Gifting

Connecting Sendoso to an AI agent allows your system to autonomously trigger digital eGifts, dispatch physical swag boxes, audit team budgets, and track delivery statuses based on real-time CRM or HR signals. Here is exactly how to do it using Truto's /tools endpoint and SDK, bypassing the need to build and maintain a custom gifting integration from scratch.

Automating direct mail and corporate gifting is notoriously difficult. Sales and HR teams spend hours manually selecting campaigns, entering recipient addresses, and checking tracking numbers. The industry is rapidly shifting toward agentic AI - autonomous systems that monitor signals in your CRM or HRIS and execute multi-step workflows across your SaaS stack. Giving a Large Language Model (LLM) the ability to spend real company budget on physical items requires precise, schema-validated API execution.

If your team uses ChatGPT, check out our guide on connecting Sendoso to ChatGPT, or if you are building on Anthropic's models, read our guide to connecting Sendoso to Claude. For developers building custom autonomous workflows, this guide details how to fetch AI-ready Sendoso tools programmatically and bind them to your agent framework.

The Engineering Reality of the Sendoso API

Building AI agents is straightforward. Connecting them to external SaaS APIs that manage financial transactions and physical logistics is complex.

Giving an LLM access to external data sounds simple in a prototype. You write a Node.js function that makes a network request and wrap it in an @tool decorator. In production, this approach collapses. If you decide to build a custom integration for Sendoso, you own the entire API lifecycle, from OAuth token management to handling payload validation for dozens of nested endpoints. As we discussed in Architecting AI Agents: LangGraph, LangChain, and the SaaS Integration Bottleneck, maintaining these connections drains engineering velocity.

Sendoso's API introduces specific integration challenges that break standard REST assumptions:

The Complexities of Physical vs. Digital Payloads

Sendoso treats eGifts and physical gifts as fundamentally different entities requiring entirely different payload structures. An eGift merely requires a touch_id and an email address. A physical gift requires detailed shipping data, but modern compliance dictates you often cannot store a recipient's home address. This requires using the Address Collection endpoint, where the API sends an email asking the recipient for their address before shipping the item. An LLM must understand when to use standard physical sending versus address collection, and must accurately construct the nested JSON requirements for each.

Strict Rate Limits and the 429 Passthrough

Sendoso enforces API rate limits to protect their infrastructure. When an AI agent enters a loop - for example, trying to retrieve the status of 500 recent sends simultaneously - it will hit these limits.

It is critical to understand how Truto handles this: Truto does not retry, throttle, or apply backoff on rate limit errors. When the upstream Sendoso API returns an HTTP 429 Too Many Requests error, Truto passes that error directly to the caller. However, Truto normalizes the upstream rate limit information into standardized IETF headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset). The caller - your agent framework - is entirely responsible for reading these headers and implementing exponential backoff and retry logic. Do not assume the integration layer will absorb these errors for you.

Campaign and Touch Abstractions

In Sendoso, you do not simply "send a coffee." You trigger a specific touch_id tied to a specific campaign_id, which is funded by a specific team_group_id. An AI agent must first query the available campaigns, filter them by delivery type (eGift vs physical), extract the correct touch ID, and ensure the assigned team group has the necessary budget before attempting the send. This requires multi-step reasoning and precise parameter passing across sequential tool calls.

Architecture: Fetching and Binding Sendoso Tools

Truto solves the integration bottleneck by treating every integration as a comprehensive JSON object mapping the underlying product's API behavior. Truto maps Sendoso's endpoints into Resources and Methods.

These Methods operate as Proxy APIs. Truto handles the OAuth authentication, credential storage, and pagination abstraction, returning a clean, predictable format. For agentic use cases, Proxy APIs are ideal because they expose the raw power of the underlying API without the boilerplate.

Instead of writing custom schemas for Sendoso, you use Truto's /tools endpoint. This API returns a complete list of Proxy APIs formatted as LLM-ready tools, complete with descriptions and input schemas.

Here is how you fetch these tools and bind them to a LangChain agent using the truto-langchainjs-toolset:

import { TrutoToolManager } from "@trutohq/truto-langchainjs-toolset";
import { ChatOpenAI } from "@langchain/openai";
import { AgentExecutor, createOpenAIFunctionsAgent } from "langchain/agents";
import {
  ChatPromptTemplate,
  MessagesPlaceholder,
} from "@langchain/core/prompts";
 
// Initialize the Truto Tool Manager with your Truto API key
const trutoManager = new TrutoToolManager({
  apiKey: process.env.TRUTO_API_KEY,
});
 
async function initializeSendosoAgent(integratedAccountId: string) {
  // Fetch all Sendoso tools for this specific authenticated account
  const tools = await trutoManager.getTools(integratedAccountId);
 
  const llm = new ChatOpenAI({
    modelName: "gpt-4o",
    temperature: 0,
  });
 
  // Bind the dynamically fetched tools to the LLM
  const llmWithTools = llm.bindTools(tools);
 
  const prompt = ChatPromptTemplate.fromMessages([
    ["system", "You are a corporate gifting assistant with access to Sendoso. Execute gifting workflows based on user requests. Always verify campaigns and budgets before sending."],
    ["human", "{input}"],
    new MessagesPlaceholder("agent_scratchpad"),
  ]);
 
  const agent = await createOpenAIFunctionsAgent({
    llm: llmWithTools,
    tools,
    prompt,
  });
 
  return new AgentExecutor({
    agent,
    tools,
    verbose: true,
  });
}

This architecture ensures that if Sendoso updates an endpoint or adds a new parameter, Truto automatically updates the tool definition. Your agent dynamically ingests the new schema on the next boot, requiring zero code changes on your end.

Hero Tools for Sendoso Agents

Truto provides a comprehensive suite of tools for Sendoso. Below are the highest-leverage operations you should expose to your AI agents to enable autonomous gifting workflows.

list_all_sendoso_campaigns

Before an agent can send a gift, it needs to know what gifts are available. This tool retrieves all active campaigns, returning crucial data including the id, name, status, delivery_type, and the associated touch_id. The agent uses this to map a human request ("Send a coffee") to the specific internal ID required by Sendoso.

"List all active eGift campaigns in our Sendoso account and identify the touch ID for the Starbucks $10 tier."

Instead of triggering an email directly from Sendoso, this tool generates a raw eGift URL that your agent can hand back to the user or inject into a personalized email draft. It requires the touch_id and the recipient's details. This is highly useful for SDRs who want to drop a coffee link directly into a LinkedIn message or a customized outbound sequence.

"Generate an eGift link for the 'SDR Lunch Meeting' campaign for prospect david.smith@acmecorp.com so I can paste it into my email reply."

create_a_sendoso_physical_gift_address_collection

Sending physical items is a compliance minefield if you do not have the recipient's address. This tool triggers an automated workflow where Sendoso emails the recipient a branded landing page to collect their shipping details before dispatching the item. It accepts parameters like expire_after_days and hide_product_info.

"Send a New Hire Swag Box to jane.doe@company.com using the address collection workflow. Set the link to expire in 7 days and make sure the product price is hidden."

list_all_sendoso_sends

Automation is useless without observability. This tool lists all historical sends, allowing the agent to check the status of a specific gift. It returns delivery states, tracking codes, and cost details. An agent can use this to proactively notify a sales rep when a prospect has received their gift.

"Check the status of the physical swag boxes we sent out last Tuesday. Let me know which ones have been delivered and which are still in transit."

list_all_sendoso_team_group_users

In enterprise Sendoso setups, users are organized into Team Groups, each with isolated budgets. This tool allows the agent to audit which users belong to which group, verify individual user balances, and extract user IDs. This is required if the agent needs to orchestrate sends on behalf of a specific team member rather than the default API user.

"Look up the team group for the Enterprise Sales team and verify if john.doe has enough balance left this quarter to send a $150 wine basket."

For the complete inventory of Sendoso tools, including endpoints for managing user invitations, querying organizational balances, and triggering direct physical gifts without address collection, visit the Sendoso integration page.

Building Multi-Step Workflows

Standard API wrappers fail when they attempt to execute complex business logic in a single shot. AI agents excel at multi-step orchestration, where the output of one tool becomes the input for the next.

When building these loops, especially with financial APIs like Sendoso, you must account for failure states and rate limits. Because Truto passes 429 Too Many Requests errors directly back to your framework, your tool execution loop must read the ratelimit-reset header and sleep the thread accordingly.

Here is an example of how you might handle a tool execution error gracefully within a custom agent loop:

async function executeToolSafely(toolName: string, args: any, integratedAccountId: string) {
  const maxRetries = 3;
  let attempt = 0;
 
  while (attempt < maxRetries) {
    try {
      // Execute the tool via your preferred agent framework
      const result = await executeTrutoTool(toolName, args, integratedAccountId);
      return result;
    } catch (error: any) {
      if (error.status === 429) {
        // Read Truto's normalized IETF headers
        const resetTimeSec = parseInt(error.headers['ratelimit-reset'] || '60', 10);
        console.warn(`Rate limit hit on ${toolName}. Sleeping for ${resetTimeSec} seconds.`);
        
        // Sleep until the rate limit resets
        await new Promise(resolve => setTimeout(resolve, resetTimeSec * 1000));
        attempt++;
        continue;
      }
      
      // Log standard 4xx and 5xx errors for the LLM to process
      return `Tool execution failed: ${error.message}. Please adjust your parameters and try again.`;
    }
  }
  
  return `Failed to execute ${toolName} after ${maxRetries} rate limit retries.`;
}

By exposing the raw rate limit headers, Truto ensures you have the granular control required to build production-grade, fault-tolerant AI systems across frameworks like LangGraph, CrewAI, or Vercel AI SDK.

Workflows in Action

Connecting tools to an LLM is only the baseline. The real value emerges when agents autonomously navigate specific business scenarios. Here are two concrete examples of how specialized personas use an AI agent equipped with Sendoso tools.

Scenario 1: B2B Sales SDR Securing a Meeting

An SDR notices a high-value prospect has agreed to an introductory call and wants to send a coffee gift card to confirm the meeting without context-switching into the Sendoso dashboard.

"The CTO of Acme Corp agreed to meet tomorrow. Generate a $10 Starbucks eGift link from our SDR Outreach campaign for cto@acmecorp.com so I can send it in my calendar invite."

Agent Execution Steps:

  1. Call list_all_sendoso_campaigns: The agent searches the available campaigns, filtering for names matching "SDR Outreach" and ensuring the delivery_type is an eGift.
  2. Extract Touch ID: The agent identifies the correct touch_id for the $10 Starbucks tier.
  3. Call create_a_sendoso_egift_link: The agent passes the touch_id and the recipient email (cto@acmecorp.com) to generate the link.
  4. Format Output: The agent returns the raw egift_link to the SDR.

Result: The SDR receives a direct URL in seconds, entirely bypassing the Sendoso UI and maintaining focus on their outbound motion.

Scenario 2: HR Automating New Hire Swag

An HR operations manager needs to send a welcome kit to a new employee but does not have their home shipping address.

"We just hired Alex as our new Lead Designer. Send him the 'Premium Welcome Kit' physical swag box. Use alex@ourcompany.com for the address collection email and make sure the link expires in 5 days. Hide the product cost."

Agent Execution Steps:

  1. Call list_all_sendoso_campaigns: The agent retrieves campaigns and isolates the touch_id for the "Premium Welcome Kit" physical campaign.
  2. Call create_a_sendoso_physical_gift_address_collection: The agent executes the tool, passing the touch_id, setting email to alex@ourcompany.com, setting expire_after_days to 5, and setting hide_product_info to true.
  3. Confirm Execution: The agent receives a success message and a tracking_code from the Sendoso API.

Result: The agent confirms the request has been dispatched. Sendoso takes over the address collection workflow, and the HR manager never had to handle sensitive physical address data manually.

Strategic Wrap-Up

Integrating Sendoso into your AI agent architecture unlocks a massive operational advantage: the ability for your software to trigger real-world, physical logistics and financial incentives autonomously.

However, building this integration in-house means your engineering team inherits the burden of maintaining complex nested schemas, managing OAuth lifecycles, and writing boilerplate code for pagination. By leveraging Truto's /tools endpoint, you instantly convert Sendoso's complex API into a secure, LLM-ready toolset. Truto handles the authentication and API proxies, normalizes the rate limit headers so your agent can react intelligently, and ensures your application is completely insulated from upstream schema drift.

Stop wasting engineering cycles writing boilerplate JSON schemas for SaaS APIs. Let your developers focus on the agent's core cognitive loops, and let Truto handle the connectivity.

FAQ

Does Truto automatically retry Sendoso API rate limits?
No. Truto passes HTTP 429 Too Many Requests errors directly back to the caller. However, Truto normalizes the upstream rate limit information into standard IETF headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset). Your AI agent framework must read these headers and implement its own backoff and retry logic.
How do AI agents handle the difference between eGifts and physical gifts in Sendoso?
They require different tools and schemas. eGifts generally use the `create_a_sendoso_egift_link` tool, requiring an email and touch ID. Physical gifts, to avoid storing PII, typically use the `create_a_sendoso_physical_gift_address_collection` tool, which triggers a workflow to ask the recipient for their shipping details.
Can I use Sendoso tools with LangGraph or CrewAI?
Yes. Truto's `/tools` endpoint generates standard LLM-ready definitions that are completely framework agnostic. Whether you use LangChain, LangGraph, CrewAI, or the Vercel AI SDK, you can bind these tools to your agent using standard function calling patterns.

More from our Blog