# Solicitar la elección de una opción dinámica

Si bien es posible hacer que el usuario elija una opción por medio del tag `<options>`, las opciones a mostrar son estáticas en el sentido de que estas se encuentran definidas en el xml. Si se requiere que el usuario elija una opción de un conjunto de opciones que se generaron dinámicamente, por ejemplo luego de una ejecución de una API REST, se debe utilizar el tipo de acción `option-data-collect`:

```xml
  <action type="option-data-collect"
        key="state.chosen_phone"
        with_text="Por favor, elija el número de teléfono con el cual quiere operar:"
        with_options_from="state.phones"
        with_option_text="&#009;{{index}}. Teléfono {{iterator.phone_number}}"
    />
```

En detalle:

* El comando `&#009;`, especifica que se debe escribir un tab.
* El comando `{{index}}`, especifica que se debe mostrar el número de opción.
* El comando `{{iterator.phone_number}}` especifica que debe tomar el dato `phone_number` de la opción que se está iterando.
* Se pueden utilizar la cantidad de comandos que se desee, por ejemplo `with_option_text="&#009;{{index}}. Teléfono +{{iterator.country_code}} {{iterator.phone_number}}"`
* La variable `phones` debe ser una lista de objetos como la siguiente:

```xml
{
  "phones": [{
    "phone_number": "...",
    ...
  }, {
    "phone_number": "...",
    ...
  }]
}
```

* En la variable `state.chosen_phone` se guarda el objeto que corresponde a la opción seleccionada por el usuario.


---

# 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://soporte.optiwe.com/chatbots/configuraciones-avanzadas/solicitar-la-eleccion-de-una-opcion-dinamica.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.
