Project

Profile

Help

Contact Forms with Planio » History » Sprint/Milestone 10

Thomas Carney, 10/31/2016 05:02 PM

1 8 Thomas Carney
# Set Up Contact Forms with the Planio Help Desk
2
3 3 Thomas Carney
Today we’re going to look at setting up a contact form that sends messages directly to Planio where they'll appear as issues in the Help Desk.
4 1 Thomas Carney
5
{{TOC}}
6 5 Thomas Carney
7 10 Thomas Carney
## Benefits
8 9 Thomas Carney
9
  - No need for server-side scripting to handle the contact form submissions.
10
  - Reply to website inqueries directly from Planio using the Help Desk. 
11
  - Don't let inquiries slip through the cracks in your overloaded inbox.
12
13 7 Thomas Carney
## HTML Form
14 5 Thomas Carney
15 2 Thomas Carney
You can send contact form requests directly to Planio, as Planio will accept an unauthenticated POST request with application/x-www-form-urlencoded form data.
16 1 Thomas Carney
17
First, we’re going to build a simple form with an action attribute that submits the form to Planio via the POST HTTP method.
18
19
~~~html
20
<form action="https://example.plan.io/track" method="POST">
21
22
Then, we’ll add input fields for a name, email, email subject, and the description:
23
24
  <label for="name">Your name:</label>
25
  <input name="name" id="name" type="text" />
26
27
  <label for="mail">Your email address:</label>
28
  <input name="mail" id="mail" type="email" />
29
30
  <label for="subject">Subject:</label>
31
  <input name="subject" id="subject" type="text" />
32
33
  <label for="description">Your message:</label>
34
  <textarea name="description" id="description"></textarea>
35
~~~
36
37
A Planio account can have multiple projects, so we need a way to assign this message to a particular project in Planio. Therefore, we’ll add a hidden input field with the value set to the name of the project you want to forward the issue:
38
39
~~~html
40
  <input name="project" type="hidden" value="example-project" />
41
~~~
42
43
Then, we add the submit input field:
44
45
~~~html
46
  <input type="submit" value="Submit request" />
47
~~~
48
49 7 Thomas Carney
## Add a Honeypot Field
50 1 Thomas Carney
51 6 Thomas Carney
Forms are frequently the target of spambots that will send messages to any form they can find online. One strategy for dealing with spam bots is to add an additional input field to the form called a honeypot field. Then, you hide the form field using CSS. If that input field is filled out, which spambots usually do, then the message is discarded as spam - hence the name honeypot field.
52 5 Thomas Carney
53 1 Thomas Carney
Here’s the honeypot field along with some CSS:
54
55
~~~html
56
<!-- CSS to hide honeypot field -->
57
<style media="screen">#url { display:none; }</style>
58
  <input name="url" id="url" type="text" />
59
~~~
60
61
So, pulling it all together, our form will look like this:
62
63
~~~html
64
<!-- CSS to hide honeypot field -->
65
<style media="screen">#url { display:none; }</style>
66
67
<form action="https://example.plan.io/track" method="POST">
68
69
  <label for="name">Your name:</label>
70
  <input name="name" id="name" type="text" />
71
72
  <label for="mail">Your email address:</label>
73
  <input name="mail" id="mail" type="email" />
74
75
  <label for="subject">Subject:</label>
76
  <input name="subject" id="subject" type="text" />
77
78
  <label for="description">Your message:</label>
79
  <textarea name="description" id="description"></textarea>
80
81
  <input name="project" type="hidden" value="example-project" />
82
  <input name="url" id="url" type="text" />
83
  <input type="submit" value="Submit request" />
84
85
</form>
86
~~~
87 5 Thomas Carney
88
## Example Contact Form Message as an Issue in Planio
89 1 Thomas Carney
90
When someone fills out this form, the message will show up in Planio as an issue as you can see here:
91
92
![](contact-form-message-as-issue.png)
93
94
That’s just one of the examples of how you can use the Redmine API at Planio to streamline your processes. You’ll find more examples and documentation in our [Redmine API documentation](https://plan.io/api/) .