In this sample, we will show how a Bot by using Power Virtual Agents can identify if the user on the other side is a Human or a Bot. This can be achieved by sending an email to the user with a verification code that has to be used on the Bot in order to proceed with the dialog flow.
- Email account to send emails from
To import the sample bot follow the steps below:
-
Log in to the Power Apps site.
-
Select the environment where the PVA sample bot will be imported.
- Go to the Solutions tab, and on the command bar, select the Import option.
- Click on the Browse button and locate the HumanVerificationSample_1_0_0_0.zip file included in this repository.
- Information about the solution will be displayed, click Next
- If you have an Office connection, select it. Otherwise, create a new connection. After selecting the connection, the Import button will be available.
- After clicking the import button, the solution will start to import into the selected environment.
- When the import process has finished, the following message will appear.
To set up the sample bot, some configurations need to be done to start using it.
- Go to Power Virtual Agents, select the environment and click on the EmailVerificationBot.
-
Go to the "Human Verification" topic.
-
Go to the "Generate the verification code" flow and click on "View flow details".
- After being redirected to power automate, click the "Edit" button.
- On the "Initialize CodeLength variable" step, you can change the value to set the desired length of the verification code that will be sent through email.
- On the "Send an email to the account sent as input" step, an email account from which the verification code will be sent, has to be set up. The placeholder "youremail@here" should be replaced.
Note: Make sure to use the same email account used by the connection reference when importing the solution.
-
One of these trigger phrases has to be used to start the flow:
- human verification
- email verification
- verification
- verification code
-
The bot will ask for the user's email to validate that there is a person on the other side
- The bot will send a verification code through email and the user needs to copy the code and paste it into the chat window
-
Once the email is entered, there can be two different scenarios:
a) The verification code is correct and the chat flow finishes.
b) The entered code is not valid.
- First, the Mail variable gets filled with the email account provided by the user during the conversation flow.
- Then, the CodeLength and VerificationCode variables are initialized.
- After that, the email is composed to be sent to the email account informed by the user, the subject is set as "PVA verification code" and finally the body is formed by the text "Verification code:" and followed by the value of the VerificationCode variable.
- Finally, the value of the VerificationCode variable is returned to the bot to be used in a prior step.