Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

SMS Segment Counter

communication.sms_segments

ProductionBounded custom (Class B)Deterministicstrictinstantv1.0.0
No network

Overview

Nothing here is sent and nothing is connected to: you hand us the text of a message and we hand back arithmetic, with no gateway, no carrier lookup and no phone number involved. We work out which alphabet your text needs, how many segments it occupies, and how many characters you have left in the last one, using the published GSM 03.38 tables — 160 characters in a single 7-bit segment and 153 in each segment once a message is split, or 70 and 67 when the text needs UCS-2. The surprises are the point. Nine characters cost two septets instead of one, so a 160-character message with a single curly brace in it needs two segments; and one emoji outside the basic multilingual plane eats two of your 70. We show you exactly which characters pushed you into UCS-2, so you can find the one that tripled the bill. We never return the split segments themselves: splitting belongs to whoever sends the message, and handing the pieces back would only be your own text in slices.

Segment arithmetic looks trivial and almost nobody gets it right by hand. Splitting a message costs you seven septets of every segment, not zero; nine ordinary-looking characters cost two septets each; and a single emoji collapses your budget from 160 characters to 70, of which it takes two. The result is a campaign that was priced at one segment and billed at three. We give you the same numbers your provider will, from the published tables, before you send anything.

Reliability

The same text always produces the same numbers — there is no clock, no randomness and nothing outside your request. Segments are packed left to right so that a two-unit character is never broken across a boundary, which is what a real transport does; with no two-unit character present that is exactly the familiar division, so 160, 161, 153 and 154 characters land where you expect. The characters that cost two septets are the caret, the four brackets and braces, the backslash, the tilde, the pipe, the euro sign and a form feed. Three things can stop the call rather than answer it. SMS_TEXT_TOO_LARGE means the text is longer than 65536 characters, which is far beyond any sendable message — measure the part you actually intend to send; SMS_ENCODING_UNSUPPORTED means encoding was something other than AUTO, GSM7 or UCS2, and we refuse rather than quietly fall back to AUTO — correct the value and retry; SMS_ENCODING_INCOMPATIBLE means you asked for GSM7 on text the GSM alphabet cannot carry, and the details say how many distinct characters and where the first one is — either switch to AUTO and accept UCS-2, or replace those characters yourself, since we will not substitute them for you. Going past maxSegments is never a failure: it comes back as exceedsMaxSegments so you can decide.

Context footprint

The answer is a dozen numbers plus at most 32 single characters, so it stays a fraction of a kilobyte no matter how long your message is. Your text is never echoed back and never written to a log. A successful call costs 1 execution credit.

When to use it

Before a message goes out, or live while somebody is writing one, whenever the segment count changes what you pay or what fits.

When you want the message sent or split for you, when you need a per-segment price, or when you are measuring anything other than SMS.

Scope

Note
Counts SMS segments, characters used and characters remaining for a message, under the published GSM 03.38 capacity tables.

Non-goals

  • Does not send a message, reach a gateway, or open any connection
  • Does not return the split segments — counting is the whole job
  • Does not look up a carrier, a route, a price or a phone number
  • Does not rewrite your text to make it cheaper, and never substitutes a character to squeeze it into GSM-7
  • Does not know what your provider charges per segment

Properties

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

analysis

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call1 credit

File handling

Accepts file_refProduces file_refMax input2 MB

How we handle your data

Sensitive input, safe output
What this means

This skill may receive sensitive content, but it does not target sensitive data and returns only a structured non-sensitive result.

Squillify guarantees
  • Runs inside Squillify
  • This skill runs inside Squillify.
  • Payloads are not sent to an external service by this skill.
  • Squillify does not permanently store submitted payloads.
  • Telemetry records metadata only, not submitted content.
  • Submitted payloads are not used for training.
  • Submitted payloads are not reviewed by humans.
  • This skill does not target sensitive data.
  • The response does not contain submitted content.
Your responsibility

Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
textstringYesExact message text to measure.
encodingstringNoEncoding policy; omit it for AUTO.
forceConcatenationbooleanNoWhether concatenation capacity is forced; omit it for false.
maxSegmentsintegerNoAdvisory segment ceiling; omit it for the transport maximum.

Output schema

FieldTypeRequiredDescription
encodingstringYesApplied SMS encoding.
segmentsintegerYesBounded SMS count for segments.
charsUsedintegerYesBounded SMS count for charsUsed.
charsPerSegmentintegerYesBounded SMS count for charsPerSegment.
charsRemainingintegerYesBounded SMS count for charsRemaining.
unitsTotalintegerYesBounded SMS count for unitsTotal.
extendedCharCountintegerYesBounded SMS count for extendedCharCount.
nonGsmCharactersarrayYesFrom 0 through the reporting cap distinct non-GSM characters.
concatenatedbooleanYesWhether concatenation overhead was applied.
exceedsMaxSegmentsbooleanYesWhether the advisory segment ceiling was exceeded.
summaryobjectYesClosed summary containing codePointCount, javaCharCount, and encodingSelectedBy properties.

