# Code Action

The Code Action provides a great method to maximize your flows flexibility using Javascript language.

The language you can use is actually Javascript. We plan to add more languages in the future, starting with Python support.

You will mainly use the Code Action to develop “low code” automation when you need advanced features only provided by a programmatic approach. Keep in mind that **no async features are allowed**. You can only use synchronous coding. If you need to get some data from a remote web services you can do it prepending a Web Request action to the Code Action.

Use **context.attributes.KEY** or **context.attributes\[KEY]** to read the value of a flow attribute

Ex.

```
let age = context.attributes.age;
```

Use **context.setAttribute(KEY, VALUE)** to set the value of an attribute

Ex.

```
context.setAttribute('age', 35);
```

In the following example published on Tiledesk Community you can test how the Code Action works.

[Community Code Action example](https://tiledesk.com/community/search/getchatbotinfo/chatbotId/65d12ff648cc2800132cd27e-Code-Action-basic-example)

<figure><img src="/files/Zsb3kHc4KvYMWrN8fh7I" alt=""><figcaption></figcaption></figure>

In this example we execute a couple of tasks:

1. Modify the existing “age” attribute set up using the Set Attribute action (age = 2)
2. Add a totally new attribute (jsondata) to the flow

You are able to see the result printed in the reply:

<figure><img src="/files/OHc1fSXqkMrdPVq07a8j" alt=""><figcaption></figcaption></figure>

**Use case: A/B testing with Code Action**

Take a look at this Community Chatbot to create an A/B testing chatbot using the Code Action.

<https://tiledesk.com/community/search/getchatbotinfo/chatbotId/6622718217940b00137de783-Chatbot-A-B-test-with-Code-Action>

If you have questions about the Code Action or other Tiledesk features feel free to send an email to [support@tiledesk.com  ](mailto:support@tiledesk.com)or leave us [feedback](https://feedback.tiledesk.com/feedback).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guide.tiledesk.com/ai-chatbots-and-automation/actions-explained/code-action.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
