BotGenius

How to Integrate WordPress with WhatsApp via BotGenius API

How to Integrate WordPress with WhatsApp via BotGenius API

How to Create WordPress Users via HTTP API Integration with BotGenius for WhatsApp

Integrating external APIs into chatbot workflows can significantly enhance automation and streamline user experiences. In this blog, we’ll walk through how to set up and use HTTP API integration in BotGenius to automatically create WordPress user accounts through WhatsApp.

By connecting WordPress with BotGenius via HTTP API, businesses can automate user registrations, provide instant feedback to users, and deliver a seamless onboarding experience without manual intervention. Let’s dive into the step-by-step process to achieve this integration.


Benefits of Integrating WordPress and BotGenius via API

Before jumping into the technical steps, here are a few key benefits of integrating WordPress user creation with BotGenius  via API:

  • Automation: Automate the user registration process, saving time and minimizing human errors.
  • Instant Feedback: Send real-time responses to users after registration.
  • Seamless Workflow: Create a streamlined process for both admins and users by integrating WordPress directly into BotGenius chatbot flow.

Step 1: Setting Up the HTTP API in BotGenius

  1. Access the API Section:
    • In your BotGenius dashboard, navigate to the “WhatsApp HTTP API” section. (From the left navigation menu, select “Integration” or “Settings”. There you will find “HTTP API”. Click on it, and then select “WhatsApp HTTP API”)
    • Click “Create” to set up a new API connection.
  2. Configure API Details:
    • API Name: Name your API connection, such as “WordPress User Create Demo”.
    • Method: Set the method to POST since we are sending data to create a new user.
    • Endpoint URL: Input the WordPress REST API endpoint for user creation:
      https://yourwebsite.com/wp-json/wp/v2/users

Step 2: Setting Up the Headers

For this integration, WordPress uses Basic Authentication with an application password. You need to include your WordPress username and an application-specific password encoded in Base64 format in the headers.

Authorization with Application Password

WordPress Application Passwords are a secure way to allow external services like BotGenius to interact with your WordPress site. Here’s how to generate an application password:

  1. Log into WordPress: Go to your admin dashboard.
  2. Navigate to User Profile: Go to Users > Your Profile.
  3. Generate Application Password: In the Application Passwords section, give your integration a name (e.g., “BotSailor API”) and generate the password.
  4. Save the Password: Copy and save the password, as you will not be able to view it again.

Encode Username and Password in Base64

To use this password in your API, you need to encode your username:application_password string in Base64. Here’s how:

  • If your username is admin and your application password is 1234567890abcdef, you’ll need to encode the string admin:1234567890abcdef.

You can use various online tools for Base64 encoding:

Once encoded, it will look like this:

YWRtaW46MTIzNDU2Nzg5MGFiY2RlZg==

Add the Headers in BotSailor

  • Header Key: Content-Type
    Header Value: application/json
  • Header Key: Authorization
    Header Value: Basic
Authorization: Basic YWRtaW46MTIzNDU2Nzg5MGFiY2RlZg==

Step 3: Configuring Body Data for API Request

In the Body Data section of the BotGenius API configuration, you need to map the fields that will be sent to WordPress to create the user. Common fields include:

  • username: (e.g., phone number from the chatbot input).
  • name: (e.g., full name from user input).
  • email: (dynamically captured email).
  • password: Static or dynamically generated.
  • roles: Set this to subscriber or any other role as per your requirement.

You can map static values or dynamic values collected from the chatbot conversation (such as a user’s email or name).


Step 4: Verifying the API

Once you’ve configured the API, click “Verify Connection” to ensure everything is set up correctly. If the connection is successful, BotGenius will confirm that the API endpoint is reachable, and the data is being sent properly.

 


Step 5: Creating the Flow in BotGenius Flow Builder

  1. Start the Bot Flow:
    • Create a new bot flow and add a trigger, such as a keyword (WPAPITest) that users can type to start the flow.
  2. User Input:
    • Add a User Input Flow to collect the user’s information, such as their email address or name. Save this data into custom fields.
  3. Text Message:
    • Send a confirmation message to the user, such as:
      Thanks for your email. We are creating your WordPress account, please wait a moment.
  4. Trigger the API Call:
    • Add the HTTP API action in the flow. Map the user input (such as email, username, etc.) to the appropriate fields in the API request body.
  5. Send Success Confirmation:
    • After the API call, send a message confirming the account creation:
      Hi, your WordPress account has been created. Your username is: #WordPressUserId# and your default password is: 123456.

      Here WordPressUserId is a custom field inside BotGenius.

Step 6: Testing the Flow

Once the API is set up, run tests by interacting with your chatbot to see if the user account is being created on WordPress. Ensure that all user input fields are correctly captured and sent to the API.

Conclusion

By integrating WordPress’s API with BotGenius , you can fully automate the user registration process directly through WhatsApp. This not only saves time but also provides users with a smooth onboarding experience, all while ensuring the data is properly synced across platforms. For more details on setting up API integration in BotGenius ,

This integration opens up new possibilities for automating workflows, reducing manual tasks, and improving overall user experience.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *