Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Latest commit

 

History

History
130 lines (78 loc) · 7.61 KB

Playground.didact.md

File metadata and controls

130 lines (78 loc) · 7.61 KB
<style> .button.is-dark.is-small { font-family: 'IBM Plex Sans', sans-serif; background-color: #1a1a1a; border-color: white; color: #fff; } .button.is-dark.is-small:hover { font-family: 'IBM Plex Sans', sans-serif; background-color: #2a67f5; border-color: white; color: #fff; } </style>

Code Pattern: Authenticate users on your chatbot with SMS one time passcode

developer.ibm.com

Summary

In this code pattern, learn how to authenticate users on your chatbot with an SMS one-time passcode (OTP).

Description

Chatbots are prevalent everywhere. And, some conversations are confidential, so chatbots must verify the authenticity of its users. One example of this is a customer who holds an insurance policy who uses a chatbot to get more information about that insurance policy. Sending a one-time passcode through SMS is a popular way to identify a user.

This code pattern shows how to build a chatbot that authenticates users through an SMS one-time passcode. You also learn to use IBM Watson Assistant, IBM Cloud Functions, and custom APIs to build this application.

After you have completed this code pattern, you understand how to:

  • Build conversational interfaces into any application, device, or channel
  • Run your application code without servers
  • Build APIs to authenticate users on your chatbot
  • Make external API calls through Watson Assistant

Flow

architecture

  1. The user registers for a policy on the portal.

  2. User data is stored in the database, and policy details are sent to the user’s phone number in an SMS through the Twilio Messaging API.

  3. The user interacts with the chatbot and asks for confidential information that is related to the policy. Watson Assistant prompts the user to enter the OTP.

  4. The query is sent to Watson Assistant, which in turn invokes IBM Cloud Functions to make an API call to the user-defined, back-end API for retrieving information.

  5. The database is searched for the user’s phone number, and the OTP generated by the back-end API is sent to the user through Twilio.

  6. The user enters the OTP in the chat application to authenticate themselves.

  7. Watson Assistant validates the OTP by interacting with the back-end API.

  8. The user-requested confidential information is fetched from the database if the OTP is valid.

  9. IBM Cloud Functions returns the confidential information to Watson Assistant.

  10. Watson Assistant displays the user-requested confidential information.

  11. The user can see the confidential information in the chatbot.

Instructions

This is an Interactive instructions, follow the steps to setup a working instance of the code pattern in the Developer Playground.

1. Clone the GitHub repository

Open Terminal

Get the Code Pattern on Playground

2. Create and Configure Twilio Messaging Service

  • Create a Twilio service account.
  • Verify caller IDs.
  • Create the Twilio Trial Number.
  • Copy Account SID, Auth Token and Phone Number.

For detailed steps click here.

3. Build and Configure DB APIs

You can build and run the APIs within the Developer Playground, click on Build and Run to start the application.

Build and Run

Configure the APIs by entering the credentials copied in the previous steps and take a note of the APIs URL.

4. Set up Cloud Functions

  • Create a Cloud Function Action here.
  • Copy the code from here and paste as in the canvas for cloud function action.

5. Create Watson Assistant Services

You need to be logged in to your IBM Cloud account in the Developer Playground to create and configure services.

Open new terminal

Login to IBM Cloud

  • Navigate to Watson Assistant Instance from here.
  • Follow the steps here to import a Watson Assistant Skill and configure with Cloud Function URL.

6. Build and Run the Web App

You can build and run the APIs within the Developer Playground, click on Build and Run to start the application. You can also manage the created services in IBM Cloud Dashboard.

Build and Run

You can stop the Apps by clicking on the below buttons.

Stop Running APIs Stop Running Web App

7. Clean up

Completed the code pattern? Click on Clean up to delete the IBM Cloud services that were created.

Clean up

Find the detailed steps here.

You can find the detailed steps in the README file.