Working with promo codes
The bot allows not only to give promo codes to clients, but also check their validity and control their one-time use
You can give a promo code to a client one of two ways:
Prepare a list of promo codes in a Google Sheet, train salebot to find an available code, give it to a client and then mark it as an issued one in the doc;
Train Salebot to generate it by following certain rules, give it to the client and then mark it in the doc.
You can check the codes’ validity with the use of Google Sheets and its API requests.
You can learn all about these processes below.
How to check the promo code from Google Sheets
If you have an objective to limit access to the bot or special offers, you can use the function of checking promo codes.
Prepare a Google Sheet in which one column will be a list of your promo codes. Set the access setting to “Anyone with this link can edit”. How to do this, read in this article
This is how the function works: A client pastes their promo code into the bot, the function checks whether or not the code is in the column that you created. If the code is found, then a line “Promo code was used” is added to the neighboring cell and then the function returns this reply:
{“status”: ‘’0’’}
Function address: https://store.salebot.ai/function/check-promocode
To check the code you need to send these parameters from the block:
{"id":"1HfnHDbJYTGz68-3KWIcRISncTmdEn8v7Vf_OKvDMrOI", "promocode": "#{question}", "col_number": "1"}
id is the id of your Google Sheet where you put your codes. You can get it from the link to your doc. The doc itself has to be open for editing to anyone who has the link.
If the promo codes are situated in a separate sheet, then you need to use the parameter list_name, in which you have to place its name, for example:
{"id":"1HfnHDbJYTGz68-3KWIcRISncTmdEn8v7Vf_OKvDMrOI", "promocode": "#{question}", "col_number": "1", "list_name": "Sheet name"}
The next parameter is the promo code that the client applies.
col_number - is the number of the column that holds the codes
{“status”: ‘’1’’}
, after that you can’t apply the code for the second time
If the function doesn’t find the promo code in the sheet or it’s been used already, then it replies with
{“status”: ‘’0’’}
If you’re wondering how to use this and where to place this, look at the screenshot below
#{custom_answer} - the answer from the server that’s mentioned in the tab “URL request”
Use this variable in the answer tab to see what’s located in it. If you’ve done everything correctly, then you can save status->status, and in the arrows in the tab “Variable for comparison” set the values to "status == 0" (and reply to the user that the code has been used) or "status == 1" (the user moves further). The example is below
How to give a promo code from Google Sheets
Prepare your sheet like in the image below. Promo codes in the first column and in the second a mark “Available”. Set up access settings to “Anyone on the Internet with this link can edit”. How to do this, read in this article
You will get a link similar to this:
https://docs.google.com/spreadsheets/d/1HfnHDbJYTGz68-3KWIcRISncTmdEn8v7Vf_OKvDMrOI/edit?usp=sharing
The bold text here is the id of your page. You’ll need it later.
Create a block on Salebot and in its settings paste these parameters:
Request type: POST-json
URL request: https://store.salebot.ai/function/findcell
Stored values:
data->Promo code;
cell_number|row ->line;
JSON parameters:
{"id": "1HfnHDbJYTGz68-3KWIcRISncTmdEn8v7Vf_OKvDMrOI", "find": "Available", "col": 2, "return": 1}
where you need to place your own page id instead of 1HfnHDbJYTGz68-3KWIcRISncTmdEn8v7Vf_OKvDMrOI
Create a block below and in the connection settings click on “Time settings”. In the opened section in the tab “Delay before answer” type -1, so the move happens as fast as possible.
In the new block, set the parameters mentioned below.
To show the client their code, type #{Promo_code}
Request type: POST-json
URL request: https://store.salebot.ai/function/gsheets
JSON parameters:
{"id": "1HfnHDbJYTGz68-3KWIcRISncTmdEn8v7Vf_OKvDMrOI", "write":{"b#{line}":"Used"}}
where you need to place your own page id instead of 1HfnHDbJYTGz68-3KWIcRISncTmdEn8v7Vf_OKvDMrOI
How to generate a promo code with the help of Salebot
If the promo code can be created with certain rules, then you can generate them right in Salebot and write them down in Google Sheets for later checking.
We’ll need variables for this. For example, to generate a unique promo code, we can use the variable #{client_id}. It’s a variable in Salebot that indicates your client’s number in the system.
In the block’s settings Advanced -> Calculator write down:
Promocode = promo#{client_id}
In the field "Answer" paste #{Promo_code}
In my case, you’ll get a promo code promo1330882.
If you want to add a more random aspect to your code, then you can add the call of the function random()
Promocode = 'promo' + '#{client_id}' + random(0,10)
In this case, it adds 1 random number in the end
Now let’s paste it to our sheet of codes.
To begin, you need to create a blank Google Sheet doc. The same access settings of “Anyone on the Internet with this link can edit”. Type the words Promo codes in the A1 cell
If the first cell is empty, then the function won’t work, so don’t forget to fill it in
You will get a link similar to this:
https://docs.google.com/spreadsheets/d/1HfnHDbJYTGz68-3KWIcRISncTmdEn8v7Vf_OKvDMrOI/edit?usp=sharing
The bold text here is the id of your page. You’ll need it later.
Now let’s get back to Salebot and continue working on your block with the promo code
Request type: POST-json
URL request: https://store.salebot.ai/function/gsheets
JSON parameters:
{"id": "1sl15vKFjo5TFD98GnVjF3AlLtdhr85-AkEjoeJkgDxE", "mapping":{"a":"#{Promo_code}"}}
Where you need to place your own page id instead of 1HfnHDbJYTGz68-3KWIcRISncTmdEn8v7Vf_OKvDMrOI
You have to create something like this:
Last updated