# Create a skill (more details)

The interest of creating a skill is to modularize and structure your chatbot. We can also share the skill to the community

### Structure of your competence

* (my-skill)
  * my-skill.js
  * my-skill.converse

Let's create our scenario as usual in the JS file:

```javascript
import code from './my-skill.converse'

export default {
    code
}
```

And in the ConverseScript

```typescript
@Intent(/hello/i)
hey() {
    > Hey !
}
```

### With parameters

If we want to send parameters, such as a token, the skill must return a function:

`skills/my-skill.js`

```javascript
import code from './my-skill.converse'

export default function(token) {
    return {
        code
    }
}
```

In your main script:

```javascript
import mySkill from './skills/my-skill'

export default {
    skills: {
        mySkill: mySkill('my-token')
    }
}
```

It is possible to write it this way too:

```javascript
import mySkill from './skills/my-skill'

export default {
    skills: {
        mySkill: {
            skill: mySkill,
            params: ['my-token']
        }
    }
}
```

This time, the value of `mySkill` is an object with two properties:

* `skill`: the path to competence
* `params`: the parameters to send to the function of the competency

### An asynchronous skill

The skill can return a promise

`skills/my-skill.js`

```javascript
import code from './my-skill.converse'

export default function() {
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve({
                code
            })
        }, 2000)
    })
}
```

So let's send the skill to the `resolve()` function of the promise. In the main script:

```javascript
import mySkill from './skills/my-skill'

export default {
    skills: {
        mySkill
    }
}
```
