Project

Profile

Help

Contact Forms with Planio » History » Sprint/Milestone 6

Thomas Carney, 10/25/2016 03:20 PM

1 6 Thomas Carney
## Set Up Contact Forms with the Planio Help Desk
2 1 Thomas Carney
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 5 Thomas Carney
{{TOC}}
6
7 6 Thomas Carney
### HTML Form
8 5 Thomas Carney
9 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.
10 1 Thomas Carney
11
First, we’re going to build a simple form with an action attribute that submits the form to Planio via the POST HTTP method.
12
13
~~~html
14
<form action="https://example.plan.io/track" method="POST">
15
16
Then, we’ll add input fields for a name, email, email subject, and the description:
17
18
  <label for="name">Your name:</label>
19
  <input name="name" id="name" type="text" />
20
21
  <label for="mail">Your email address:</label>
22
  <input name="mail" id="mail" type="email" />
23
24
  <label for="subject">Subject:</label>
25
  <input name="subject" id="subject" type="text" />
26
27
  <label for="description">Your message:</label>
28
  <textarea name="description" id="description"></textarea>
29
~~~
30
31
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:
32
33
~~~html
34
  <input name="project" type="hidden" value="example-project" />
35
~~~
36
37
Then, we add the submit input field:
38
39
~~~html
40
  <input type="submit" value="Submit request" />
41
~~~
42
43 6 Thomas Carney
### Add a Honeypot Field
44 1 Thomas Carney
45 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.
46 5 Thomas Carney
47 1 Thomas Carney
Here’s the honeypot field along with some CSS:
48
49
~~~html
50
<!-- CSS to hide honeypot field -->
51
<style media="screen">#url { display:none; }</style>
52
  <input name="url" id="url" type="text" />
53
~~~
54
55
So, pulling it all together, our form will look like this:
56
57
~~~html
58
<!-- CSS to hide honeypot field -->
59
<style media="screen">#url { display:none; }</style>
60
61
<form action="https://example.plan.io/track" method="POST">
62
63
  <label for="name">Your name:</label>
64
  <input name="name" id="name" type="text" />
65
66
  <label for="mail">Your email address:</label>
67
  <input name="mail" id="mail" type="email" />
68
69
  <label for="subject">Subject:</label>
70
  <input name="subject" id="subject" type="text" />
71
72
  <label for="description">Your message:</label>
73
  <textarea name="description" id="description"></textarea>
74
75
  <input name="project" type="hidden" value="example-project" />
76
  <input name="url" id="url" type="text" />
77
  <input type="submit" value="Submit request" />
78
79
</form>
80
~~~
81 5 Thomas Carney
82
## Example Contact Form Message as an Issue in Planio
83 1 Thomas Carney
84
When someone fills out this form, the message will show up in Planio as an issue as you can see here:
85
86
![](contact-form-message-as-issue.png)
87
88
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/) .