template forms in prismic - prismic.io

I'm new to prismic and trying to figure out if this is right tool for what I need. I need to create multiple form templates. I want prismic user to be able to build out the template, which will get loaded into gatsby where each field will get built out as components based on a title, type, action, name.
Title will be the title or label.
type will be the type of form element, ex: input, button, radio action,
if its a button the action it needs to do.
name the name for the form element.
Does prismic seem like a good candidate for this and does anyone know of any examples of how I might go about setting up the prismic end. Most of what Ive seen so far is full pages with just title and images. Not exactly forms.
In their repository I only see these options to create elements am I missing some important ones ?
Title
Rich Text
Image
Content Relationship
Link
Link to Media
Date
Timestamp
color
number
key text
Select
Embed
GeoPoint
Group
How would I go about creating form elements, Is there a way to create custom objects to export? Every time I try to add a new filed or a custom object to the json editor it says. Unrecognized, property it will be ignored.
I'd like to be able to use the group to group a bunch of form elements together even if they are just custom objects that I can pass custom properties to so when I load the group into React I can use the custom properties to build out my components ?? Can anyone set me straight here on if this is possible using prismic.
Thanks!

I can't say if Prismic is the best tool for this particular job, but i think you're overestimating what exactly you need in order to render a html form.
Consider the following custom type. It really only consists of titles, structured texts, a repeatable zone and a select. What you do with that data is completely up to you on the front end.
{
"Main": {
"uid": {
"type": "UID",
"config": {
"label": "Form UID",
"placeholder": "Form UID"
}
},
"form_title": {
"type": "StructuredText",
"config": {
"single": "heading2",
"label": "Form Title",
"placeholder": "Form Title"
}
},
"action_title": {
"type": "StructuredText",
"config": {
"single": "heading2",
"label": "action title",
"placeholder": "Submit form"
}
},
"form_action_description": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "form action description",
"placeholder": "form action description"
}
},
"success_message": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "success message",
"placeholder": "success message"
}
},
"error_message": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "error message",
"placeholder": "error message"
}
},
"submit_button_text": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "submit button text",
"placeholder": "submit"
}
},
"body": {
"type": "Slices",
"fieldset": "Slice zone",
"config": {
"choices": {
"test": {
"type": "Slice",
"fieldset": "Form Section",
"description": "Section of a form",
"icon": "vertical_align_center",
"display": "list",
"non-repeat": {
"form_section_title": {
"type": "StructuredText",
"config": {
"single": "heading1",
"label": "Form Section title",
"placeholder": "Form Section title"
}
},
"form_section_description": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "Form Section Description",
"placeholder": "Form Section Description"
}
}
},
"repeat": {
"label": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "label",
"placeholder": "label"
}
},
"type": {
"type": "Select",
"config": {
"options": [
"text",
"textarea",
"checkbox",
"radio",
"submit"
],
"default_value": "text",
"label": "type"
}
},
"name": {
"type": "StructuredText",
"config": {
"single": "paragraph",
"label": "name",
"placeholder": "name"
}
}
}
}
}
}
}
}
}

Related

Linking TextBlock & Input.Text in a adaptive card

I have an adaptive card like below.
I want to shown what ever the user inputs in the Input.Text field in the TextBlock (instead of name). Is this even possible?
Note: I am building this with Bot Framework Composer.
{
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Text",
"placeholder": "Placeholder text",
"id": "name"
},
{
"type": "TextBlock",
"text": "Your name is <name>",
"wrap": true
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3"
}

Adaptive card conditional validation

I have an adaptive card like below
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.3",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"text": "Order Page",
"wrap": true,
"style": "heading"
},
{
"type": "Input.Text",
"label": "Item",
"id": "item",
"isRequired": true,
"errorMessage": "Name is required"
},
{
"type": "Input.Text",
"label": "Quantity",
"isRequired": true,
"errorMessage": "Location is required",
"id": "quantity"
},
],
"actions": [
{
"type": "Action.Submit",
"title": "Cancel",
"data": {
"buttonClicked": "cancel"
}
},
{
"type": "Action.Submit",
"title": "Submit",
"data": {
"buttonClicked": "submit"
}
}
]
}
I am using this in a chat bot.
Here the user has to enter the item name & the quantity if they wish to order by clicking Submit button.
On the other hand if they change their mind and not wish to order, they can just click Cancel button.
However, since I have "isRequired": true, the card starts to validate even when the user clicks Cancel button. So, how to do the validation ONLY when Submit button is clicked but not when Cancel button is clicked?
There is a solution available. You can use the property "associatedInputs" and set it to "none".
{
"type": "Action.Submit",
"title": "Cancel",
"associatedInputs": "none",
"data": {
"buttonClicked": "cancel"
}
},
You may find the relevant documentation here:
https://adaptivecards.io/explorer/Action.Submit.html

Why is 'Error: Invalid JSON: unexpected token' coming up? (brand new to this!)

