How to pass non-user input into Symphony Element Actions

Symphony Elements is our standard UX component library used to create rich workflows for bots without the need for complicated code and UI design.

Symphony Element Actions only pass user input that is requested in the form. In order to pass values you don't want the user to edit, you will need to hide them within the Elements form. There are two ways to accomplish this securely:

 

Form-ID/Submit button

To insert the required values in the Form-ID or Submit button, use the JSON representation of what you want to pass. The values will be returned in the action property and you can then use a JSON deserializer to get the values you passed:

<messageML>
<form id="my-form">
<text-field name="userInput" placeholder="User Input">Default Input</text-field>
<button name='"action":"submit","secret-1:"My Secret 1","secret-2":"My Secret 2"' type="action">Submit</button>
<button type="reset">Reset</button>
</form>
</messageML>

Command

...
"formValues": {
"action": "\"action\":\"submit\",\"secret-1:\"My Secret 1\",\"secret-2\":\"My Secret 2\"",
"userInput": "Default Input"
}
...

Command

Entity JSON

Setting the Entity JSON of the Elements form to the value you want to pass is a very secure method because the data is stored and obtained from the server side. It works in a very similar way to the first, but here the value is set in the data payload of the message instead of the form. The formMessageId of the Symphony Elements Action can then be used in the Get Message By ID API call to obtain the entity JSON that was originally passed to it.

<messageML>
<form id="my-form">
<text-field name="userInput" placeholder="User Input">Default Input</text-field>
<button name="submit" type="action">Submit</button>
<button type="reset">Reset</button>
</form>
</messageML>

Value for message in form-data

{"secret-1":"My Secret 1", "secret-2":"My Secret 2"}

Value for data field in form-data

...
"formMessageId": "cADVMNeLkd1js-2GMDWneX___o0iPtQwbQ",

"formId": "my-form",
"formValues": {
"action": "submit",
"userInput": "Default Input"
}
...

Elements Action

The formMessageId is then used to obtain the entity JSON that was originally passed to it.

...
"message": "<div data-format=\"PresentationML\" data-version=\"2.0\"> <form id=\"my-form\"> <input type=\"text\" name=\"userInput\" placeholder=\"User Input\" value=\"Default Input\"/> <button type=\"action\" name=\"submit\">Submit</button> <button type=\"reset\">Reset</button> </form> </div>",
"data": "{\"secret-1\":\"My Secret 1\",\"secret-2\":\"My Secret 2\"}",
...

Command

Note: https://{{agentUrl}}/agent/v1/message/:id where :id is the message ID.

Find more information on MessageML on the Symphony Developers Documentation website.

If you require further assistance with Symphony Element Actions, please contact the Symphony Support team at support@symphony.com