> ## Documentation Index
> Fetch the complete documentation index at: https://chatbotx.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Code

> Generate a unique random code in a ChatbotX Flow for vouchers, tickets, order references, and other customer records.

**Generate Code** creates a unique random string or number inside a Flow. Use it when each customer needs a reference that is different from every other customer, such as a voucher code, event ticket, or order ID.

The Flow can use the generated result in a later message, a Custom Field, or another Action.

## Add Generate Code to a Flow

<Steps>
  <Step title="Open the Flow">
    Open the Flow that needs to create a unique code.
  </Step>

  <Step title="Add a Perform Action node">
    Add a **Perform Action** node before the Flow sends or stores the code.
  </Step>

  <Step title="Choose Generate Code">
    Open the node, click **Create**, then select **Tools > Generate Code**.

    <Frame>
      <img src="https://mintcdn.com/chatbotx/GMkdbZ1eGBhC4VPX/images/select_generate_code_in_tools_menu.png?fit=max&auto=format&n=GMkdbZ1eGBhC4VPX&q=85&s=18b4542cc65de3fada7bc9cf3dc64713" alt="Select Generate Code In Tools Menu" width="2862" height="1885" data-path="images/select_generate_code_in_tools_menu.png" />
    </Frame>
  </Step>

  <Step title="Configure and save the code">
    Select a **Type**, set the values required by that type, choose the **Custom Field** that will receive the code, then click **Save**.
  </Step>
</Steps>

<Frame>
  <img src="https://mintcdn.com/chatbotx/GMkdbZ1eGBhC4VPX/images/generate_code_action.png?fit=max&auto=format&n=GMkdbZ1eGBhC4VPX&q=85&s=c03bc5bd785fad7c454b9a0accf3941a" alt="Generate Code Action" width="2866" height="1890" data-path="images/generate_code_action.png" />
</Frame>

## Choose a code type

| Type                    | Description                                    |
| ----------------------- | ---------------------------------------------- |
| **Numeric Length**      | Generates a random sequence of decimal digits. |
| **Numeric Value**       | Generates a random integer.                    |
| **Alphanumeric Length** | Generates random characters.                   |

Select the **Custom Field** where ChatbotX should save the generated result. Use **Add** when you need a new Custom Field.

## Example: send a check-in code

When a customer registers for an event, the Flow runs **Generate Code** and saves the result. The next message sends the code to the customer as their check-in reference.

<Note>
  Generate the code before the message that displays it. This ensures the Flow has a value ready to insert for the customer.
</Note>
