Documentation & Reference

[asknik] Shortcode Reference

Everything you need to install AskNik AI, drop dynamic cached shortcodes into WordPress pages and form workflows, configure connection modes, and troubleshoot responses.

01. 60-Second Quickstart

Install and activate AskNik AI Shortcode (asknik-shortcode), configure your connection mode under Settings → AskNik AI (paste a Google AI Studio Gemini API key for Free/Pro BYOK, or activate Managed mode once Phase 2 Gateway is enabled), and drop [asknik] into any block, page, or template.

Quickstart Example Free & Pro
[asknik prompt="Write a crisp 2-sentence welcome note for our WordPress visitors." model="gemini-2.5-flash" ttl="3600"]

02. Self-Closing vs. Enclosing Block Syntax

WordPress shortcode attributes break when prompts contain nested quotes, multiline templates, or inner shortcodes. Use Self-Closing syntax for simple prompts and Enclosing Block syntax (Pro) whenever you combine dynamic shortcodes or multi-line instructions.

Enclosing Block With Nested Shortcodes Pro
[asknik format="html" lang="auto" cache_ttl="86400"]
Summarize this customer request in 3 reassuring bullets:
Name: [ff_entry field="names"]
Notes: [ff_entry field="message"]
[/asknik]

03. Complete Shortcode Attribute Reference

Attribute Tier Default Behavior & Validation
prompt Free & Pro "" Inline prompt text for self-closing usage.
preset / id Pro "" Loads a saved Prompt Preset from ask_asknik_presets by slug or numeric ID.
model Free & Pro gemini-2.5-flash Overrides the default provider model (locked to Flash-Lite on Free Starter).
system Free & Pro "" Optional system instruction passed cleanly via provider systemInstruction.
temp / temperature Free & Pro 0.7 Float clamped between 0.0 (factual/deterministic) and 2.0 (creative).
max_tokens Free & Pro Provider default Positive integer capping maxOutputTokens (hard-capped on Free Starter).
cache Free & Pro yes yes or no. Forced yes (86400s) on Free Starter; configurable in BYOK/Pro.
ttl / cache_ttl Free & Pro 3600 Transient cache lifetime in seconds (0 disables caching where permitted).
lang Pro site auto (mirror submission language), site (WP locale), or explicit ISO code.
format Pro text text, html, markdown (wp_kses_post safe), list, json, or email (inline-CSS card).
render Pro sync sync (server PHP — forced in emails/PDFs) or async (non-blocking shimmer via REST).
files Pro "" Comma-separated attachment ID(s) or allowlisted image/PDF URLs (max 5MB).
fallback Free & Pro Global fallback Visitor-safe fallback text if upstream times out or hits a rate limit.

04. Context Tokens, Async Rendering & Form Hooks (Pro)

In addition to nested WordPress shortcodes, Pro resolves built-in context tokens safely on the server prior to SHA-256 cache hashing:

  • Post / Page: {{post_id}}, {{post_title}}, {{post_excerpt}}, {{post_url}}, {{post_author}}
  • Current User: {{user_first_name}}, {{user_display_name}}, {{user_role}}
  • URL Query Params: {{url_param:key}} (sanitized via sanitize_text_field with strict length caps)

When using render="async" on uncached pages, PHP stores the resolved prompt server-side behind a 5-minute 32-character transient token (asknik_async_{token}) and renders a shimmer placeholder while POST /wp-json/asknik/v1/render fetches and caches the response—preventing any client-side prompt tampering. Inside email notifications or PDF generators, AskNik automatically forces render="sync".

05. Connection Modes (Starter, BYOK & Pro Managed)

Mode A · Phase 2

Free Starter

Zero-setup managed starter gateway capped at 20 uncached calls/day (250/month), 800 in / 1,200 out chars, and forced 24h caching.

Mode B · Free & Pro

BYOK

Connect your own Gemini API key (plus Claude & OpenAI in V1.1). Direct server-to-provider requests with 0% token markup.

Mode C · Phase 2

Pro Managed

Identical 100% Pro feature set paired with ~2,500 monthly managed AI credits provisioned via Freemius & asknik.ai.

06. Caching & Security Guardrails

  • Deterministic Cache Keys: Keys use asknik_sc_ + a 32-character SHA-256 hash of provider, resolved prompt, and sorted options—accelerated automatically by Redis or Memcached object caches.
  • Multimodal SSRF Hardening: files="..." restricts inputs to local WordPress uploads or allowlisted CDN domains, verifying MIME types (image/jpeg, image/png, image/webp, application/pdf) and a 5MB ceiling.
  • Visitor-Safe Errors: Raw provider error messages are only shown to authenticated administrators with manage_options. Public visitors see your clean fallback string or an empty container.

07. Troubleshooting

Shortcode outputs nothing on the frontend

Log in as an administrator (manage_options) and refresh the page to inspect the inline .asknik-error diagnostic. Most commonly, the Gemini API key in Settings → AskNik AI is blank or the prompt attribute is empty.

My prompt changes aren’t showing up immediately

Check your ttl attribute or global Cache TTL setting. Changing any word in the prompt or options automatically generates a fresh SHA-256 cache key, or temporarily set ttl="0" while testing in BYOK mode.

Quotes inside prompt="..." are breaking the shortcode

Switch to the enclosing block syntax [asknik]...[/asknik] so WordPress parses multiline text, double quotes, and nested shortcodes cleanly without attribute truncation.

60-Second Rule

Ready to put [asknik] to work?

Start free with zero developer console friction, or unlock 100% of Pro features via Pro BYOK or Pro Managed.