extension-email-marketing
Send personalised marketing emails to subscribers with an unsubscribe link.
extension-http-outcalls
HTTP outcalls performed by the backend canister (not in the frontend).
Full skill instructions
HTTP outcalls extension for Caffeine AI.
This skill covers the requirements for HTTP requests from the backend canister, including GET, HEAD, POST, PUT, DELETE, and PATCH. Use it whenever integrating with an external API or service.
Follow these rules:
check_canister_api_compliance. It probes the
endpoint and measures the response against those limits, and it runs behind
the deploy gate, so an endpoint it refuses cannot ship.The 1 MB and 10_000-entry limits above are the module's own ceilings —
defaultMaxResponseBytes is 1 MB — and check_canister_api_compliance measures
against exactly those two numbers. It refuses earlier than they do: when the URL
carries no server-side bound, it blocks as soon as the probed response is
already past a quarter of the byte ceiling or past 1_000 entries. That band is
the dangerous one, because it passes a one-off curl and then grows until the
canister exceeds its per-message instruction budget parsing the payload. Design
to the stricter bound: bound the request server-side.
A flight lookup takes a flight number and must return one aircraft. Fetching
https://opensky-network.org/api/states/all — every aircraft airborne
worldwide, roughly 10-13k rows — and scanning the parsed result in Motoko for
the one callsign is wrong. The canister downloads and parses every record in
the world to answer a single lookup, and the message is rejected:
IC0522: Canister exceeded the limit of 40000000000 instructions for single message execution. Nothing about the code looks wrong — the URL is valid, the
parse compiles, and a one-off curl returns 200.
That is an instruction limit, not a byte limit. Reaching for a smaller page size does not help: the canister still walks the whole collection to find one row.
The provider already offered the right bound. ?icao24=<hex> on the same
endpoint is the identifier bound: kilobytes, one aircraft, one record to parse.
For HTTP outcalls that must be performed in the backend:
The existing module mo:caffeineai-http-outcalls/outcall.mo provides a generic
bounded request function for every HTTP method supported by the IC, plus
backward-compatible GET and POST helpers.
module {
public type TransformationInput = {
context : Blob;
response : IC.HttpRequestResult;
};
public type TransformationOutput = IC.HttpRequestResult;
public type Transform = query TransformationInput -> async TransformationOutput;
public type Header = {
name: Text;
value: Text;
};
public type Method = {
#get;
#head;
#post;
#put;
#delete;
#patch;
};
public type Request = {
url : Text;
method : Method;
headers : [Header];
body : ?Blob;
maxResponseBytes : Nat64;
transform : Transform;
};
public type Response = IC.HttpRequestResult;
public let defaultMaxResponseBytes : Nat64;
// Helper function for the transform callback used by the IC on HTTP outcalls.
public func transform(input : TransformationInput) : TransformationOutput;
// Generic bounded request supporting GET, HEAD, POST, PUT, DELETE, and PATCH.
public func httpRequest(request : Request) : async Response;
// HTTP GET request with a transform callback function.
public func httpGetRequest(url : Text, extraHeaders: [Header], transform : Transform) : async Text;
// HTTP POST request, specifying a transform callback.
public func httpPostRequest(url : Text, extraHeaders: [Header], body : Text, transform : Transform) : async Text;
};
Use httpRequest when the status, headers, a custom response limit, or a method
other than GET or POST is needed. maxResponseBytes may set a lower limit; the
module caps every request at defaultMaxResponseBytes (1 MB). The module
executes every HTTP outcall with is_replicated = ?false; callers cannot enable
replicated execution. The backward-compatible helper stays the shortest path for
a simple GET:
import Text "mo:core/Text";
import OutCall "mo:caffeineai-http-outcalls/outcall";
actor {
public query func transform(input: OutCall.TransformationInput) : async OutCall.TransformationOutput {
OutCall.transform(input);
};
func setItemActive() : async OutCall.Response {
await OutCall.httpRequest({
url = "https://api.example.com/items/123";
method = #patch;
headers = [{ name = "Content-Type"; value = "application/json" }];
body = ?("{\"active\":true}".encodeUtf8());
maxResponseBytes = 100_000;
transform;
});
};
func makeGetOutcall(url: Text) : async Text {
await OutCall.httpGetRequest(url, [], transform);
};
};
POST usage through httpPostRequest is analogous.
Before considering an HTTP outcall complete, execute the equivalent request
locally with curl. Do not rely only on remembered API documentation or on the
Motoko code compiling. Every check below is required. If any check fails, the
HTTP outcall is incomplete and MUST NOT proceed to deployment.
curl --fail-with-body --silent --show-error. Verify
the successful status plus every response field and type consumed by the
app. A response that is merely valid JSON is not sufficient.check_canister_api_compliance on the exact URL and method the
implementation uses. It measures the response against the outcall byte
ceiling and entry bound and reports whether the URL is bounded server-side,
mechanically and behind the deploy gate, so an outcall to a host it never
cleared cannot ship. When it refuses an endpoint, choose a compatible public
API or narrow the feature honestly; do not implement an unbounded fetch-all
request and filter it in the canister.Response bounds are that check's job, not curl's. The checks above are the ones it cannot do for you: it probes the endpoint, not the app, so it never learns which response fields the app reads or what the user typed to produce the URL.
If the request fails or any check above is unmet, inspect the status and
response body. Check the provider's current official API documentation and
release or migration notes with web search. Confirm the current API version,
endpoint, parameter names and formats, required headers, and request body. Do
not guess around failures. Fix the Motoko request to match the working REST
request and rerun curl; repeat until all checks pass, then rerun the backend
checks. Never report completion while any required check is missing or failed.
Typical failure clues: 400 indicates invalid parameters or body shape;
404/410 often indicates an obsolete endpoint or API version; 405
indicates the wrong method; and 415 indicates the wrong content type. Treat
429 and 5xx responses as quota or provider availability issues only after
confirming the request against current official documentation.
Send personalised marketing emails to subscribers with an unsubscribe link.
Support for sending an email with a link the recipient can click to prove they own the email address.
General file/object storage, such as for images, videos, files, documents and other bulk data. Perfect fit for image galleries, video galleries, and other file or object management. Supports large files beyond IC limit, with browser-cached HTTP URL access.
Authorization system with role-based access control. Must-have for all apps that manage personal or access-restricted data.
Support for sending service/transactional emails. Don't use this for sending marketing emails or verification emails.
Core infrastructure providing backend connection configuration, storage client, and React app entry point.
Requests invite-link / RSVP based access where guests can submit responses without login while admin can view responses with login.
Approval-based user management.
Send an email with multiple to, cc and bcc addresses.
MANDATORY recipe for every Caffeine build that calls OpenAI (ChatGPT, GPT-4o, an LLM, a chatbot, embeddings). The ONLY supported path is the `openai-client` mops package with a canister-side API-key bearer. Hand-rolling `ic.http_request` to `api.openai.com/v1/...` is a FORBIDDEN anti-pattern — it leaks the bearer across replicated outcalls (security + 13× billing impact), bypasses the typed request/response bindings, and forces hand-rolled JSON on a language with poor JSON support. Load this skill whenever the user, spec, or any prior task mentions ChatGPT, GPT (any version), OpenAI, an LLM, a chatbot, or embeddings — and BEFORE writing any code that touches `api.openai.com`.
MANDATORY recipe for every Caffeine build that posts to X (Twitter). The ONLY supported path is the `x-client` mops package with OAuth 2.0 PKCE. Hand-rolling `ic.http_request` or `icBooking.http_request` calls to `api.x.com/2/tweets`, `api.x.com/2/oauth2/token`, or any other X endpoint is a FORBIDDEN anti-pattern — it bypasses bearer auth, replication-cost safeguards, and `x-client`'s null-field handling. Load this skill whenever the user, spec, or any prior task mentions tweeting, live-tweeting, posting-to-X, posting-a-status, sharing-to-Twitter, or any equivalent phrasing — and BEFORE writing any code that touches `api.x.com`.
Make a canister's data queryable by the Caffeine Data Intelligence agent. Use whenever an app stores structured data (Maps/Lists/arrays of records) that should be answerable in natural language — "top customers", "revenue by region", "active projects". Adds a discoverable `schema()` and a JSON `execute()` query endpoint via the `caffeineai-oql` mops package's `Expose` mixin.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience