> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jelou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflows

> Query your bot's workflows and redirect users to a specific workflow

Workflows are conversational flows that define the bot's behavior. You can query the workflows available in your bot and redirect users to a specific workflow.

***

## Get Workflows

Query all workflows available in your bot.

```
GET https://api.jelou.ai/v1/bots/{botId}/skills
```

### Path Parameters

| Field     | Location | Type   | Required | Description                   |
| --------- | -------- | ------ | -------- | ----------------------------- |
| **botId** | Path     | string | Yes      | Unique identifier of the bot. |

### Request Example

```bash theme={null}
curl --request GET \
  --url 'https://api.jelou.ai/v1/bots/BOT_ID/skills' \
  --header 'Authorization: Basic {{Base64EncodedUsername:Password}}'
```

### Responses

<AccordionGroup>
  <Accordion title="200 - Successful response">
    ```json theme={null}
    {
      "message": ["Skills retrieved successfully!"],
      "statusMessage": "success",
      "status": 1,
      "data": [
        {
          "id": 1,
          "name": "Main Skill",
          "description": "Welcome skill",
          "type": "BRAIN",
          "createdAt": "2024-10-24T11:18:05.000Z",
          "updatedAt": "2024-10-24T11:18:05.000Z",
          "state": true,
          "default": true
        },
        {
          "id": 2,
          "name": "Sales Skill",
          "description": "Sales flow",
          "type": "BRAIN",
          "createdAt": "2024-10-24T11:13:32.000Z",
          "updatedAt": "2024-10-24T11:17:44.000Z",
          "state": true,
          "default": false
        }
      ]
    }
    ```
  </Accordion>

  <Accordion title="401 - Unauthorized">
    ```json theme={null}
    {
      "message": "Authentication failed"
    }
    ```
  </Accordion>

  <Accordion title="404 - Not Found">
    ```json theme={null}
    {
      "message": ["Bot not found"],
      "status": "failed"
    }
    ```
  </Accordion>
</AccordionGroup>

### Response Detail

| Property        | Type    | Description                                                            |
| --------------- | ------- | ---------------------------------------------------------------------- |
| **id**          | integer | Workflow ID. This ID must be used to configure redirects.              |
| **name**        | string  | Workflow name.                                                         |
| **description** | string  | Workflow description.                                                  |
| **type**        | string  | Workflow type.                                                         |
| **state**       | boolean | Workflow state. Only workflows with state `true` can be used.          |
| **default**     | boolean | Indicates whether the workflow is selected as the default for the bot. |
| **createdAt**   | date    | Workflow creation date.                                                |
| **updatedAt**   | date    | Date of last update of the workflow.                                   |

***

## Configure User Workflow

Redirect a user to a specific workflow within the conversational flow.

```
POST https://api.jelou.ai/v1/bots/{botId}/users/{userId}/skill/{skillId}
```

### Requirements

* The user must have an active session.

### Path Parameters

| Field       | Location | Type   | Required | Description                                                      |
| ----------- | -------- | ------ | -------- | ---------------------------------------------------------------- |
| **botId**   | Path     | string | Yes      | Unique identifier of the bot.                                    |
| **userId**  | Path     | string | Yes      | Unique identifier of the user.                                   |
| **skillId** | Path     | string | Yes      | Identifier of the workflow to which the user will be redirected. |

### Request Body

| Field            | Location | Type   | Required | Description                                                              |
| ---------------- | -------- | ------ | -------- | ------------------------------------------------------------------------ |
| **memoryParams** | Body     | object | No       | Optional parameters that can be injected and used later in the workflow. |

### Request Example

```bash theme={null}
curl --request POST \
  --url 'https://api.jelou.ai/v1/bots/BOT_ID/users/USER_ID/skill/SKILL_ID' \
  --header 'Authorization: Basic {{Base64EncodedUsername:Password}}' \
  --header 'Content-Type: application/json' \
  --data '{
    "memoryParams": {
      "test": 1
    }
  }'
```

### Responses

<AccordionGroup>
  <Accordion title="200 - Successful response">
    ```json theme={null}
    {
      "message": "Skill set successfully",
      "status": "success"
    }
    ```
  </Accordion>

  <Accordion title="400 - Bad Request">
    ```json theme={null}
    {
      "message": "Invalid request",
      "status": "failed"
    }
    ```
  </Accordion>

  <Accordion title="401 - Unauthorized">
    ```json theme={null}
    {
      "message": "Authentication failed"
    }
    ```
  </Accordion>

  <Accordion title="404 - Not Found">
    ```json theme={null}
    {
      "message": "User or Skill not found",
      "status": "failed"
    }
    ```
  </Accordion>
</AccordionGroup>
