Confluence
Compatibility
Only available on Node.js.
This covers how to load document objects from pages in a Confluence space.
Credentials
- You'll need to set up an access token and provide it along with your confluence username in order to authenticate the request
- You'll also need the
space key
for the space containing the pages to load as documents. This can be found in the url when navigating to your space e.g.https://example.atlassian.net/wiki/spaces/{SPACE_KEY}
- And you'll need to install
html-to-text
to parse the pages into plain text
- npm
- Yarn
- pnpm
npm install @langchain/community @langchain/core html-to-text
yarn add @langchain/community @langchain/core html-to-text
pnpm add @langchain/community @langchain/core html-to-text
Usage
import { ConfluencePagesLoader } from "@langchain/community/document_loaders/web/confluence";
const username = process.env.CONFLUENCE_USERNAME;
const accessToken = process.env.CONFLUENCE_ACCESS_TOKEN;
const personalAccessToken = process.env.CONFLUENCE_PAT;
if (username && accessToken) {
const loader = new ConfluencePagesLoader({
baseUrl: "https://example.atlassian.net/wiki",
spaceKey: "~EXAMPLE362906de5d343d49dcdbae5dEXAMPLE",
username,
accessToken,
});
const documents = await loader.load();
console.log(documents);
} else if (personalAccessToken) {
const loader = new ConfluencePagesLoader({
baseUrl: "https://example.atlassian.net/wiki",
spaceKey: "~EXAMPLE362906de5d343d49dcdbae5dEXAMPLE",
personalAccessToken,
});
const documents = await loader.load();
console.log(documents);
} else {
console.log(
"You need either a username and access token, or a personal access token (PAT), to use this example."
);
}
API Reference:
- ConfluencePagesLoader from
@langchain/community/document_loaders/web/confluence