# Chatbot User Authentication

#### Phone Number Authentication Setup <a href="#phone-number-authentication-setup" id="phone-number-authentication-setup"></a>

This guide walks you through integrating an API for phone number verification within your flow. You’ll set up two APIs—one to send the OTP and another to verify it. Follow these steps carefully.

**Step 1: Create the API for Sending OTP**

1. **Navigate to Developer Section**

Go to your platform's **Developer Section**.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FarnXYvAZVcAEFUSNiBzt%252Fimage.png%3Falt%3Dmedia%26token%3Dd557ba68-3dd6-46e8-8879-41888c890a79&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=a7ce8c2d&#x26;sv=2" alt=""><figcaption></figcaption></figure>

2. **Add a New API**

Click on the **Add API** button as shown in the screenshot

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252Fc7fbneHRLoOUuwkb2y3D%252Fimage.png%3Falt%3Dmedia%26token%3Debd91cee-4f81-4795-824c-dc8dca1de940&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=4b1847d2&#x26;sv=2" alt=""><figcaption></figcaption></figure>

* Enter an **API Name** (e.g., "Send OTP").

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FW9CT3bzmtd35dIqSSmXu%252Fimage.png%3Falt%3Dmedia%26token%3D6c1dcee8-af11-4f62-a4c9-d4b66e4baa5d&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=ba99926&#x26;sv=2" alt=""><figcaption></figcaption></figure>

3. **Configure API Details**

* Choose the appropriate **Method** from the dropdown that is POST

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FVJOCQzneeGT0P3NDoaoN%252Fimage.png%3Falt%3Dmedia%26token%3D5067f58d-d621-4079-95dc-58d2b26ac7ab&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=5bffe314&#x26;sv=2" alt=""><figcaption></figcaption></figure>

* In the **API URL** field, enter the API endpoint provided for sending OTP.

{% hint style="info" %}
API : <https://api.v7.botpenguin.com/integrations/custom-feature/send-otp-sms>
{% endhint %}

1. **Set Headers**
   * Go to the **Headers** section.
   * Add the required authorization fields:
     * **Authorization Key**: Enter the authorization key provided by the service.
     * **Value**: Your token or key.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252F8ATutzHZMxo4IEJkEbTz%252Fimage.png%3Falt%3Dmedia%26token%3D1856c4ed-b357-4997-a740-5b34841e2624&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=f706b15a&#x26;sv=2" alt=""><figcaption></figcaption></figure>

1. **Define Request Body Parameters**
   * In the **Body** section, enter the parameters as shown in the screenshot:
     * **accountSID**: Obtain from Twilio.
     * **authToken**: Obtain from Twilio.
     * **fromNumber**: Your Twilio phone number.
     * **toNumber**: Map this to the user’s phone number attribute.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252F9mxDmS8KE8fPPvnHsbno%252Fimage.png%3Falt%3Dmedia%26token%3Da979e3f4-cd16-4767-ab2b-afe5e32827f3&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=759591b0&#x26;sv=2" alt=""><figcaption></figcaption></figure>

1. **Save API**
   * Click **Save** to store the API configuration.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252F2IW1tMWKGpCZfJg36R5L%252Fimage.png%3Falt%3Dmedia%26token%3Df80dba21-488c-49ac-8704-85c6e448519e&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=2418f279&#x26;sv=2" alt=""><figcaption></figcaption></figure>

**Map Phone Number Attribute**

* In the **Attributes** section, select the user’s phone number attribute.

1. **Save Custom Attribute**
   * In the **Manage API Response** section, choose **Save to Custom Attribute**.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252Fh22ma7FOzVyVulkCd0ZG%252Fimage.png%3Falt%3Dmedia%26token%3Dbd4452cb-77c6-4832-944c-dfdc3d550946&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=f1e65bf0&#x26;sv=2" alt=""><figcaption></figcaption></figure>

* If not already created, create a custom attribute to store the verification status or OTP code.

***

**Step 2: Create the API for OTP Verification**

1. **Add Another API for OTP Verification**
   * Click **Add API** again.
   * Name this API (e.g., "Verify OTP").

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FkbYMA9nfS7oTEyHas8kj%252Fimage.png%3Falt%3Dmedia%26token%3D54313713-2394-4126-89f8-71d2be445f46&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=4d8f9e80&#x26;sv=2" alt=""><figcaption></figcaption></figure>

