PodTech's Tabichan API SDK for JavaScript/Node.js - Your AI-powered tourism assistant.
- 🗾 Support for Japan and France tourism queries
- 🔄 Asynchronous chat processing with polling
- 🖼️ Image thumbnails for tourism content
- 🌐 Multi-language support
- 🔒 Secure API key authentication
- 📦 Dual CommonJS/ESM support
- 🎯 Full TypeScript support
- 🔌 Real-time WebSocket support for interactive conversations
npm install tabichan
# or
yarn add tabichan
Set your API key as an environment variable:
export TABICHAN_API_KEY="your-api-key-here"
const TabichanClient = require('tabichan');
// Initialize client with API key from environment
const client = new TabichanClient(); // Uses TABICHAN_API_KEY env var
// Start a chat about Japan tourism
const taskId = await client.startChat(
"What are the best temples to visit in Kyoto?",
"user123",
"japan"
);
// Wait for the response
const result = await client.waitForChat(taskId, true); // verbose = true
console.log(result);
import { TabichanClient, type Country, type ChatMessage } from 'tabichan';
const client = new TabichanClient(process.env.TABICHAN_API_KEY);
const history: ChatMessage[] = [
{ role: "user", content: "Hello" },
{ role: "assistant", content: "Hello! How can I help you with your travel plans?" }
];
const taskId = await client.startChat(
"Tell me about romantic places in Paris",
"user456",
"france" as Country,
history,
{ budget: "mid-range", duration: "3 days" }
);
const result = await client.waitForChat(taskId);
const { TabichanWebSocket } = require('tabichan');
const wsClient = new TabichanWebSocket('user123', 'your-api-key');
// Set up event handlers
wsClient.on('connected', () => {
console.log('Connected to Tabichan WebSocket');
});
wsClient.on('question', (data) => {
console.log('Question:', data.question);
// Answer the question
wsClient.sendResponse('I prefer cultural attractions');
});
wsClient.on('result', (data) => {
console.log('Result:', data.result);
});
wsClient.on('complete', () => {
console.log('Chat completed');
});
wsClient.on('error', (error) => {
console.error('Error:', error);
});
// Connect and start chat
await wsClient.connect();
await wsClient.startChat('Show me the best temples in Kyoto');
import { TabichanWebSocket, type WebSocketMessage } from 'tabichan';
const wsClient = new TabichanWebSocket('user123');
wsClient.on('question', (data: { question_id: string; question: string }) => {
console.log('Question received:', data.question);
wsClient.sendResponse('My preference is cultural sites');
});
wsClient.on('result', (data: { result: any }) => {
console.log('Final result:', data.result);
});
await wsClient.connect();
await wsClient.startChat('Plan a 3-day trip to Tokyo', [], { budget: 'mid-range' });
const TabichanClient = require('tabichan');
const client = new TabichanClient('your-api-key-here');
// Start a chat with history and additional inputs
const taskId = await client.startChat(
"Tell me about romantic places in Paris",
"user456",
"france",
[
{ role: "user", content: "Hello" },
{ role: "assistant", content: "Hello! How can I help you with your travel plans?" }
],
{ budget: "mid-range", duration: "3 days" }
);
// Poll for status manually
const statusData = await client.pollChat(taskId);
console.log(`Status: ${statusData.status}`);
// Wait for completion
const result = await client.waitForChat(taskId);
// Get related image if available
const imageId = result.itinerary.days[0].activities[0].activity.id;
const imageBase64 = await client.getImage(imageId, "france");
console.log(`Generated image: ${imageBase64.length} characters`);
Initialize the client with your API key. If not provided, uses TABICHAN_API_KEY
environment variable.
startChat(userQuery: string, userId: string, country?: 'japan' | 'france', history?: ChatMessage[], additionalInputs?: object): Promise<string>
Start a new chat session and return a task ID.
Poll the status of a chat task.
Wait for a chat task to complete and return the result.
Get a base64-encoded image by ID.
Initialize the WebSocket client with a user ID and API key. If API key is not provided, uses TABICHAN_API_KEY
environment variable.
Connect to the Tabichan WebSocket server.
Disconnect from the WebSocket server.
Start an interactive chat session.
Send a response to an active question.
on('connected', () => void)
- Fired when connected to the serveron('disconnected', (info) => void)
- Fired when disconnected from the serveron('question', (data) => void)
- Fired when the agent asks a questionon('result', (data) => void)
- Fired when receiving chat resultson('complete', () => void)
- Fired when the chat session is completeon('error', (error) => void)
- Fired on connection or general errorson('authError', (error) => void)
- Fired on authentication errorson('chatError', (error) => void)
- Fired on chat-specific errors
git clone https://github.com/Podtech-AI/tabichan-javascript-sdk.git
cd tabichan-javascript-sdk
npm install
npm test
npm run build
# Build TypeScript definitions
npm run build:types
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Add tests for your changes
- Run the test suite (
npm test
) - Build the project (
npm run build
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please contact us at maxence@podtech.tech or open an issue on GitHub.
Made with ❤️ by PodTech AI