Scale customer reach and grow sales with AskHandle chatbot
Last updated:February 7, 2025

How to Build a Chat Completion Experience with AskHandle API?

This tutorial explains how to create a chat experience using the AskHandle API. You will learn how to get your API token, create chat rooms, send messages, and receive AI responses.

Step 1: Get Your API Token

To interact with the AskHandle API, you need an API token. Use the following command to generate your token by providing your username and password:

Sh

The API returns a token like this:

Json

Keep this token secure. It is required to authorize all future API requests.

Step 2: Create a Chat Room

To handle conversations, you need to create a chat room. Send a POST request to the rooms endpoint and include the API token in the header:

Sh

The response will contain the details of the newly created chat room:

Json

Take note of the uuid, as it is required to send messages.

Step 3: Send a Message to the AI

After creating the chat room, you can send messages to the AI. Use the messages endpoint with the room UUID and message details. Include the message body, nickname, and room UUID in the request. The fields email and phone_number are optional but can be added to track user contact details.

Example request:

Sh

In this example, the user has included both email and phone_number fields, but these are not mandatory. The AI will process the message and generate a response.

Step 4: Receive the AI Response

The API will respond with message details, including the AI-generated answer:

Json

The support_answer field contains the AI's reply, which can be displayed to the user.

Use Cases

  • Automated customer support chatbots.
  • AI assistants for product recommendations.
  • Knowledge-based chat systems for frequently asked questions.

Additional Tips

  • Keep your API token confidential to prevent unauthorized access.
  • Each user session should have a separate chat room to manage conversations effectively.

This guide covers the essential steps to build an AI chat experience using the AskHandle API. For more details, check the full API documentation.

Was this article helpful?
Have more questions? Contact us