Advanced Usage

Show a Typeform survey on cancellation

Using the handleResponse option and the Typeform modal embed, you can show a survey to users on cancellation to learn more about why the cancelled. Check out the example!


Render a React app on an event such as pre_load.

Let take a look at an example that will render a React app on an event such as pre_load.

First, you need to create your app and make your mounting function named mountMyReactApp() that is accessible from the HTML file. This example simply defines a globally accessible function.

//You react app
const App = () => {
return <div>
<h2>Pre_load React App</h2>
//Define a globally accessible mounting function
var mountMyReactApp = () => {
console.log('mountMyReactApp called')
//Renders your react app
ReactDOM.render(<App />, document.getElementById('your-app-root'))

Depending on how you structure your app/website, you can call your mount react app function in other ways, this is just one simple example of how it could be done.

Then in your embed code for Servicebot, you would add the handleResponse setting like below, which will call the mounting function mountMyReactApp()defined above if the pre_load event is fired.

<div id="your-app-root"></div>
<div id="servicebot-subscription-portal"></div>
window.servicebotSettings = {
handleResponse: async function(payload){
if(payload.event == 'pre_load') {