Published on

Retrieve Freshdesk Knowledge Base Article in Node.js


Recently, I worked on an AI chatbot project that uses our knowledge base articles (powered by Freshdesk) as a dataset.

For things that are available publicly, it's straightforward. Write a scraper and fetch all relevant articles and content.

However, in our case, we have to train on our internal data as well.

For such cases, using API might be a good choice.


You will need to have an API key (obviously!) and also know the domain for your Freshdesk account.


Create a new Node.js project

mkdir freshdesk-kb-fetcher && $_
npm init -y; npm pkg set type="module";

And install the required package. In my case, I'll be using axios for interacting with APIs. You can use fetch itself if it's supported in your environment, like in the latest Node.js or some edge environment.

npm install axios

Code Snippet

import axios from 'axios';

const apiKey = process.env.FRESHDESK_API_KEY; // 
const domain = 'your-company-here';

const articleId = 123456;

const fetchSupportTicket = async (articleId) => {
  try {
    return axios.get(
        headers: {
          "Content-Type": "application/json",
          Authorization: `Basic ${Buffer.from(apiKey).toString("base64")}`,
  } catch (error) {
    // Handle errors

Happy fetching data!