<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Andrew Berry</title>
    <description>The latest articles on DEV Community by Andrew Berry (@andrewberry391).</description>
    <link>https://dev.to/andrewberry391</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F203368%2F9942cff4-75e4-4372-8082-1905df28c35e.png</url>
      <title>DEV Community: Andrew Berry</title>
      <link>https://dev.to/andrewberry391</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andrewberry391"/>
    <language>en</language>
    <item>
      <title>"You've got mail" IoT E-Mailbox with Gmail Notification</title>
      <dc:creator>Andrew Berry</dc:creator>
      <pubDate>Mon, 29 Jul 2019 14:25:13 +0000</pubDate>
      <link>https://dev.to/andrewberry391/you-ve-got-mail-iot-e-mailbox-with-gmail-notification-5264</link>
      <guid>https://dev.to/andrewberry391/you-ve-got-mail-iot-e-mailbox-with-gmail-notification-5264</guid>
      <description>&lt;h1&gt;
  
  
  E-Mailbox
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;In this tutorial we will be going over how to use a Wia Dot One with a Grove Servo Motor to make the servo lift a flag on a mailbox whenever you have a new email.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2F0t-_rK0HwhOPFlDhXYNrbpLNuz6GE_TQQ38YwDpnhXNiNlm7CkqzwsjgC_fgo_NhIQtEuFTBF6Gs" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2F0t-_rK0HwhOPFlDhXYNrbpLNuz6GE_TQQ38YwDpnhXNiNlm7CkqzwsjgC_fgo_NhIQtEuFTBF6Gs" title="Figure 1" alt="&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 1&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Wia Dot One &lt;a href="https://store.wia.io/products/dot-one" rel="noopener noreferrer"&gt;Buy yours here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Servo Motor &lt;a href="https://www.amazon.com/Longruner-Helicopter-Airplane-Controls-KY66-10/dp/B01NA80LUR?th=1" rel="noopener noreferrer"&gt;Buy yours here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MicroUSB cable &lt;a href="https://store.wia.io/products/micro-usb-cable" rel="noopener noreferrer"&gt;Buy yours here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Account on &lt;a href="https://www.wia.io/" rel="noopener noreferrer"&gt;Wia&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Preparation
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Account  at Wia&lt;/strong&gt;
You will need to be registered and /or logged in to your Wia account at  &lt;a href="https://www.wia.io/" rel="noopener noreferrer"&gt;https://www.wia.io/&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set up your Dot One&lt;/strong&gt;
You will need to have a set up Dot One and you can find the tutorial on how to do that &lt;a href="https://wia.developerhub.io/dot-one/setting-up-a-dot-one" rel="noopener noreferrer"&gt;Here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set up your code project&lt;/strong&gt;
Now you will need to create a space and then a block project on your &lt;a href="https://dashboard.wia.io/spaces" rel="noopener noreferrer"&gt;Wia Dashboard&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Creating the block Project
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Now you will need to set up a code block project. You can follow along from what is shown in figure 4. &lt;/li&gt;
&lt;li&gt;Be careful when doing this and remember that capital letters make a difference when naming your variables which is especially important when it comes to giving your states the same names.&lt;/li&gt;
&lt;li&gt;If you would like the code version of this so you can copy and paste code rather than doing the block project feel free; It is also below.&lt;/li&gt;
&lt;li&gt;Lastly if you would like to try and make it yourself in code try that and then match it to my code if you are having any issues!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2FoWF_vRwgTKX_u9h4a_JFahW_27pxUM58VzkEEcE40GNuxzafcdcqVyiY0XXzY_L8bAaHXDV2Pbo_" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2FoWF_vRwgTKX_u9h4a_JFahW_27pxUM58VzkEEcE40GNuxzafcdcqVyiY0XXzY_L8bAaHXDV2Pbo_" title="Figure 2" alt="&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 2&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;WiFi.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;Wia.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;ESP32_Servo.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;currentState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;previousState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;Wia&lt;/span&gt; &lt;span class="n"&gt;wiaClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Wia&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;Servo&lt;/span&gt; &lt;span class="n"&gt;myServo19&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;WiFi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2500&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;myServo19&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;attach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="n"&gt;currentState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;previousState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;currentState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wiaClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getDeviceState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"emailReceived"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;currentState&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;previousState&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;myServo19&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;180&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;150000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;myServo19&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;previousState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;currentState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;60000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting up Zapier
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;We are going to use the Zapier platform with webhooks to detect when you have a new email and this will trigger an event on the Wia Cloud Platform.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;To start go to Zapier and create an account and once you have reached the page as seen in figure 3 you need to start filling in the options for your Zap&lt;/li&gt;
&lt;li&gt;For the section &lt;strong&gt;Connect this app...&lt;/strong&gt; enter &lt;strong&gt;Gmail&lt;/strong&gt; and then for the section &lt;strong&gt;with this one!&lt;/strong&gt; enter &lt;strong&gt;Webhooks by Zapier&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Then for the section &lt;strong&gt;When this happens...&lt;/strong&gt; enter &lt;strong&gt;New email&lt;/strong&gt; or if you want some other option in your email to trigger the email box then select that. Lastly for &lt;strong&gt;then do this!&lt;/strong&gt; select &lt;strong&gt;POST&lt;/strong&gt; and press the &lt;strong&gt;Use Zap&lt;/strong&gt; button! As seen in figure 3!&lt;/li&gt;
&lt;li&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2Fc9e2Dhg1J-sMvE5adTJuRJi_T_rQYPgMpvKr2IkKU0cPyJGd3TcFeHPARYQ0rLS3seZ5CM6SMnRS" title="Figure 3" alt="
"&gt;
&lt;em&gt;Figure 3&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Then follow the instructions to connect your account and press &lt;strong&gt;continue&lt;/strong&gt; and follow the instruction for what types of emails you would like to trigger Zap.&lt;/li&gt;
&lt;li&gt;Next when you see the &lt;strong&gt;Choose and action app&lt;/strong&gt; search for &lt;strong&gt;Webhooks&lt;/strong&gt; and select &lt;strong&gt;Post&lt;/strong&gt; and &lt;strong&gt;Continue&lt;/strong&gt; as seen in figure 4 and figure 5.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2FXpT3hc-QaCfroTaGoom_L7j4JGQce_9a3pBcITkZRoQP-Ttm03uFoe0Y48uY5kI836SlLmrGXf-O" title="Figure 4" alt="
"&gt;
&lt;em&gt;Figure 4&lt;/em&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2F6bhgXmrkwB22Om4sfStnnMapi52JGnWC3nLA5IUXtX6QfDxCcnTRcpRSJKKDGGZNjWb-V6Q4mpr0" title="Figure 5" alt="
"&gt;
&lt;em&gt;Figure 5&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Now for the next section we will need to fill in some information from the Wia Platform as explained below and refer to Figure 6 and Figure 7 and Figure 8 if needed.&lt;/li&gt;
&lt;li&gt;For the &lt;strong&gt;URL&lt;/strong&gt; section put in &lt;strong&gt;&lt;a href="https://api.wia.io/v1/events" rel="noopener noreferrer"&gt;https://api.wia.io/v1/events&lt;/a&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Leave &lt;strong&gt;payload&lt;/strong&gt; empty. &lt;/li&gt;
&lt;li&gt;For the &lt;strong&gt;Data&lt;/strong&gt; in the left box put &lt;strong&gt;name&lt;/strong&gt; and in the right box put the name of your event which for this example is &lt;strong&gt;emailReceived&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Wrap Request Array&lt;/strong&gt; select &lt;strong&gt;no&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Leave &lt;strong&gt;File&lt;/strong&gt; empty.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Unflatten&lt;/strong&gt; select &lt;strong&gt;yes&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Leave &lt;strong&gt;Basic Auth&lt;/strong&gt; empty.&lt;/li&gt;
&lt;li&gt;For the &lt;strong&gt;Headers&lt;/strong&gt; in the the left box put &lt;strong&gt;Authorization&lt;/strong&gt; and in the right box we will need our device ID.&lt;/li&gt;
&lt;li&gt;You can find your device ID by going to the &lt;a href="https://dashboard.wia.io/spaces" rel="noopener noreferrer"&gt;Wia Dashboard&lt;/a&gt; and go into the space where your Dot One is.&lt;/li&gt;
&lt;li&gt;Then go to the &lt;strong&gt;Things&lt;/strong&gt; tab, select your Dot One and go to the &lt;strong&gt;Configuration&lt;/strong&gt; section and you should see &lt;strong&gt;Your Device secret key is:&lt;/strong&gt; copy that key as seen in Figure 8 in the red box.&lt;/li&gt;
&lt;li&gt;Now go back to Zapier and in the &lt;strong&gt;Headers&lt;/strong&gt; section in the right box input &lt;strong&gt;Bearer (your secret key)&lt;/strong&gt; thus paste the key you copied so an example would look something like "Bearer d_sk_712yhbbasd8192yesn" if your secret key is "d_sk_712yhbbasd8192yesn".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2FyHEMVMhgzb7slp7sOoxMWIMA3WuSSY7Ut_FD8C-M-k_T7Y5HCp1QUWsqSgDOLgMPDMHoRma8q1Hk" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2FyHEMVMhgzb7slp7sOoxMWIMA3WuSSY7Ut_FD8C-M-k_T7Y5HCp1QUWsqSgDOLgMPDMHoRma8q1Hk" title="Figure 6" alt="&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 6&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2Fc6J0amCOL0UhKpcZu5CoVzH67QLp5AafjDCnTgNDRYZKBODWsCB5wTm5YwQd9pcvq52Ty37Umtxx" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2Fc6J0amCOL0UhKpcZu5CoVzH67QLp5AafjDCnTgNDRYZKBODWsCB5wTm5YwQd9pcvq52Ty37Umtxx" title="Figure 7" alt="&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 7&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2FEJBWLmTiOtcLTlZNxY9Y-3Qmxq_MsukpHuXtrWIwTCVJljfjv0uQ4-NKyjgb3FFcH-1t2dX5VRFk" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2FEJBWLmTiOtcLTlZNxY9Y-3Qmxq_MsukpHuXtrWIwTCVJljfjv0uQ4-NKyjgb3FFcH-1t2dX5VRFk" title="Figure 8" alt="&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 8&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Then click &lt;strong&gt;Continue&lt;/strong&gt; and &lt;strong&gt;Finish&lt;/strong&gt; on the next page and you're all set with Webhook!&lt;/li&gt;
&lt;li&gt;You can test this by going through the tests on Zapier and click &lt;strong&gt;Test This Step&lt;/strong&gt; under the &lt;strong&gt;Action&lt;/strong&gt; section &lt;/li&gt;
&lt;li&gt;Once Zapier has prompted that you have completed the test go to the &lt;a href="https://dashboard.wia.io/spaces" rel="noopener noreferrer"&gt;Wia Dashboard&lt;/a&gt;  and in the &lt;strong&gt;Things&lt;/strong&gt; tab select your dot one&lt;/li&gt;
&lt;li&gt;Then go to the &lt;strong&gt;Events&lt;/strong&gt; section and you should see an event with the name you inputted on Zapier. As you can see in Figure 9 I have had many events come in!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2Fug4TXH6-d-BURiG6Yu2L8rfyqMM6fzNuRvhbYIiDMa2Xjv_rHiNXVE6c6HGNO1XiPsBHAO7yVT2V" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2Fug4TXH6-d-BURiG6Yu2L8rfyqMM6fzNuRvhbYIiDMa2Xjv_rHiNXVE6c6HGNO1XiPsBHAO7yVT2V" title="Figure 9" alt="&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 9&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up your Flow
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Now that we have Zapier all set up with the webhooks to trigger events on our Dot One we need to set up a flow to recognize that event and tell your Dot One what to do.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;To start off go to the &lt;a href="https://dashboard.wia.io/spaces" rel="noopener noreferrer"&gt;Wia Dashboard&lt;/a&gt;  and go to the space with your Dot One and select the &lt;strong&gt;Flows&lt;/strong&gt; tab to &lt;strong&gt;Create a Flow&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Now once in your new flow drag an &lt;strong&gt;Event Created&lt;/strong&gt; node into the workspace found in &lt;strong&gt;Trigger&lt;/strong&gt; under &lt;strong&gt;Wia&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Then name the event and select your Dot One from the List. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Note:&lt;/strong&gt; It is very important that you name your event the same as the event name you put in your Webhook on Zapier which for our example was &lt;strong&gt;emailReceived&lt;/strong&gt; as you can see in Figure 10.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2F7S7tAEH0Yd3EFWPyrFrFoIZX7xiYry9aW2w10MK4uxUGq78SRE9lJHQbGqf6-ha0YR6WXIiRBNlO" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2F7S7tAEH0Yd3EFWPyrFrFoIZX7xiYry9aW2w10MK4uxUGq78SRE9lJHQbGqf6-ha0YR6WXIiRBNlO" title="Figure 10" alt="&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 10&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now drag a &lt;strong&gt;Run Function&lt;/strong&gt; node into the workspace found in &lt;strong&gt;Logic&lt;/strong&gt; under &lt;strong&gt;Wia&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In this run function copy and paste the following code into the editor:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;device&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;emailReceived&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;device&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;emailReceived&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This code takes the current state and increments it by one if the state exists and if not it sets the current state to one. &lt;/li&gt;
&lt;li&gt;This is used by our code previously to change the state so that the code can check if the state has changed and if it has that means an event was sent from webhooks thus a new email is in your email box!&lt;/li&gt;
&lt;li&gt;Now we need to update the state so drag an &lt;strong&gt;Update State&lt;/strong&gt; node into the workspace found in &lt;strong&gt;Logic&lt;/strong&gt; under &lt;strong&gt;Wia&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In this node we need to fill out some information about the state so select your device and for &lt;strong&gt;State&lt;/strong&gt; put the state we are working with, for our example it is &lt;strong&gt;emailReceived&lt;/strong&gt; and for value put &lt;strong&gt;${input.body}&lt;/strong&gt; which takes the output of the run function and updates the state with its value.&lt;/li&gt;
&lt;li&gt;Then connect the nodes as seen in Figure 11 and turn on the flow and you should be all set!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2FnA5Dma6djZatql7aezc1lQfkjPg1lFJFt2gD78VRL1C8QMCEfdWBJipQrUyYE17-XUZOjT-QeyMg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2FnA5Dma6djZatql7aezc1lQfkjPg1lFJFt2gD78VRL1C8QMCEfdWBJipQrUyYE17-XUZOjT-QeyMg" title="Figure 11" alt="&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Figure 11&lt;/em&gt;&lt;/p&gt;

</description>
      <category>iot</category>
      <category>wia</category>
      <category>wiadotone</category>
      <category>servo</category>
    </item>
  </channel>
</rss>
