Unique Set of Number - CodelessBot

What Does This Plugin Do?

BETA

This plugin will send back a random and unique set of numbers from a specific range. In other words – no duplicate random numbers!

Level of Difficulty: Medium

Compatibility: Chatfuel, ManyChat

Plugin Request URL
  • Chatfuel: https://api.codelessbot.com/v1/chatfuel/number/deal-cards?accesskey={{cbot_accesskey}}&secretkey={{cbot_secretkey}}
  • ManyChat: https://api.codelessbot.com/v1/manychat/number/deal-cards?accesskey=YOURACCESSKEY&secretkey=YOURACCESSKEY

Example Use Cases

Quiz with Random Different Questions

Send each of your students a different set of questions pulled from a “bank of questions”

Card Deal

Creating a card game? Use this plugin to help you “shuffle and deal” from a deck of cards

How-To Setup the Plugin

Follow the 3 Simple Steps...or Login to CodelessBot to access the Plugin Wizard!

Step 1. Download & Install the Quick-Start Plugin Template

Login to CodelessBot, navigate to Templates on the sidebar and download the Quick-Start Template. Follow the prompt to install the Template. Next, you'll need to create a copy of the template for this specific plugin. See and follow the instructions below.

(If you've already install the Quick Start Template and created a copy of the plugin template - skip this step!

Chatfuel Instructions

a. From your Chatfuel dashboard, open the new bot called "JSON API Tutorial & CodelessBot Template" 

b. Find the group containing the name of this plugin.

c. Click on the arrow next to the plugin name to clone this group and blocks from the template into your own Chatfuel Bot.

d. Navigate back to the Chatfuel Dashboard

e. Open your Bot and find the new plugin group that you just cloned. 

f. Open the new Plugin block and enter in your CodelessBot access key and secret key.

Tip: Rename the plugin block to something more meaningful. For more details, refer to the Getting Started Guide.

ManyChat Instructions

After you download and installed the Quick Start Template...

  1. From the ManyChat sidebar, click on the Flows"
  2. Open the folder "CodelessBot Templates"
  3. Find the flow containing the name of this plugin. 
  4. Create a copy by click on the three dots icon on the right
  5. Then click on duplicate
  6. Feel free to rename this new flow and move it to a different folder
  7. Open up the flow and click on the "Starting Step" to modify the information you'll be sending to CodelessBot

For more details, refer to the Getting Started Guide.

Step 2. Send information to CodelessBot

To quickly do this, use the Plugin Wizard to answer a few questions. It'll then generate the code with the information below for you to copy and paste into your bot.

cbot_min

The lowest possible value for the random numbers.

More Detail

Value must not be less than 0.

cbot_return

A comma-separated list of attributes/variables to return the random numbers.

More Detail

The maximum number of attributes/variables is 30.

For Chatfuel, you’ll need to enter in the exact user attribute that you want assigned the random number.

For ManyChat, you can simply enter in temp1, temp2, temp3…etc. The number of “temp” will depend on the number of random numbers you want to be sent back.

cbot_max

The highest possible value for the random numbers.

More Detail

Value must not be more than 500.

Chatfuel Instructions
  1. In this plugin block, scroll down to the "JSON API" card
  2. Copy and paste the code from the Plugin Wizard into the textbox. (Or you can enter the correct value by referring to the descriptions above.)

Tip: Make sure the "Send as" is set to JSON. Not URL encoded or Full JSON Profile.

ManyChat Instructions

a. Click over to the "Body" tab in this external request 

b. Next, copy and paste the code from the Plugin Wizard into the "Request Body". (Or you can enter the correct value by referring to the descriptions above.)

c. If there are any "Replace With placeholder" in the code, you'll need to replace them with the correct matching custom field by clicking on "Add a Variable".

d. To check if you set this up correctly, click on "Test the Request" on the right and you should get a success "200 OK" response

e. Click on the blue "Save" button

Step 3. CodelessBot will reply with the "answer"

CodelessBot will reply back with the following information:

All Custom Fields/Attributes listed in cbot_return

The custom fields/attributes listed in cbot_return will be set with a random number within the range cbot_min to cbot_max.

Chatfuel Instructions

CodelessBot will automatically set any user attributes listed in “cbot_return” with a random value within your specified range. After this JSON API card, you can add additional cards to:

  1. Send a message to the user with the result
  2. Add a new card “Go To Block” with a condition to redirect users to a different blocks depending on the result

Note: These are just some ideas. You are not limited by the 2 ideas above.

ManyChat Instructions

Finally, to save and make use of the results, you’ll need to map the CodelessBot temp responses to actual ManyChat custom fields. To do this:

a. Click over to the “Response mapping” tab. CodelessBot will send back the results using temporary variable (eg. temp1, temp2, temp3…etc). These variables are all listed in the column JSONPath.

b. For each temp listed in the JSONPath, select the ManyChat custom field you want to use to store the value from CodelessBot.

c. If you entered more than 3 temp custom fields for cbot_return in Step 2, just click on “+Add” button and enter in additional temp fields. Just be sure to follow the format and start with $.

d. Click on “Save” when you’re done. After this external request step, you can add a next step where you’re:

  1. Sending a message to share the results with users
  2. Add a new Condition step to redirect users to a different step or flow depending on the result

More Information

FAQs

1. Can I use any attribute name for cbot_return values?

You must not use the reserved prefix “cbot_rsp”; e.g cbot_rsp, cbot_rsp_number1

2. What's the max number of "cards" I can get back?

You may specify up to 30 attributes/variables to return random, unique numbers for.

Enhance Your Bot with CodelessBot

CodelessBot plans start from $18/month