title: DialogFlow/Api.AI inline editor regex for email validation
body: <p><a href="https://github.com/dialogflow/fulfillment-regex-nodejs" rel="nofollow noreferrer">https://github.com/dialogflow/fulfillment-regex-nodejs</a></p>
  
  <p>shows an easy way to perform a regex validation, however I haven't succeeded in creating one for email addresses. </p>
  
  <p>from the original regex i changed the pattern to [^\s]*@[a-z0-9.-] </p>
  
  <p>changed the dialogflow parameter to email with $email and kept the rest the same. </p>
  
  <pre><code>function validateEmployeeID (agent) {
  // get the employee ID parameter from the request header received from Dialogflow
  
  let email = agent.parameters.email;
  let pattern = /[^\s]*@[a-z0-9.-]/;
  if (email.match(pattern) !== null) 
  { agent.add(`Email is wrong, please provide a valid email address.`); } 
  else { agent.add(agent.request_.body.queryResult.fulfillmentText); }
  }
  </code></pre>