> For the complete documentation index, see [llms.txt](https://docs.newbot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.newbot.io/use-newbot-framework-js/create-a-skill-more-details/conditional.md).

# Conditional

It happens several times that one wishes to execute a different skill according to the platform or certain information of the user. For example, we could have a following skill:

```typescript
profile() {
    Messenger.getProfile() // custom function to get Messenger profile
    > Your name is { : response.data.name }
}
```

We can think that this method allows to recover the [user profile on Messenger](https://developers.facebook.com/docs/messenger-platform/identity/user-profile)

However, we want to achieve a universal scenario and have the same [on Line](https://developers.line.me/en/reference/messaging-api/#get-profile):

```typescript
profile() {
    Line.getProfile() // custom function to get Line profile
    > Your name is { : response.data.displayName }
}
```

We will need to use a conditional skill to switch from one to another depending on the platform:

```javascript
import formats from "newbot-formats";
import code from "./main.converse";

import profileMessengerSkill from "./skills/profile/messenger/profile";
import profileLineSkill from "./skills/profile/line/profile";

export default {
  code,
  skills: {
    formats,
    profileSkill: [
      {
        skill: profileMessengerSkill,
        condition(data, user) {
          return data.session.platform == "messenger";
        }
      },
      {
        skill: profileLineSkill,
        condition(data, user) {
          return data.session.platform == "line";
        }
      }
    ]
  }
};
```

Note several points:

1. The name of the skill is always the same `profileSkill`
2. We use the `condition` property that returns a Boolean

### Call in the main script

In the main script `main.converse`, we can call the skill using its name:

```typescript
@Event('start')
start() {
    profileSkill.profile()
}
```

The right skill will be triggered according to the platform!

### Property condition

#### Settings

\</api-table>

#### Return value

Boolean or Promise

We can delay the conditional test with a promise.

```javascript
condition(data, user) {
    return new Promise(resolve => {
        setTimeout(() => {
            resolve(data.session.platform == "line")
        }, 2000)
    })
}
```
