<@368829146584842242> <@1151174425039872031> can ...
# 🌎general
c
@fresh-fireman-491 @quick-musician-29561 can you help me with one issue? I am using reeon email verifier to verify the email addresses.. I am trying to integrate the email verifier using api, I used the api and other codes in the validation section of raw input card. It perfectly executing. But i want: if the inputted email is valid, it outputs text : This email is valid (or something like this) How to to this?
f
Hey @clean-holiday-47965 In the validation section you could set a variable to true if the email is valid. You could then check if that variable is set to true with an expression card right after Raw Input card and then from that expression card go to a node that says This email is valid and then continue on with your flow.
Can the user continue the flow is the email is invalid?
If they can't and they have to input a valid email to continue you could just have a text card after the Raw input card to display the message on success.
c
My code inside the email address cards Validation
Copy code
const email = event.payload.text;
const url = `https://emailverifier.reoon.com/api/v1/verify?email=${email}&key=removedmyapiforprivacy&mode=quick`;

try {
  const response = await axios.get(url);
  const verificationResult = response.data;

  // Extracting information from JSON response
  const verifiedEmail = verificationResult.email;
  const status = verificationResult.status;
  const username = verificationResult.username;
  const domain = verificationResult.domain;
  const mxRecords = verificationResult.mx_records;

  // Example usage
  console.log(`Email: ${verifiedEmail}`);
  console.log(`Status: ${status}`);
  console.log(`Username: ${username}`);
  console.log(`Domain: ${domain}`);
  console.log(`MX Records: ${mxRecords.join(', ')}`);

  // Handle the verification result or perform other actions based on the verification result
} catch (error) {
  console.error('Error verifying email:', error);

  // Handle errors (e.g., send an error message back to the user)
  const errorEvent = {
    type: 'text',
    text: 'An error occurred while verifying the email. Please try again later.'
  };

  return errorEvent;
}
Reoon documentations below: This API endpoint is ideal for verifying email at its entry-level. You can verify an email to check its validity before allowing it to enter your email database. This document contains the API documentation to be used by any programming language. The QUICK mode allows the user to verify an email address extremely fast within 0.5 seconds. However, this mode does not support deep verification like the POWER mode. So individual inbox status will not be checked in this mode. The advantages of quick mode verification: Extremely fast verification: Verify an email address in less than 0.5 seconds. Checks the most important things in the shortest time. Does not need to keep your user waiting. Best for: During user registration on your website. Prevent users from registering using temporary/disposable emails. The disadvantages of quick mode verification: Deep verification and detailed information are less available compared to the POWER mode. So individual inbox status will not be checked in this mode. GET Request URL (HTTPS):
Copy code
https://emailverifier.reoon.com/api/v1/verify?email=<email>&key=<key>&mode=quick
Here, email = The email address you want to verify. i.e. jhon123@gmail.com key = One of your API keys created above on this page. mode = "quick" (Default is "quick", if not provided). In the URL above, replace the <> with your own data. Response (JSON):
Copy code
{
    "email": "jhon123@gmail.com",
    "status": "valid",               // All Status: "valid", "invalid", "disposable"
    "username": "jhon123",
    "domain": "gmail.com",
    "is_valid_syntax": true,
    "is_disposable": false,
    "is_role_account": false,
    "mx_accepts_mail": true,
    "mx_records": [
        "gmail-smtp-in.l.google.com",
        "alt1.gmail-smtp-in.l.google.com",
        "alt2.gmail-smtp-in.l.google.com",
        "alt3.gmail-smtp-in.l.google.com",
        "alt4.gmail-smtp-in.l.google.com"
    ],
    "verification_mode": "quick"
}
How to do the task then?
f
With task you mean setting the variable to true right?
c
kind of ... like if reoon verifies the mail and gets the status Valid, the response will be back to botpress and as it is valid, the botpress bot response will be "Your email address is valid" or it will just move to another node, or whatever... But if its Not Valid / Disposal (from reoon) botpress will response something like, the email isnt valid , please use another one
======================== this was the result after using the validation code above... but it doesnt get me any responses of the email, if its valid or not > I want something to get the valid invalid response to the bot
f
Devmik probs has a better way of doing it but I would do it like this const email = event.payload.text; const url = `https://emailverifier.reoon.com/api/v1/verify?email=${email}&key=removedmyapiforprivacy&mode=quick`; try { const response = await axios.get(url); const verificationResult = response.data; // Extracting information from JSON response const verifiedEmail = verificationResult.email; const status = verificationResult.status; const username = verificationResult.username; const domain = verificationResult.domain; const mxRecords = verificationResult.mx_records; if ( verificationResult.status == "valid" ) { workflow.status = "valid" } else if ( verificationResult.status == "invalid" ) { workflow.status = "invalid" } else if ( verificationResult.status == "disposable" ) { workflow.status = "disposable" } // Example usage console.log(
Email: ${verifiedEmail}
); console.log(
Status: ${status}
); console.log(
Username: ${username}
); console.log(
Domain: ${domain}
); console.log(
MX Records: ${mxRecords.join(', ')}
); // Handle the verification result or perform other actions based on the verification result } catch (error) { console.error('Error verifying email:', error); // Handle errors (e.g., send an error message back to the user) const errorEvent = { type: 'text', text: 'An error occurred while verifying the email. Please try again later.' }; return errorEvent; }
Then with an expression card check if workflow.status == "valid"
And then go to the desired node that says the email is valid
If you want to check if it was valid or disposable you can use the logic or ||
if (verificationResult.status == "valid" || verificationResult.status == "disposable") { workflow.status = "valid"; } else if (verificationResult.status == "invalid") { workflow.status = "invalid"; }
We could also simplify it
if (["valid", "invalid", "disposable"].includes(verificationResult.status)) { workflow.status = verificationResult.status; }
Your code would look like this with the simplified version: const email = event.payload.text; const url = `https://emailverifier.reoon.com/api/v1/verify?email=${email}&key=removedmyapiforprivacy&mode=quick`; try { const response = await axios.get(url); const verificationResult = response.data; // Extracting information from JSON response const verifiedEmail = verificationResult.email; const status = verificationResult.status; const username = verificationResult.username; const domain = verificationResult.domain; const mxRecords = verificationResult.mx_records; // Simplified status assignment if (["valid", "invalid", "disposable"].includes(status)) { workflow.status = status; } // Example usage console.log(
Email: ${verifiedEmail}
); console.log(
Status: ${status}
); console.log(
Username: ${username}
); console.log(
Domain: ${domain}
); console.log(
MX Records: ${mxRecords.join(', ')}
); // Handle the verification result or perform other actions based on the verification result } catch (error) { console.error('Error verifying email:', error); // Handle errors (e.g., send an error message back to the user) const errorEvent = { type: 'text', text: 'An error occurred while verifying the email. Please try again later.' }; return errorEvent; }
Then you could check the status with an expression card
Check if valid or disposable workflow.status === "valid" || workflow.status === "disposable"
Check if invalid workflow.status === "invalid"
c
@fresh-fireman-491 error.... i also tried using Execute Code card , same issue
f
Can you go to the logs and expand the error message and send it here
c
sure wait
Copy code
18:25:23
debug
vld-b2745d1a5c
action
Executing capture card custom validation
18:25:23
error
vld-b2745d1a5c
action
Error executing validation "inline-vld-b2745d1a5c.js"
Error executing validation "inline-vld-b2745d1a5c.js"
 [SyntaxError, missing ) after argument list]
{"scope":"bot-action","cardId":"vld-b2745d1a5c","nodeId":"node:Standard2","workflowId":"flow:Main"}
f
And what code did you use
Can you send me all of the code except the api
c
I used this in the validation field (used my api key in the apikey section) and the expression u said...
@fresh-fireman-491 Validation code:
Copy code
const email = event.payload.text;
const url =   `https://emailverifier.reoon.com/api/v1/verify?email=${email}&key=mykey&mode=quick`; 
try {
  const response = await axios.get(url);
  const verificationResult = response.data;

  // Extracting information from JSON response
  const verifiedEmail = verificationResult.email;
  const status = verificationResult.status;
  const username = verificationResult.username;
  const domain = verificationResult.domain;
  const mxRecords = verificationResult.mx_records;

  // Simplified status assignment
  if (["valid", "invalid", "disposable"].includes(status)) {
    workflow.status = status;
  }

  // Example usage
  console.log(Email: ${verifiedEmail});
  console.log(Status: ${status});
  console.log(Username: ${username});
  console.log(Domain: ${domain});
  console.log(MX Records: ${mxRecords.join(', ')});

  // Handle the verification result or perform other actions based on the verification result
} catch (error) {
  console.error('Error verifying email:', error);

  // Handle errors (e.g., send an error message back to the user)
  const errorEvent = {
    type: 'text',
    text: 'An error occurred while verifying the email. Please try again later.'
  };

  return errorEvent;
}
Expression condition:
Copy code
workflow.status === "invalid" || workflow.status === "disposal"
f
You console.logs are missing the backticks to make it a string
Should look like this
console.log(
Email: ${verifiedEmail}
); console.log(
Status: ${status}
); console.log(
Username: ${username}
); console.log(
Domain: ${domain}
); console.log(
MX Records: ${mxRecords.join(', ')}
);
Uh
Oh, discord formatting
Can you upload the code as a file instead
c
got it wait
@fresh-fireman-491 tried that. now this issue!
code as u mentioned ⏬
f
I am making dinner right now but I will try and set it up with my own bot when I am done
c
sure. you might need the api key to test i guess. i dmed u @fresh-fireman-491
3 Views