- Issue created by @Mohammed J. Razem
- Merge request !72Issue #3413325: Allow multiple tokens for replacement in ECA plugin β (Open) created by Mohammed J. Razem
- Status changed to Needs review
12 months ago 10:55pm 8 January 2024 - πΊπΈUnited States kevinquillen
Does this really need to change or can this be facilitated with other Actions? I tried to keep it minimal so this slotted in to ECA as chainable workflows.
From Jurgen:
You can use the https://ecaguide.org/plugins/eca/base/actions/eca_token_set_value/ action and concatenate tokens in the Value of the token field, e.g. The combined value of user [user:id] is now [node:title] from [user:name], so the new token now has that string with multiple tokens being resolved there. Of course, that way you can also just concatenate token values without any other fixed strings in-between. Is it that what you were looking for?
- π©πͺGermany jurgenhaas Gottmadingen
Well, it depends upon the field definition in the configuration form. Currently,
token_input
is defined like this:$form['token_input'] = [ '#type' => 'textfield', '#title' => $this->t('Token input'), '#default_value' => $this->configuration['token_input'], '#description' => $this->t('The data input for OpenAI.'), '#weight' => -10, '#eca_token_reference' => TRUE, ];
This means, ECA expects the name of a token - exactly one and really only a name. So you couldn't even use
node:body
here.For the use case of providing "The data input for OpenAI.", this field configuration is not ideal, I guess. I should probably be more like this:
$form['token_input'] = [ '#type' => 'textarea', '#title' => $this->t('Token input'), '#default_value' => $this->configuration['token_input'], '#description' => $this->t('The data input for OpenAI. This field supports tokens.'), '#weight' => -10, ];
In that case, the input could be
[node:body]
or any sequence of text, containing any number of tokens.Note, the current
token_input
with the'#eca_token_reference' => TRUE,
really just expects a token name without the brackets and uses that token's data for further processing. It helps us to validate the configuration form, so that this is not providing any non-valid token name.Whenever arbitrary text content should be allowed, this is not the correct format, then it should be a text-area that allows for any input, including tokens or just a token. But then with real token syntax, i.e. with the surrounding brackets.
- πΉπThailand AlfTheCat
My suggestion for an ideal solution would be to not require an "Input token" but simply allow tokens inside of the "Prompt" field. I think that is in line with what @jurgenhaas is suggesting.
I have noticed that if I store data inside of tokens, I can use those tokens in the Prompt field. But it does not support prompts like, "Summarize [entity:body]".