Articles on: AI Chatbot & Automations

How to start Workflows programmatically (without the user sending a message)

This guide will focus on triggering a scenario programmatically from your website's code, by using Javascript. This can help you offer choices or collecting information from your users even before they've sent a message (when opening the chatbox for instance)


Workflows are no-code procedural automations, they are designed to help you automate processes and be versatile enough to accommodate any type of usages.

By simply selecting and connecting specialized blocks together, you can create a series of events, conditions and actions which allow you to build automations and trigger them automatically in your conversations


Whether you wish to automatically qualify users starting a conversation, filter or categorize their requests, collect information or offer them choice-based paths, workflows can do this before they've even had breakfast.


Just discovering Workflows? Learn more from this guide



Starting Workflows programmatically without the user sending a message


in some cases, you may be looking to start workflows programmatically before the user has even sent a message.


Some examples would include:

  • Directly displaying buttons inside of the chatbox when the user first opens it
  • Triggering a scenario during the user's navigation on your platform


This is possible by using our Javascript SDK, which exposes a dedicated method to start scenarios


Note that for a scenario to be started with the JS SDK, it must start with an Action block.


To do so, simply:

  1. Create a scenario starting with an action block and deploy it
  2. Copy its ID from the main Workflow Builder menu
  3. Use that ID inside of the dedicated SDK method, to be executed by your code during runtime


Here is an example for a situation where we wish to trigger it whenever the user opens the chatbox:

$crisp.push(["on", "chat:opened", function() {
$crisp.push(["do", "bot:scenario:run", ["scenario_85c6438c-2310-4d2c-b4dc-c8f8a76d2d19"]]);
}]);





Frequently Asked Questions


Still have some questions which were not covered above? Perhaps you'll find our answer in this FAQ. Also checkout this article and master your workflows craftsmanship!

If your question does not figure here, share it with us directly by chat, we'll be available to assist you


I am using the SDK correctly but my Bot is not starting, why is that?


This can be troubleshooted by following a few steps.

  1. Ensure that your scenario was properly saved and deployed. You can also verify that it is enabled from the Scenario Manager view.
  2. Make sure that your using the correct Scenario ID as well (this is a common mistake).
  3. A scenario will not start if an operator has sent a message during the past 20 minutes, you can hover messages in that conversation to view the timestamps if you have any doubt. Also note that if you use a "Exit Block - Stop Scenario" at the end of your flow, it will prevent your scenario from triggering again during the next 24 hours, if it already ran once during this conversation.
  4. Finally, there could be an issue in your code, in the place where you are using the SDK to fire your scenario, make sure to follow good practices to easily debug your code.



I don't have access to the code of my website, is there any other way to use the SDK?


While using the SDK requires having access to the code of your website or application, you can also do with Google Tag Manager and similar tools if these are used on your website.

In GTM, you can create a "Custom HTML" tag to execute any SDK command, provided that Crisp is loaded on the page where you are injecting GTM. The Tags you create can be associated with a "Trigger" in order to determine how and when it should be executed.


For instance, to push a Crisp Event named "my-event" with GTM, you can create a "Custom HTML" Tag containing:

<script>
$crisp.push(["do", "bot:scenario:run", ["your-scenario_id"]]);
</script>



What else can I do with the SDK?


There are loads of possibilities with the SDK! You can programmatically open and close the chatbox, hide it, push custom data and segments, and much more. The SDK also allows you to listen to some events, in order to execute code when a user opens the chatbox, or when Crisp has loaded on your page.


You can read more about the SDK in our Developer's Hub, it provides a very useful set of tools!

Updated on: 28/01/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!