LangChain Tools

The langchain-kudosity package gives your LangChain.js agent tools to send SMS, MMS, and RCS through Kudosity. Hand the tools to an agent, and it can text a customer whenever its logic decides to — an appointment reminder after a booking, a delivery update, a follow-up when a lead goes quiet.

The package is open source under the MIT licence at github.com/kudosity/langchain-kudosity.

Install

npm install langchain-kudosity @langchain/core

The package works with @langchain/core 0.3 and 1.x.

Before you begin

You need:

  • A Kudosity account. Sign up if you do not have one.
  • Your API key, from the dashboard under Developers > API Settings.
  • A registered sender: a virtual number or alphanumeric sender ID for SMS and MMS, and a registered RCS agent ID for RCS.

Set your API key as an environment variable:

export KUDOSITY_API_KEY="your_api_key"

Available tools

ToolClassWhat it does
kudosity_send_smsKudositySendSmsSend a text message to a phone number
kudosity_send_mmsKudositySendMmsSend an image, GIF, video, or audio attachment, passed as public URLs
kudosity_send_rcsKudositySendRcsSend a rich, branded RCS message, with optional SMS fallback for devices that cannot receive RCS

Each tool returns the message id and status as JSON, so your agent can match the send against delivery webhooks. When a call fails, the tool returns the API's validation detail — every failed field at once — as JSON instead of throwing, so the agent can correct its input and retry.

Use a tool directly

import { KudositySendSms } from "langchain-kudosity";

const sendSms = new KudositySendSms({
  // a virtual number on your account, or an alphanumeric sender ID (max 11 chars)
  defaultSender: "61481074185",
});

const result = await sendSms.invoke({
  recipient: "61491570156",
  message: "Your appointment is tomorrow at 10am. Reply STOP to opt out.",
});
// → {"id":"2d2c8fb6-…","status":"queued","recipient":"61491570156",…}

Hand the tools to an agent

import { createAgent } from "langchain";
import {
  KudositySendSms,
  KudositySendMms,
  KudositySendRcs,
} from "langchain-kudosity";

const tools = [
  new KudositySendSms({ defaultSender: "61481074185" }),
  new KudositySendMms({ defaultSender: "61481074185" }),
  new KudositySendRcs({
    defaultSender: "YourAgentId", // a registered RCS agent ID, not a phone number
    defaultFallbackSender: "61481074185",
  }),
];

const agent = createAgent({ model: "anthropic:claude-sonnet-5", tools });

await agent.invoke({
  messages: [
    { role: "user", content: "Text 61491570156 that their delivery arrives Thursday." },
  ],
});

The model supplies the recipient and message. The sender comes from your configuration by default, so the model cannot invent one — it can only override it with another sender you have registered.

RCS: two things to get right

  • The RCS sender is a registered RCS agent ID, never a phone number. Registration is not part of the API — see the RCS agent registration process, then use the agent ID here.
  • Include an SMS fallback on almost every send. Not every handset can receive RCS. The tool's input schema prompts the model to supply sms_fallback_message; the fallback sender stays in your configuration (defaultFallbackSender), so the model never picks the number.

Configuration reference

OptionDefaultNotes
apiKeyKUDOSITY_API_KEY environment variableKudosity V2 API key, sent as x-api-key
defaultSenderUsed when the model does not supply a sender
defaultFallbackSenderRCS tool only: the SMS sender used when the model adds a fallback message
baseUrlhttps://api.transmitmessage.comOverride for testing

Next steps


Did this page help you?