Greeting from Code
The welcome parameter selects the greeting for a new dialog. To choose automatically based on visitor data, use settings based on website conditions.
Choose a greeting
In channel settings, configure one default greeting and optionally add additional starting messages. The default can display centered text or an automation message. Each additional message is an exact automation and step pair; you can select steps from different automations in the project. The default automation message is allowed automatically and does not need to be added again.
The welcome parameter in init selects the greeting for the current widget instance. Omitting it inherits channel settings. For centered text, set welcome: { mode: "centered_text" }. Configure the text, suggestions and image through the existing theme fields.
To select an allowed message, pass both IDs:
SenlerWidget.init({
channel_id: "YOUR_CHANNEL_ID",
welcome: {
mode: "automation_message",
automation_id: "AUTOMATION_ID",
node_id: "MESSAGE_STEP_UUID",
},
});
The automation must belong to the channel's project, be running and support the widget channel. Its published version must contain a Message step for the current dialog, without a quote of the source message, dynamic buttons or attachments from variables, or dialog.*, run.*, and trigger.* variables. You can select an eligible step in channel settings. The server supplies the text, buttons, attachments, sender name and avatar. You do not need to provide them or a version ID separately.
Change the selection on the page without repeating init or requesting your site's backend:
SenlerWidget.configure({
welcome: {
mode: "automation_message",
automation_id: "AUTOMATION_ID",
node_id: "MESSAGE_STEP_UUID",
},
});
SenlerWidget.configure({ welcome: { mode: "centered_text" } });
SenlerWidget.configure({ welcome: null }); // Restore the greeting from channel settings
Before a dialog starts, switching immediately changes the greeting. In an existing dialog, history is preserved and the selection applies to the next new dialog. Omitting welcome in configure keeps the current selection; null resets it to channel settings. open() only shows the widget.
All allowed messages are available to every visitor of this widget. JavaScript selection conditions do not restrict access for individual users. No separate greeting signature is needed; existing user_hash authentication continues to verify the user.
The server checks the selected pair both when displaying it and on the first reaction. If the message is not allowed, the automation is stopped or the step is unavailable, the widget shows an error and does not start the scenario. Removing a message from the allowed list also prevents an already displayed greeting from starting it.
Displaying or switching a greeting does not create a dialog or start the automation. After the first reaction, continuation follows the selected button or the reply wait in the displayed step; without a reply wait, normal agent response rules apply. Channel settings stay unchanged.
The step's Wait for a reply after a button click setting also applies to this greeting: the button starts its branch, and the visitor's next message starts Reply. No separate init parameter is needed.
In a tab that has been open for a long time, an expired greeting is refreshed before sending. The widget asks the visitor to reply again so they can see the updated message first.
Messages After the Conversation Starts
After the visitor's first reply, messages can be sent through a regular Message step in a running automation. For example, connect a greeting's answer option to the next message or configure a trigger for an incoming message. Set the step's recipient to Current dialog.
Changing welcome through init, configure, or resolveRuntime does not add an automation message to an existing conversation's history. It selects a greeting for a new chat. The ask method sends a question on behalf of the visitor, not an automation message.