学习 / Bird 集成系列 / 在注册时验证手机号码

Bird 集成第 03 部分

在注册时验证手机号码

7:36 分钟

我们的 bird shop 通过邮件确认订单并以短信发送物流更新——在第三部分中它不再盲目信任电话号码。新客户现在需要在账号创建之前用一次性验证码验证号码:一次调用发送验证码,一次调用检查验证码,无需自建 OTP 系统,无需存储验证码。编程代理编写集成代码,我们故意触发错误来展示为什么错误的验证码不是一个异常。

内容概览

  • 在注册时发送一次性验证码
  • 验证客户输入的验证码
  • 账户确认后的下一步操作
Transcript

Auto-generated from the video.

Hey. And welcome back to another integration series, part three. In the first two series, we've integrated email and SMS notifications into our web web shop. And today we're going to be integrating Verify. So, we want to make sure that once a user creates an account on our Aviary Shop, that we can actually validate the user against the information that they've put in. And there's two ways to do this. We can either decide to build an entire logic flow ourselves, which is going to be quite uh difficult and quite tedious. Or we can actually make use of the Verify platform within Bird.

So, Verify allows us to actually run two APIs very efficiently. The first API is sending out a verification token. Bird will generate a unique token and send it over depending on the channel of choice. And then there's a second API where the user submits the token that they've just received, and we do the match-up with the actual token that has been sent.

During this entire process, Bird doesn't actually see the tokens that have been sent, so that's all behind the scenes. Um but it allows you to have an a clear verification process in place to make sure that you can authenticate your users. Now, when setting up Verify, um there's some important components that we need to go through before we actually start the integration. First, we're going to head to the country step. Just like what we have with SMS, is that there's country-specific enablements.

For Verify, we've enabled all countries by default, so that's different than for SMS where everything is turned off by default. Um and for now, we also want to just focus on the Netherlands. Um within your country, you have the option to select which verification models you want to support and in which order you want to start doing this.

So, for the Netherlands, I've just set up this as a starting, so we're going to start with a WhatsApp verification. We're not going to do SMS because we don't want that. Um and then we've got an alternative fallback as email. So, in this case, the verification goes out through WhatsApp. In the event that fails, we'll send an email instead with that verification token.

Then, when we go into the configuration, there's also a few configurations that we can set up. So, we've got the duration of validity. So, how long is the token actually valid for? Standard is 10 minutes. But, we're going to up that to 15 minutes cuz we're a web shop. We're not as strict. Then, we've got the maximum number of retries. So, how many retries does a user have before we actually just block them? Um this is to make sure that we don't over track your systems with hundreds and hundreds of attempts. And then, we've got a retry delay. So, actually after what time frame will the attempts trigger the next sequence?

Then, we've got some specific channel settings as well. So, it's important to note that both SMS and WhatsApp, we're actually going to be using a Bird verified sender. So, we're not going to enable you to use a custom sender because we're going to take care of the heavy lifting when it comes to sender ID registrations and everything.

Um so, for this, we have a predetermined sender called Authifly, which will basically be used as the sender for both WhatsApp and SMS verification tokens. Then, for email, we also have the option to use a shared sender or that we can actually use a specific. So, we're just going to use verify at Aviary Messaging, which is our custom domain for our shop.

Then lastly, what's always important is setting up an API key. So, I've already gone and created the API key specifically for verify, given it the scopes for email, SMS, and for actually for verify. So, it's a bit of a broader key, so do be mindful of that.

Now, just like last time, we're going to open up a fresh Claude session, and we're going to start integrating Verify. All righty. Uh welcome back. So, this integration took a bit longer than the one that we had for SMS and email. Um multiple APIs need to be set up. But all in all, it was done within uh 8 to 10 minutes. So, again, let's just have a quick look at everything that it did. I had a very straightforward question, implement verify using the Bird CLI.

Um so, it found out uh the information, had a clear picture of how to shop. Um it asked me which channels I wanted to prioritize. So, again, WhatsApp and email. Um then started designing the entire verification flow. So, in essence, it needed uh three specific packages. It needed to have uh the starting route, so that's actually the sending of the verification. Then it's the checking route, so that's checking the code against the sent code. Um and then actual registration page needed to be have updates to make sure that everything was tied together.

Um then it decided to go. So, oh, it also uh deliberately did the restrictions, so it won't actually copy the routes, but it will actually use the verification um routes. Now, then it started building. Um so, it created the different routes. So, this is the verify start route. So, here we can actually see exactly what was written out for um the send state.

Uh we've got the error messages implemented already. And then we've got the check state, which checks against the sent um server. So, we've got the timeout implemented automatically. We can customize the error messages as we wish, and then the actual verification step is happening right there as well.

Now, and then it did all of the checks so again, so my agent does verify everything, runs several checks, and updates all of the information. And here it's got an overview of everything that it actually implemented. So, the verification created and it sends the resends, the branches on success, and then the actual two-step sign-up detail.

And then the full verification. All right, so we're back in our webshop, and we're just going to fill out our phone number, create a quick password, and I'm going to send the verification token. So, the moment it's sent on WhatsApp, if it doesn't arrive, so the moment that it fails, we're going to go over into the fallback. But I've immediately received the Authifly verification token.

So, I'll just quickly show you how that looks like, so you see a few of my previous tests as well. Um the profile is Authifly, so that's just the authentication. Now, I've set it up that in the event that I incorrectly uh paste the code, I'm actually going to get that code is incorrect. So, it's four retries, and then we're going to go into the correct code.

And it's correctly verified, and my account has been created. I can see my recent orders. Um but that's it. That's Verify in a couple of minutes. Uh have a look at the documentation, go to mcp.bird.com, and uh I'll see you in the next one.

从一个渠道开始。
准备好后,再添加其他渠道。

测试 API 密钥即刻可用。添加支付方式并验证发送者身份后,即可解锁生产环境。

正在使用 Claude Code、Cursor 或 Codex?复制一条设置提示,您的智能代理即可自动安装 Bird CLI 和相关技能。选择您的工具:

Cursor