Use Google Cloud Functions to set directly new values to Landbot variables
Here, you can find another approach that allow you to use a new value without the need of a user input.
In this example, we are going to ask for a date and, if the user has selected a weekend, we will force the user to select another date showing again the date picker.
Below the flow:
- Select Date Question (in this case we will use the MM/DD/YYYY format);
- Add a Webhook block (add a fake url, so we can Save temporarily we will change it later on);
- Set up a Conditional block with the desired value, in this case will be @isweekend;
- If True (Green Dot) we will create a flow to continue as normal.
- If False (Red Output) we will display a Error Message suggesting to select another date and connect it to the date question.
- At this point we will need a Google Cloud Function, here we will create the script that will check the day of the week and return True or False (as a String, Landbot doesn't recognise Boolean values, and transforms true to True and false to False);
- Once the Function is deployed, we can get the Endpoint from the Trigger section;
- Now, we return to the Webhook block to test the Endpoint with the body, so we can get variable where we are going to store the @isweekend value;
And we will Test to set up the Landbot variable;
- Once the Save response is set up correctly, we can set the body with the variable from the Date question and Save the Webhook;
- Finally we can run the bot: