# Hello world (JS)

### Index.js

First let's create a simple hello-world script. We are creating a function called handler() that we act as the entryPoint of our Function. Our goal is to print a simple "hello world" to the console.

```javascript
exports.handler(()=>{
    console.log('hello world');
});
```

If you are using visual studio code, this should look something like this:

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

### Deploying with the ExH CLI

You can deploy it to the task service using the EXH CLI Tool.

```
exh tasks sync --name hello-world \
   --code= my/directory \
   --entryPoint=index.handler \
   --runtime="nodejs14.x"
```

To create a function we need to provide:

* Function name (`name`)
* Reference to the directory containing the (built) code (`code`)
* The entryPoint in this case our handler function in the index.js file (`entryPoint`)
* The runtime needed to run our code (`runtime`)

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

You can see a hello-world function has been created in the task service. See the [Tasks](/extrahorizon/services/automation/task-service/tasks.md) page on how to create a task and run it.

### Tips

* When synchronizing your task, make sure that you also include the `node_modules` directory if necessary
* Make sure not include any developer dependencies when bundling your task. Otherwise the size of your task might be too big (there is a 10MB limit). You can easily strip developer dependencies by using `npm install --production` or `yarn install --production`


---

# 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://docs.extrahorizon.com/extrahorizon/services/automation/task-service/examples/hello-world-js.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.
