How to set up a custom API integration with AI Assist
The instructions below are for desktops and laptops only.
tawk.to’s AI Assist lets you connect your live chat to backend systems, giving customers quick access to real-time product and order information. This makes it easy for customers to browse your inventory, make and track orders, schedule appointments, and more.
You can also tap into customer data and personalize interactions, like greeting customers by name and recommending products based on their past purchases.
API integrations can help to expand your live chat capabilities, enhance customer experience, and reduce your support team’s workload.
If you use multiple AI agents, they share the same API integrations, ensuring accurate and consistent information delivery across channels.
In this guide, we walk you through the basic steps to integrate AI Assist with other APIs using OpenAPI.
First, you’ll need your OpenAPI specifications, which is a JSON (.json) or YAML (.yaml) file that defines the communication between the API and AI Assist. Your OpenAPI specifications contain the API’s data models, endpoints, request parameters, and response formats.
Click here for an example of a JSON OpenAPI schema.
If the API you want to integrate doesn't already have an OpenAPI specification, you may need to create one. You can use editors like Postman or Swagger Editor to write your specifications, and validate them using Swagger’s validator or any online validator.
Learn more about creating OpenAPI specifications here.
Next, host your OpenAPI specification file on a server that allows public access. You can use a repository like GitHub, cloud storage like Amazon S3, or any web hosting service.
Take note of your file’s URL; you’ll need it for the next step.
Note: If you update your OpenAPI schema file and receive a new URL after setting up the integration, you’ll need to delete the integration and re-add it with the new URL.
Follow these steps to configure your integration:
2. On your dashboard, select the property for which you want to integrate. Hover over the property name to ensure you’ve selected the correct one.
4. Click Settings under AI Assist.
5. Select your AI agent.
6. Click Integration/API.
7. Click Add Tool under API.
8. Enter the URL of your OpenAPI specification file in Schema File URL. You can get this from the repository or storage that hosts your OpenAPI specification file. Ensure your URL is publicly accessible and correctly points to your specification file.
For example:
https://petstore.swagger.io/v2/swagger.json
Note: If you update your OpenAPI schema file and receive a new URL, you’ll need to delete the integration and re-add it with the new Schema File URL.
9. Enter the API Base URL. This is the root URL of the API. You can get this from the provider of the API. The endpoints, requests, and responses in your OpenAPI specifications will be accessed via this URL. Ensure the endpoints in your specifications match the API endpoints to avoid any errors.
For example:
https://petstore.swagger.io/v2
10. Set the appropriate authentication method for the API. Select No Auth if the API doesn’t require authentication.
If you select API key, enter the API Key and Value. You can get this from the provider of the API. Ensure that you’re using the correct API key to avoid authentication errors.
10. Double-check your details and click Save.
AI Assist uses your data sources, including API integrations, to respond to customers.
To help AI Assist understand your API integration and respond accurately, try this:
Ensure your API schema contains detailed descriptions of the endpoints and parameters used in your integration.
Update the Base Prompt in the Settings page to instruct AI Assist when to make an API request and what information to look for. For example:
- If the customer asks about order status, run [API call] to get the relevant information.
It’s important to mention the API call exactly as defined in your API schema.
To learn more about setting up the Base Prompt, click here.
While the API Base URL can be changed, the Schema File URL cannot be edited. If you update your OpenAPI schema file and receive a new URL, you’ll need to delete the integration and re-add it with the new Schema File URL.
When AI Assist gets information via an API request, it prioritizes this information over other data sources and uses it to generate a response to customers. You can customize AI Assist’s response using Base Prompt instructions, such as setting the tone, or including buttons for customers to click.
Each API request has a unique ID and is a separate data point. Follow-up API requests are independent of previous API requests and responses. So, whenever AI Assist makes an API request, it does not refer to the requests and responses that were made previously.
Lengthy conversations may be truncated and AI Assist may not be able to refer to information mentioned early in the conversation.
Test your integration for accuracy, latency, and security. Follow best practices for API authentication and data encryption.
Optimize your integration to ensure a smooth chat experience for your customers. Create a customer-centric experience that fosters loyalty, boosts sales, and propels your business forward.
Ensure your integration can handle increasing chat volumes as your business grows.
Check out these guides for examples of integrating AI Assist with other APIs:
If you have feedback about this article, or if you need more help:
Click the green live chat icon
Schedule a call with us
Visit our community