1. **Set Method and URL**
   * Choose the appropriate **Method** (POST).
   * Enter the **API URL** for verifying OTP.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FAGLA0RiDiD7zPR12ovay%252Fimage.png%3Falt%3Dmedia%26token%3D0c9991cf-2662-42c5-862d-1a079641222b&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=9fa91d0f&#x26;sv=2" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
API : <https://api.v7.botpenguin.com/integrations/custom-feature/verify-user-otp>
{% endhint %}

1. **Set Headers**
   * Fill in the header details similar to Step 1.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FK9JCRz7K4PWRL0IIOZSy%252Fimage.png%3Falt%3Dmedia%26token%3D2383e19f-35f5-4157-9ca3-34755ed8baf2&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=42c295d4&#x26;sv=2" alt=""><figcaption></figcaption></figure>

1. **Define Request Body Parameters**
   * In the **Body** section, pass:
     * **systemOtp**: The OTP sent to the user.
     * **userOtp**: The OTP entered by the user.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FjH27yBctAyhoGomHEH7Q%252Fimage.png%3Falt%3Dmedia%26token%3D62534cce-b10b-4f94-9283-1e7b6bbded89&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=e29775b4&#x26;sv=2" alt=""><figcaption></figcaption></figure>

1. **Save API**
   * Click **Save**.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FifjNIuag52MtHj8TsS8j%252Fimage.png%3Falt%3Dmedia%26token%3De4ea2695-9793-4e66-8e99-b864bc8cc358&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=f58c0f8b&#x26;sv=2" alt=""><figcaption></figcaption></figure>

***

**Step 3: Integrate APIs into the Chat Flow**

1. **Edit the Chat Flow**
   * Go to **Edit Flow** and open the chat flow you want to edit.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FtrRZGf77FKRiUIzeak1p%252Fimage.png%3Falt%3Dmedia%26token%3D15612d59-a719-44ac-ada8-59101c989b69&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=57f23ffc&#x26;sv=2" alt=""><figcaption></figcaption></figure>

1. **Add API Components**
   * **Send OTP** API:
     * Add the **API component** and select the API created in Step 1.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252Fob5jkpQeBlGBfDWcGtHE%252FScreenshot%25202024-11-04%2520at%25205.16.59%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3Dad4cc86d-1542-4b9f-b52f-359a4ca51e93&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=c5e989b9&#x26;sv=2" alt=""><figcaption></figcaption></figure>

**Phone Number Input**:

* Add a component to capture the user’s phone number.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FCYxYE3KNcrW11Q74gfC7%252FScreenshot%25202024-11-04%2520at%25205.19.13%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3D0c69f7d8-e5de-488d-b017-12956c94aa65&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=6dfbe68d&#x26;sv=2" alt=""><figcaption></figcaption></figure>

* **Verify OTP** API:
  * Add the **API component** again and select the **Verify OTP** API from Step 2.

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FQtLQw0UDF2vDDy7PImkw%252FScreenshot%25202024-11-04%2520at%25205.26.12%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3Dea5ede06-af82-428d-820f-47cc7868f8ea&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=92b94329&#x26;sv=2" alt=""><figcaption></figcaption></figure>

1. **Add Delays**

   * Add a delay of 5 seconds between sending and verifying OTP, and 2 seconds if re-verifying.

   <figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252FOTDojqvPfRxgBhglWtum%252FScreenshot%25202024-11-04%2520at%25205.29.07%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3D00a220f7-ac78-4ca6-b429-c6ac213c1570&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=298af513&#x26;sv=2" alt=""><figcaption></figcaption></figure>

<figure><img src="https://help.botpenguin.com/~gitbook/image?url=https%3A%2F%2F1745791824-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FAPDb8cKQtGlIAfgHjcsQ%252Fuploads%252F1lRMWuJnBFM8LA5oFJy1%252FScreenshot%25202024-11-04%2520at%25205.28.03%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3D818a3bed-a99c-4af5-a8bc-a7db8872e339&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=95b5ab8e&#x26;sv=2" alt=""><figcaption></figcaption></figure>

1. **Response Messages**
   * Configure messages to display whether the OTP was verified successfully or if the user should re-enter it.

***

This setup enables you to authenticate a user’s phone number seamlessly by sending and verifying an OTP.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.botpenguin.com/platform-guidelines-and-trainings/unlock-power-of-botpenguin/chatbot-user-authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
