Please learn the basics on how to create a simple form with ConfiForms in Confluence here: Creating a form in Confluence
Here we start with quite a similar approach, but will add 2 fields: one to ask for a phone number and another field to input the message
We will add a validation rule to verify the message is not longer than 160 symbols
This is what we are about to build
This is how the page looks like in the editor
We have 2 fields definitions, we have a field definition rule to check the length of the message field and the IFTTT rule with action to send sms
Field definitions are simple
- Text field
- Text area field
Field definition rule is configured as follows
-----
And the final touch is the actual macro that sends SMS messages - this is configured using ConfiForms IFTTT macro, with action "Send SMS"
Storage format for the solution (includes ConfiForms FormView to render form and TableView to show the results)
Code Block |
---|
<ac:structured-macro ac:name="confiform" ac:schema-version="1" ac:macro-id="2934c7bf-a47d-499a-aa5f-7854f73fd02b">
<ac:parameter ac:name="formName">smsSender</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1"
ac:macro-id="da7fa001-4777-4114-acba-7a62bbcb1d0a">
<ac:parameter ac:name="fieldName">number</ac:parameter>
<ac:parameter ac:name="fieldLabel">Phone number</ac:parameter>
<ac:parameter ac:name="fieldDescription">with country code, please</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1"
ac:macro-id="eaca0b0b-93a0-4ea6-af70-6d5dca83aad0">
<ac:parameter ac:name="fieldName">message</ac:parameter>
<ac:parameter ac:name="fieldLabel">Message</ac:parameter>
<ac:parameter ac:name="fieldDescription">max 160 characters</ac:parameter>
<ac:parameter ac:name="type">textarea</ac:parameter>
</ac:structured-macro>
</p>
<p><br/></p>
<p class="auto-cursor-target">
<ac:structured-macro ac:name="confiform-field-definition-rules" ac:schema-version="1"
ac:macro-id="b7799af3-61bb-466d-8039-17bdb331bd15">
<ac:parameter ac:name="condition">message.asLength:>160</ac:parameter>
<ac:parameter ac:name="values">Message shall be shorter than 160 symbols</ac:parameter>
<ac:parameter ac:name="action">Validation rule</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:name="confiform-ifttt" ac:schema-version="1"
ac:macro-id="0aa4edf3-439d-4f1a-81e5-09f2870c2049">
<ac:parameter ac:name="action">Send SMS</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">[entry.message]</ac:parameter>
<ac:parameter ac:name="who">[entry.number]</ac:parameter>
<ac:rich-text-body>
<p><br/></p></ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target"><br/></p></ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target"><br/></p>
<ac:structured-macro ac:name="confiform-entry-register" ac:schema-version="1"
ac:macro-id="211183e7-61ce-4b0c-93e4-74af8f0e1776">
<ac:parameter ac:name="overrideSaveButtonLabel">Send</ac:parameter>
<ac:parameter ac:name="formName">smsSender</ac:parameter>
<ac:parameter ac:name="formTitle">SMS Sender</ac:parameter>
<ac:parameter ac:name="successMessage">Message has been sent</ac:parameter>
<ac:rich-text-body>
<p><br/></p></ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target"><br/></p>
<ac:structured-macro ac:name="confiform-table" ac:schema-version="1" ac:macro-id="0e6128c2-e926-43bb-a21c-65ec6572b1c4">
<ac:parameter ac:name="formName">smsSender</ac:parameter>
<ac:rich-text-body>
<p><br/></p></ac:rich-text-body>
</ac:structured-macro>
|