Skip Welcome Message

Cesar Banchio Updated by Cesar Banchio

To skip the welcome message and directly begin the flow with other blocks we'll need to use Javascript in the Custom Javascript section of the bot, as well as CSS

This is how the flow will look like

Key Considerations

  • A welcome message is still required to publish the bot, but weโ€™ll hide it using CSS.
  • The flow starts at the Global Keyword, which must be set to default.
  • URL parameters will not be available until after a real user input.

Step 1: Add CSS

In the "Add CSS" section of the bot's Design settings, insert the following code to hide the welcome message:

[data-block="welcome"] { display:none!important;}

Step 2: Add JavaScript

There are two possible scenarios based on how the bot is embedded:

Case 1: Embedded Without Popup or Live Chat
Because we're simulating a user input with code, every time the page is loaded it will be counted as a chat

Insert the following JavaScript:

<script>
var landbotScope = this;
this.onLoad(function(){

landbotScope.core.events.on("init", () => {

landbotScope.core.sendMessage({ type: 'hidden', payload: "default" })
}
)
})
</script>

Case 2: Popup or Live Chat Mode

Use the following JavaScript:

<script>  
const sendMessage = () => {
this.core.sendMessage({
type: 'hidden',
message: 'default!',
payload: 'default',
})
}
const findWelcome = () => {
let open = this.window.document.getElementsByClassName('is-open')[0]
if(open) {
setTimeout(sendMessage, 500)
clearInterval(id)
}
}

let id = setInterval(findWelcome, 500)
</script>

This is how the Custom Code Section will look like:

Important Notes

  • Testing: This method cannot be tested in preview modeโ€”it must be tested via a URL or an embedded page.
  • Customizing the Flow: After the Global Keyword, you can build any flow you want.

By following these steps, your bot will skip the welcome message and start the conversation automatically! ๐Ÿš€

Was this article helpful?

Contact