Skip to main content
Sitecore Documentation
  • Learn
  • Downloads
  • Changelog
  • Roadmap
PersonalizeCloud Portal
Sitecore Personalize
        • Add a programmable decision
        • Create a programmable with the Code Assistant
        • Add a decision template
        • Examples of programmable decisions
        • Use custom fields
        • Including dates
        • Copy programmable decisions
        • Including print statements
        • Troubleshooting
    • Managing data systems
  • Using client-side JavaScript
  • Glossary
  1. Introduction to decisioning in Sitecore Personalize
  1. Sitecore Personalize
  2. Introduction to decisioning in Sitecore Personalize
  3. Managing programmable decisions

Create a programmable with the Code Assistant

Note

Code Assistant is only available if Sitecore Stream is enabled for your organization.

You can use the Code Assistant to quickly create a programmable in Sitecore Personalize to help make decisions for an experience or experiment. Whether you’re a developer who wants to save time or a marketer without JavaScript experience, the Code Assistant helps you generate code by simply describing what you need in natural language.

To create a programmable with the Code Assistant:

  1. Click and drag the Programmable component from the palette to the decision canvas and click Edit .

  2. To open the left-hand pane, click Code Assistant.

    Click Code Assistant to open the left-hand pane.
  3. In the left-hand pane, do one of the following:

    • Enter a prompt describing the logic you want to create. Be specific about the criteria, such as guest attributes (gender, city, country), time frames, and the expected return value. See Prompting the Code Assistant for best practices.

      For example: Write a programmable that returns the guest's birthday

    • Select one of the suggested prompts.

    The Code Assistant generates the code and also updates the Type option for the programmable (in the Settings sidebar) based on the prompt. This might take a few minutes.

    Note

    The Code Assistant generates code based on your current prompt and any code that's present in the code editor. It does not consider your prompt history or previous codes in the editor.

    AI responses can vary. Running the same prompt more than once might produce different results.

    After the code is generated, it is labeled with a version number, such as Code Output 1.

  4. To preview the generated code, click View.

    The AI-generated code is labeled with a version number in the left-hand pane.
    Tip

    If you've entered multiple prompts, use the View buttons to compare different code outputs.

  5. In the Code Output dialog:

    • To insert the generated code into the editor and replace any existing code, click Replace code.

    • To copy the generated code to your clipboard, click Copy code.

    Important

    AI-generated code might not always be accurate. Always review and test the code before using it.

  6. Optionally, after inserting the code, you can do the following in the code editor:

    • Make manual changes to the code if needed.

    • Click Format JS Format JS icon to format your code changes automatically.

    • Click Undo to revert changes.

  7. Click Save.

If you have suggestions for improving this article, let us know!

© Copyright 2026, Sitecore A/S or a Sitecore affiliated company.
All rights reserved.

Privacy policySitecore Trust CenterTerms of use