API contract

POST /v1/execute
curl
curl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"communication.sms_segments","input":{"text":"Northwind: order 4417 ships today and arrives Thursday.","encoding":"AUTO"}}'
Integrations
TypeScript SDK
import { Squillify } from "@squillify/sdk";

const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });

const { output } = await sq.execute("communication.sms_segments", {"text":"Northwind: order 4417 ships today and arrives Thursday. Track it at nwnd.co/t/4417, or reply STOP to opt out."});

Errors

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.
SMS_TEXT_TOO_LARGE429NoA size, quota, rate, or time limit was exceeded.
SMS_ENCODING_UNSUPPORTED400NoThe skill does not support the requested variant.
SMS_ENCODING_INCOMPATIBLE412NoThe input is valid but cannot be processed as-is.

Other limits

LimitValue
Recommended inline bytes32 KiB

Limitations

  • Does not send a message, reach a gateway, or open any connection
  • Does not return the split segments — counting is the whole job
  • Does not look up a carrier, a route, a price or a phone number
  • Does not rewrite your text to make it cheaper, and never substitutes a character to squeeze it into GSM-7
  • Does not know what your provider charges per segment
  • Actually sending the message, which needs a gateway we deliberately do not have
  • Getting the segments' text back so you can send them yourself
  • Pricing a message, since what a segment costs is between you and your provider

How to call

POST /v1/execute (requires authentication)

Request bodyjson
{
  "skillKey": "communication.sms_segments",
  "input": {
    "text": "Northwind: order 4417 ships today and arrives Thursday. Track it at nwnd.co/t/4417, or reply STOP to opt out."
  }
}

Examples

A plain transactional alert that fits one GSM-7 segment

Inputjson
{
  "text": "Northwind: order 4417 ships today and arrives Thursday. Track it at nwnd.co/t/4417, or reply STOP to opt out."
}
Expected outputjson
{
  "extendedCharCount": 0,
  "encoding": "GSM7",
  "summary": {
    "javaCharCount": 109,
    "codePointCount": 109,
    "encodingSelectedBy": "AUTO_DETECTED"
  },
  "segments": 1,
  "charsPerSegment": 160,
  "exceedsMaxSegments": false,
  "charsUsed": 109,
  "concatenated": false,
  "nonGsmCharacters": [],
  "charsRemaining": 51,
  "unitsTotal": 109
}
Tip
Every character is in the GSM alphabet, so AUTO chose GSM7 and the message travels alone at the full 160-septet capacity. charsRemaining tells you how much more you could add before a second segment appears.

A campaign with an accent and an emoji, which forces UCS-2

Inputjson
{
  "maxSegments": 2,
  "text": "Rentrée sale — 30% off everything until Sunday 🎉 Shop now at maisonclaire.example/sale and use code RENTREE30 at checkout."
}
Expected outputjson
{
  "extendedCharCount": 0,
  "encoding": "UCS2",
  "summary": {
    "javaCharCount": 123,
    "codePointCount": 122,
    "encodingSelectedBy": "AUTO_DETECTED"
  },
  "segments": 2,
  "charsPerSegment": 67,
  "exceedsMaxSegments": false,
  "charsUsed": 123,
  "concatenated": true,
  "nonGsmCharacters": [
    {
      "char": "—",
      "codePoint": 8212,
      "firstIndex": 13
    },
    {
      "char": "🎉",
      "codePoint": 127881,
      "firstIndex": 47
    }
  ],
  "charsRemaining": 11,
  "unitsTotal": 129
}
Tip
The party-popper emoji lives outside the basic multilingual plane, so it costs two of the 70 and, together with the em dash, drags the whole message into UCS-2 at 67 characters per segment. nonGsmCharacters names exactly which characters did it, and exceedsMaxSegments answers the two-segment budget that was set.
  • Show a live segment count and remaining characters while somebody composes a message
  • Catch the one emoji or curly brace that turned a one-segment alert into three
  • Budget a campaign before you send it, by pricing the segment count per recipient
  • Decide whether a template still fits one segment after you add an opt-out line

Avoid for

  • Actually sending the message, which needs a gateway we deliberately do not have
  • Getting the segments' text back so you can send them yourself
  • Pricing a message, since what a segment costs is between you and your provider

Composable with

Safety & privacy

  • Runs without calling any external service.
  • Your payloads are never stored permanently.
  • Telemetry captures metadata only — never your payload contents.
  • We never train models on your payloads.
  • No human reviews your payloads.

Tags

messaginganalysissmsemailtext