Skip to content

Integration guide

Asklify + WordPress

Two options: paste the snippet with any header/footer plugin (no code), or register the script properly in your theme. Both take minutes.

Prerequisite: an Asklify project with some knowledge added — the quickstart covers that in a couple of minutes. You'll need your public project ID (pub_...) from Widget → Install.
1

No-code: header & footer plugin

Install any “insert headers and footers” plugin (e.g. WPCode), paste the embed snippet into the Footer section, and save. Done.

2

Theme code: enqueue the script

For version-controlled themes, add the template below to functions.php — it loads the widget on every page with the correct attributes.

3

Optional shortcode for landing pages

functions.php (shortcode)
// Use [asklify] on specific pages instead of loading site-wide.
add_shortcode( 'asklify', function () {
  ob_start(); ?>
  <script
    src="https://api.asklify.in/widget.js"
    data-project-id="pub_YOUR_PROJECT_ID"
    defer
  ></script>
  <?php return ob_get_clean();
} );

Ready-to-use template

Copy, paste, replace the project ID — that's the whole integration:

functions.php
/**
 * Asklify chat assistant.
 */
function asklify_enqueue_widget() {
  wp_enqueue_script(
    'asklify-widget',
    'https://api.asklify.in/widget.js',
    array(),
    null,
    array( 'in_footer' => true, 'strategy' => 'defer' )
  );
}
add_action( 'wp_enqueue_scripts', 'asklify_enqueue_widget' );

// Add the data-project-id attribute to the script tag.
function asklify_script_attributes( $tag, $handle ) {
  if ( 'asklify-widget' === $handle ) {
    $tag = str_replace(
      ' src=',
      ' data-project-id="pub_YOUR_PROJECT_ID" src=',
      $tag
    );
  }
  return $tag;
}
add_filter( 'script_loader_tag', 'asklify_script_attributes', 10, 2 );

Customization

All appearance and behavior — name, greeting, colors, theme, position, suggested questions — is configured in your dashboard under Widget settings and applies instantly without redeploying. See the widget configuration reference.

Event handling

To react to what happens in conversations — a chat starting, a customer requesting a human, feedback submitted — subscribe to webhooks. For fully custom experiences, the REST API exposes chat with streaming, knowledge search, and conversation transcripts.

Best practices

  • Train the assistant on your site by pointing Website ingestion at your WordPress sitemap (usually /wp-sitemap.xml).
  • Caching plugins are fine — the loader is a static script; just purge cache after adding it.

Troubleshooting

  • Snippet stripped when saving — WordPress editors strip <script> tags for non-admin roles; use the plugin approach or functions.php.
  • Widget missing on some pages — another plugin may defer/concatenate scripts incorrectly; exclude 'asklify-widget' from optimization plugins.

Still stuck? Check the error reference or email hello@asklify.in.