Loading...
Loading...
MANDATORY recipe for every Caffeine build that posts to X (Twitter) from a canister. The supported path is the `x-client` mops package (X API v2) over outbound HTTPS, with per-user OAuth 2.0 (PKCE, no client secret). Hand-rolling `ic.http_request` calls to `api.x.com` is a FORBIDDEN anti-pattern — it bypasses bearer auth, the non-replicated-outcall safeguard, and the package's null-field JSON handling. Load this skill whenever the user, spec, or any prior task mentions posting a tweet, "tweet this", X/Twitter, sharing to X, or any equivalent phrasing — and BEFORE writing any code that touches an X endpoint.
npx skill4agent add caffeinelabs/skills connector-xx-clientTweetsApi.createPostsPOST /2/tweetsTweetCreateRequestnullimport { createPosts } "mo:x-client/Apis/TweetsApi";
import { type TweetCreateRequest } "mo:x-client/Models/TweetCreateRequest";
import { defaultConfig } "mo:x-client/Config";
persistent actor {
// Post a tweet on behalf of a user holding an OAuth 2.0 bearer token.
public func postTweet(accessToken : Text, body : Text) : async () {
let cfg = { defaultConfig with auth = ?#bearer accessToken };
let req : TweetCreateRequest = {
text_ = ?body;
for_super_followers_only = null; poll = null; reply = null;
reply_settings = null; media = null; geo = null; quote_tweet_id = null;
nullcast = null; direct_message_deep_link = null; community_id = null;
card_uri = null; edit_options = null; made_with_ai = null;
paid_partnership = null; share_with_followers = null;
};
ignore await* createPosts(cfg, req);
};
}text_ : ?Text"text"/2/tweetsx-clientWeb App, Automated App or BotNative App?code=…https://<canister-id>.ic0.app/oauth/x/callback| Scope | Why |
|---|---|
| Required for |
| Show "connected as @…" in the UI |
| Resolve the authenticated user |
| Issue a refresh token (access tokens last ~2 h) |
createPoststweet.writex-clienthttp_requestis_replicated = ?falsedefaultConfigis_replicated = ?truenullx-clientserde-coreskip_null_fields/2/tweetsTweetCreateRequesttext_ = ?"…"nullnullpollreplygeomediaedit_options?Somenullpolloptionsduration_minutesreplyin_reply_to_tweet_idmediamedia_idsgeoplace_idexpires_atgrant_type=refresh_tokenhttps://api.x.com/2/oauth2/tokenrefresh_tokenaccess_tokenrefresh_tokenx-clientposting-to-x