enter image description hereThis is the first time i've tried to add code into my website so I'm very new to the whole thing... What I'm trying to do is add the 'how did you hear about us' question to the checkout process on my website.
Specifically, I'm having trouble trying to add a theme setting to my website using coding instructions from 'shopify developers'. In the configuration directory of 'Themes', after clicking on settings_schema.json , I follow instructions to add some code after the first curly bracket }, but when I do so and try hit save, the error message 'Invalid JSON: unexpected token' comes up. If anyone can help me that would be hugely appreciated! I'm pasting below the existing code, and below that the snippet of code I'm trying to insert. Just FYI I am using safari.
Does anyone have any idea?
Best,
Cosmo
exisiting code
[
{
"name": "theme_info",
"theme_name": "Themekit template theme",
"theme_version": "1.0.0",
"theme_author": "Shopify",
"theme_documentation_url": "https:\/\/github.com\/Shopify\/themekit",
"theme_support_url": "https:\/\/github.com\/Shopify\/themekit\/issues"
}
]
new code I'm trying to insert
{
"name": "Hear About Us",
"settings": [
{
"type": "text",
"id": "hau_form_options",
"label": "Form options",
"default": "Facebook, Twitter, Google, Instagram, Youtube",
"info": "Separate each option with a comma"
},
{
"type": "header",
"content": "Form validation"
},
{
"type": "checkbox",
"id": "hau_form_validation",
"label": "Enable form validation",
"default": true
},
{
"type": "text",
"id": "hau_error_message",
"label": "Error message",
"info": "The error message that is displayed when no selection is made",
"default": "Please select an option below"
},
{
"type": "text",
"id": "hau_error_message_other",
"label": "Other field error message",
"info": "The error message that is displayed when there is no input in the 'Other' field",
"default": "Please fill the text field below"
},
{
"type": "header",
"content": "Error styling"
},
{
"type": "color",
"id": "hau_error_color",
"label": "Color",
"default": "#ff0000"
}
]
},
I checked the JSON using JSONLint, and it looks like the trailing comma on the end is messing it up.
EDIT: I see the image now, the comma needs to be added before since you are adding it to an Array.
[{
"name": "theme_info",
"theme_name": "Themekit template theme",
"theme_version": "1.0.0",
"theme_author": "Shopify",
"theme_documentation_url": "https:\/\/github.com\/Shopify\/themekit",
"theme_support_url": "https:\/\/github.com\/Shopify\/themekit\/issues"
},
{
"name": "Hear About Us",
"settings": [{
"type": "text",
"id": "hau_form_options",
"label": "Form options",
"default": "Facebook, Twitter, Google, Instagram, Youtube",
"info": "Separate each option with a comma"
},
{
"type": "header",
"content": "Form validation"
},
{
"type": "checkbox",
"id": "hau_form_validation",
"label": "Enable form validation",
"default": true
},
{
"type": "text",
"id": "hau_error_message",
"label": "Error message",
"info": "The error message that is displayed when no selection is made",
"default": "Please select an option below"
},
{
"type": "text",
"id": "hau_error_message_other",
"label": "Other field error message",
"info": "The error message that is displayed when there is no input in the 'Other' field",
"default": "Please fill the text field below"
},
{
"type": "header",
"content": "Error styling"
},
{
"type": "color",
"id": "hau_error_color",
"label": "Color",
"default": "#ff0000"
}
]
}
]

Bot framework user selected button text is not displaying in bot

I am developing Microsoft teams bot using ms bot framework. In that, i am using adaptive cards for displaying description and two buttons.
when user clicks the button, that time i need pass json data to backend. If I pass string data ("data": "ONE") on button action then I can able to read the arguments in backend and user clicked button text is coming in bot. Kindly see the code and output image below
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Hi, this is your Botzer personal assistant , how can I help you? Click Here ",
"weight": "bolder",
"isSubtle": false,
"wrap": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "ONE",
"data": "ONE"
},
{
"type": "Action.Submit",
"title": "TWO",
"data": "TWO"
}
]
}
}
But, when I send json data on button action ("data": { "id": "action2", "name": "two", "value": "TWO"}) that time i can read the data in backend. But, button text is not coming on the bot. Kindly see the code and output image below
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Choose the number",
"weight": "bolder",
"isSubtle": false,
"wrap": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "ONE",
"data": {
"id": "action1",
"name": "one",
"value": "ONE"}
},
{
"type": "Action.Submit",
"title": "TWO",
"data": {
"id": "action2",
"name": "two",
"value": "TWO"}
}
]
}
}
What you want is called a message back, which combines the functionality of string submit actions and object submit actions. Since you don't have any inputs in your Adaptive Card, you can replace it with a hero card and use a messageBack action directly. If you still want to use an Adaptive Card then you're in luck because Teams actually has special functionality that allows you to put a message back in an Adaptive Card. You can see how to do that in the "Adaptive Cards in Teams" section of the blog post Hessel linked to, or you can consult the documentation directly.

How to get a TextBlock Text via Action.Http?

I am trying to get TextBlock Text/Value ("Click Learn More to learn more about Actionable Messages!) in response when clicking Send Feedback.
I tried {{Heading.text}} and {{Heading.value}} with Heading being id of a field.
Adaptive Card
Getting value from Input.Text via {{feedbackText.value}} works just fine.
Sample:
{
"type": "AdaptiveCard",
"version": "1.0",
"hideOriginalBody": true,
"body": [
{
"type": "TextBlock",
"text": "Visit the Outlook Dev Portal",
"size": "Large"
},
{
"type": "TextBlock",
"text": "Click **Learn More** to learn more about Actionable Messages!",
"id": "Heading"
},
{
"type": "Input.Text",
"id": "feedbackText",
"placeholder": "Let us know what you think about Actionable Messages"
}
],
"actions": [
{
"type": "Action.Http",
"title": "Send Feedback",
"method": "POST",
"url": "https://webhook.site/.....",
"body": "{{feedbackText.value}}\n{{Heading.text}}\n{{Heading.value}}"
},
{
"type": "Action.OpenUrl",
"title": "Learn More",
"url": "https://learn.microsoft.com/outlook/actionable-messages"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"}
Thanks for help.
I had the same issue trying to send the value of the textblock in http body. I used the following workaround:
Created an Input.Number field
Set the Initially Visible property to false
When the Adaptive Card is compose, I used logic app/flow to populate the value of the field
The Action.Http was then set to the id.value value of the input box.