Connect Textmagic to ChatGPT: Automate Two-Way SMS, Chat & Campaigns
Learn how to build a managed MCP server to securely connect Textmagic to ChatGPT. Automate SMS workflows, two-way chats, and bulk campaigns with AI agents.
You need to connect Textmagic to ChatGPT so your AI agents can orchestrate two-way SMS conversations, validate phone numbers, and trigger bulk marketing campaigns directly from natural language prompts. If your team uses Claude, check out our guide on connecting Textmagic to Claude or explore our broader architectural overview on connecting Textmagic to AI Agents.
Giving a Large Language Model (LLM) read and write access to your communication infrastructure is an engineering challenge. Textmagic provides a comprehensive REST API, but forcing an LLM to interact with it directly requires you to manage OAuth tokens, maintain massive OpenAPI specifications, and build custom backoff logic for strict rate limits.
You can either spend weeks building, hosting, and maintaining a custom Model Context Protocol (MCP) server, or you can use a managed infrastructure layer that handles the boilerplate. This guide breaks down exactly how to use Truto to generate a secure, authenticated MCP server for Textmagic, connect it natively to ChatGPT, and execute complex two-way messaging workflows.
The Engineering Reality of the Textmagic API
A custom MCP server is a self-hosted integration layer that translates an LLM's tool calls into REST API requests. While the MCP standard provides a predictable way for models to discover tools via JSON-RPC, the reality of implementing it against Textmagic's APIs is complex. Every integration has specific constraints, and Textmagic is no different.
If you decide to build a custom MCP server for Textmagic, you own the entire API lifecycle. Here are the specific integration challenges that break standard CRUD assumptions when working with Textmagic:
The Sync-to-Async Bulk Abstraction
Textmagic handles SMS dispatch differently depending on the volume of your payload. If you send a message to a handful of recipients, the messages endpoint processes it synchronously. However, if an AI agent attempts to send an SMS to more than 1,000 recipients at once, the system abstracts this into an asynchronous "bulk session". Your custom server must dynamically recognize this threshold, capture the session_id, and instruct the LLM to poll the bulks endpoint to track the status of the batch dispatch. If your MCP server does not handle this duality, the LLM will hallucinate a success response while the actual job is still pending or has failed.
Strict Rate Limits and 429 Errors
Textmagic enforces strict rate limits to prevent spam and network abuse. When you hit these limits, the API returns an HTTP 429 error. A common mistake when building custom MCP servers is attempting to swallow these errors and automatically retry them inside the server logic.
Truto takes a different, deterministic approach: we do not retry, throttle, or apply backoff on rate limit errors. When the upstream API returns a 429, Truto passes that error directly to the caller. Truto normalizes the upstream rate limit information into standardized headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset) per the IETF specification. This explicit failure model means the LLM client is fully aware of the rejection and is responsible for implementing its own intelligent backoff strategy before re-attempting the tool call.
Singular Number Lookups
When scrubbing contact lists, developers often assume they can pass an array of phone numbers to a validation endpoint. The Textmagic lookups API does not support batch processing - numbers must be checked one by one. If an AI agent attempts to pass an array of 50 numbers to the lookup tool, the request will fail. Your MCP tool definitions must explicitly strictly type the phone parameter as a singular string and instruct the LLM to iterate over lists individually.
Separating Chats from Replies
Textmagic differentiates between standalone inbound messages (Replies) and threaded conversations (Chats). If your AI agent needs to act as a conversational support bot, querying the replies endpoint will return isolated messages without context. To maintain state, the LLM must interact with the chats and chat_messages endpoints, which group communications by session and phone number. Your custom server must explicitly define the schemas for both and instruct the LLM on when to use each.
How to Create the Textmagic MCP Server
Instead of building this infrastructure from scratch, you can use Truto to dynamically generate an MCP server. Truto derives tool definitions directly from the integration's resource configurations and documentation records, ensuring that the schemas are always accurate and AI-ready.
Each MCP server is scoped to a single integrated account. The server URL contains a cryptographic token that encodes which account to use, what tools to expose, and when the server expires. You can create this server via the Truto UI or programmatically via the API.
Method 1: Via the Truto UI
This is the fastest method for internal tooling and immediate testing.
- Log into your Truto dashboard and navigate to the integrated account page for your Textmagic connection.
- Click the MCP Servers tab.
- Click Create MCP Server.
- Select your desired configuration. You can optionally filter the available methods (e.g., limit the server to
readoperations only) or filter by specific tool tags. - Copy the generated MCP server URL (e.g.,
https://api.truto.one/mcp/a1b2c3d4e5f6...).
Method 2: Via the Truto API
For production deployments where you are dynamically provisioning AI agents for your users, you should generate MCP servers programmatically.
Make a POST request to /integrated-account/:id/mcp with your desired configuration:
curl -X POST https://api.truto.one/integrated-account/{account_id}/mcp \
-H "Authorization: Bearer YOUR_TRUTO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Textmagic SMS Automation",
"config": {
"methods": ["read", "write"],
"tags": ["messaging", "contacts"]
}
}'The API generates a secure token, stores the metadata, and returns a ready-to-use URL:
{
"id": "abc-123",
"name": "Textmagic SMS Automation",
"config": { "methods": ["read", "write"] },
"expires_at": null,
"url": "https://api.truto.one/mcp/a1b2c3d4e5f6..."
}How to Connect the MCP Server to ChatGPT
Once you have your Truto MCP server URL, you need to register it with your LLM client. The server URL is fully self-contained - it handles authentication and serves the JSON-RPC 2.0 tool definitions automatically.
Method 1: Via the ChatGPT UI
If you are using ChatGPT Enterprise, Plus, or Team accounts with Developer Mode enabled, you can connect the server directly through the interface.
- In ChatGPT, navigate to Settings -> Apps -> Advanced settings.
- Enable Developer mode.
- Under the MCP servers section, click Add a new server.
- Name the server (e.g., "Textmagic Agent").
- Paste the Truto MCP URL into the Server URL field.
- Save the configuration. ChatGPT will immediately perform a handshake with the
/mcp/:tokenendpoint, retrieve the available tools, and make them available in your session.
Method 2: Via Manual Configuration File (CLI / Desktop)
If you are running an MCP client that requires a local configuration file (such as Claude Desktop or custom LangChain setups), you can map the remote Truto server using the official Server-Sent Events (SSE) transport wrapper.
Add the following to your mcp_config.json:
{
"mcpServers": {
"textmagic-truto": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-sse",
"https://api.truto.one/mcp/a1b2c3d4e5f6..."
]
}
}
}This configuration instructs the client to proxy the standard local stdin/stdout MCP protocol to the remote HTTP JSON-RPC endpoint hosted by Truto.
Hero Tools for Textmagic
Truto automatically exposes Textmagic resources as strictly-typed tools. Instead of managing complex body payloads, the LLM uses a flat argument structure, which the MCP router intelligently splits into query parameters and body payloads based on the JSON Schema.
Here are 6 high-leverage tools available for Textmagic.
create_a_textmagic_message
Sends an outbound SMS or MMS message. This tool handles everything from direct text dispatches to rrule-based scheduling and MMS attachments. Because the schema clearly defines phones as the required recipient format, the LLM knows exactly how to format the destination.
"Send an SMS to +15558675309 letting them know their server migration is complete, and they can log back in."
textmagic_contacts_search
Searches your Textmagic contacts by various criteria, including query strings, list IDs, tag IDs, and exact phone numbers. The query schema instructs the LLM on how to format search strings to locate specific users before dispatching a message.
"Search our Textmagic contacts for anyone with the company name 'Acme Corp' and return their phone numbers."
list_all_textmagic_lookups
Looks up carrier and formatting information for a single phone number. This is critical for validating numbers before adding them to lists or dispatching expensive outbound messages. The tool explicitly tells the LLM that numbers must be checked one-by-one.
"Check if +15551239876 is a valid mobile number and tell me the carrier. If it's a landline, let me know so I don't send an SMS to it."
list_all_textmagic_chats
Retrieves active threaded conversations. This tool allows the AI agent to look up ongoing customer interactions, filtering by unread status, voice calls, or specific assigned team members.
"Find any Textmagic chats that currently have an 'unread' status and summarize who the customers are."
list_all_textmagic_chat_messages
Fetches the specific historical messages within a designated chat ID. When combined with the chat listing tool, this allows an AI agent to read the entire context of a two-way conversation before drafting a reply.
"Get the message history for chat ID 948572 and summarize the customer's main complaint over the last three messages."
create_a_textmagic_email_campaign
Creates and schedules an email marketing campaign. Textmagic isn't just for SMS; this tool allows the LLM to orchestrate multi-channel outreach by passing a subject line, HTML message body, and a list of target recipients.
"Create a new email campaign titled 'Q3 Feature Release'. Send it from our default sender ID to list ID 8847, with a short message about our new analytics dashboard."
These represent just a fraction of the available endpoints. For the complete inventory, including sub-accounts, caller IDs, pricing estimators, and webhook configurations, view the Textmagic integration page.
Workflows in Action
By providing these tools to an LLM, you unlock autonomous workflows that previously required custom-built internal applications. Here are two examples of how an AI agent orchestrates these tools in real-time.
Scenario 1: Support Triage and Auto-Responder
A customer success team wants their AI agent to monitor incoming SMS messages, identify the customer, and draft contextual replies based on previous chat history.
"Check for any unread Textmagic chats. For the first one you find, retrieve the message history. Search our contacts to see who the phone number belongs to. Finally, draft a polite SMS reply acknowledging their specific issue and send it."
list_all_textmagic_chats: The agent queries the API, filtering forunread=true. It extractschat_id10485 and the associated phone number.list_all_textmagic_chat_messages: The agent passes thechat_idto retrieve the conversation history, learning the customer is asking about a billing error.textmagic_contacts_search: The agent searches the phone number to retrieve the customer's profile, finding out their name is Sarah and they belong to the 'Enterprise' list.create_a_textmagic_message: The agent constructs a personalized SMS ("Hi Sarah, looking into the billing error on your Enterprise account now...") and dispatches it.
sequenceDiagram participant Agent as "AI Agent" participant Truto as "Truto MCP" participant Textmagic as "Textmagic API" Agent->>Truto: Call list_all_textmagic_chats (unread=1) Truto->>Textmagic: GET /api/v2/chats?unread=1 Textmagic-->>Truto: Chat ID 10485, Phone +15550001111 Truto-->>Agent: Returns chat metadata Agent->>Truto: Call textmagic_contacts_search (+15550001111) Truto->>Textmagic: GET /api/v2/contacts/search?query=... Textmagic-->>Truto: Contact: Sarah (Enterprise) Truto-->>Agent: Returns profile data Agent->>Truto: Call create_a_textmagic_message (text, phone) Truto->>Textmagic: POST /api/v2/messages Textmagic-->>Truto: 201 Created (Message ID) Truto-->>Agent: Returns success confirmation
Scenario 2: Lead Scrubbing and Campaign Dispatch
A marketing operations manager needs to validate a new list of phone numbers, ensure they are mobile devices, and dispatch a targeted promotion.
"I have a list of three numbers: +15559992222, +15558883333, and +15557774444. Look up each one to ensure it is a valid mobile number. If it is, send them our standard 'Welcome 20%' promo text."
list_all_textmagic_lookups: The agent iterates over the first number, passing it to the lookup tool. It receives a response indicatingtype: "mobile"andvalid: true.list_all_textmagic_lookups: It checks the second number. The response showstype: "landline". The agent decides to skip this number.list_all_textmagic_lookups: It checks the third number, which returns valid mobile status.create_a_textmagic_message: The agent groups the two valid mobile numbers into an array and dispatches a single request with the promo text.
The LLM handles the logic routing entirely based on the raw API output returned through the MCP proxy, saving you from writing custom if/else conditions in a Python script.
Security and Access Control
Exposing an SMS gateway to an AI agent requires strict guardrails. You do not want a hallucinating agent to accidentally delete contact lists or spend thousands of dollars on unauthorized bulk messages. Truto provides several mechanisms to lock down your MCP servers:
- Method Filtering: You can restrict the server to specific HTTP methods. By setting
methods: ["read"], the agent can list chats and search contacts, but any attempt to executecreate,update, ordeletetools will be blocked at the server generation level. - Tag Filtering: You can scope the server to specific operational domains. Setting
tags: ["contacts"]ensures the agent can only manage address books, entirely hiding the messaging and campaign endpoints. - Require API Token Auth: By default, possessing the MCP URL grants access. For higher security, setting
require_api_token_auth: trueforces the client to pass a valid Truto API token in the Authorization header, adding a mandatory second layer of identity verification. - Ephemeral Servers: You can set an
expires_attimestamp when creating the server. Once the timestamp passes, the cryptographic token is automatically purged from edge storage, instantly revoking the LLM's access to the Textmagic instance.
Summary
Building a custom integration between Textmagic and an LLM client forces your engineering team to take on the burden of token lifecycle management, pagination cursors, rate limit backoffs, and endless JSON schema maintenance.
By leveraging a managed MCP server via Truto, you bypass the boilerplate. You generate a secure, authenticated endpoint that maps Textmagic's complex REST API directly into LLM-native tools. This allows your team to focus on designing high-value conversational agents and automation workflows, rather than debugging 429 rate limit errors or untangling inbound message webhooks.
FAQ
- How does Truto handle Textmagic rate limit errors?
- Truto does not automatically retry or absorb rate limit errors. When Textmagic returns an HTTP 429, Truto passes the error back to the caller and normalizes the rate limit data into standard IETF headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset). The caller is responsible for implementing retry and backoff logic.
- Can I restrict the AI agent to only read Textmagic data?
- Yes. When generating the MCP server via Truto, you can configure method filters (e.g., methods: ["read"]). This ensures the AI agent can only list chats and search contacts, but cannot send messages or delete records.
- Does Truto support both single and bulk SMS sending for Textmagic?
- Yes. Truto exposes the underlying Textmagic REST endpoints as distinct tools, allowing the AI agent to dispatch single messages or orchestrate bulk campaign sessions depending on the tools you expose.
- How do I secure the MCP server URL?
- You can secure the URL by setting an expires_at timestamp for ephemeral access, using method and tag filtering to restrict capabilities, and enabling require_api_token_auth to force a secondary layer of API token authentication.