Estructura

Estructura base de un Autobot

La estructura básica de un Autobot se compone de los campos "steps" y "restart_on_refresh".

  • steps: Aquí estará contenido todo el flujo del bot

  • restart_on_refresh: Esta clave define el comportamiento del bot al momento de recargar la página. Si tiene un valor true el bot comenzará desde el primer step, si su valor es false retomará el flujo en el último step conocido. Debe ser del tipo boolean.

{
    "steps": [
    ],
    "restart_on_refresh": true,
}

Ejemplo de un step

Cada "step" se compone de un elemento estructurado como clave / valor. El ejemplo hace referencia a un elemento de tipo "text" (Para mas información sobre elementos hacer click aquí).

Cada elemento debe tener las siguientes claves:

  • name: Es el nombre del step. Debe ser del tipo string

  • tags: Es la forma de indicar cual es el primer step del bot. Debe ser del tipo array de strings o del tipo null.

  • actions: Son las acciones que realizará el bot en este step. Debe ser del tipo array de diccionarios. Puede contener n cantidad de elementos tipo "text"

  • next_step: Es el próximo step al que irá el bot una vez finalizadas todas las acciones a realizar en el step actual.

  • El primer step siempre debe tener el tag "init" con el siguiente formato: ["init"] y solo puede existir un step con este tag.

  • El último step siempre debe tener el next_step como null y el tag "finish" con el siguiente formato: ["finish"].

{
    "name":"welcome",
    "tags": ["init"],
    "actions": [
        {
            "msg":"Hello world!",
            "type": "text"
        }
    ],
    "next_step": "step_2"
}

Campos opcionales

Estos campos no son necesarios para el funcionamiento básico del bot, no es necesario incluirlos salvo que se quieran activar ciertas funcionalidades

EVENT_HOOKS

  • notify_all: Por defecto el bot guardará todas las interacciones del usuario (por ejemplo al introducir su nombre en un elemento del tipo "input"), no así los mensajes mostrados en pantalla (elementos tipo "text"). Si esta clave tiene valor true se guardaran todos los steps ... MEJORAR ESTA ENTRADA

  • url: Url donde se deben notificar los estados del bot ... MEJORAR ESTA ENTRADA

"EVENT_HOOKS": {
    "notify_all": true,
    "url": "https://url_for_notifications.com"
}

ENVIRONMENT_VARIABLES

Aquí es posible definir variables que estarán disponibles en cualquier momento del bot. (Para mas información sobre variables hacer click aquí).

"ENVIRONMENT_VARIABLES": {
    "@max_attemps" : "3"
}

Ejemplo de un bot funcional

{
    "steps": [
        {
            "name":"welcome",
            "tags": ["init"],
            "actions": [
                {
                    "msg":"Hola, gracias por leer la documentación de los Autobots",
                    "type": "text"
                },
                {
                    "msg":"En el siguiente paso te pediremos que nos digas tu nombre",
                    "type": "text"
                }
            ],
            "next_step": "name_request"
        },
        {
            "name":"name_request",
            "tags": null,
            "actions": [
                {
                    "msg":"Ahora si, podrías decirnos tu nombre?",
                    "type": "input_text"
                }
            ],
            "next_step": "goodbye",
            "variables": {
                "@name": "&input_text"
            }
        },
        {
            "name":"goodbye",
            "tags": ["finish"],
            "actions": [
                {
                    "msg":"Gracias @name por haber participado de esta sección",
                    "type": "text"
                },
                {
                    "msg":"Te invitamos a seguir recorriendo la documentación",
                    "type": "text"
                }
            ],
            "next_step": null
        }
    ],
    "restart_on_refresh": true,
    "EVENT_HOOKS": {
        "notify_all": true,
        "url": "https://url_for_notifications.com"
    },
    "ENVIRONMENT_VARIABLES": {
        "@max_attemps" : "3"
    }
}

Last updated