@aismarttalk/aismarttalk-sdk
v1.4.1
Published
SDK for AiSmartTalk API
Downloads
404
Readme
AI SmartTalk SDK
Official TypeScript SDK for the AI SmartTalk API.
📚 API documentation: https://docs.aismarttalk.tech/docs/api
Install
npm i @aismarttalk/aismarttalk-sdkRequires Node.js 18+.
Quick start
import { AiSmartTalk } from '@aismarttalk/aismarttalk-sdk';
const client = new AiSmartTalk('your-chat-model-id', 'your-token');
const docs = await client.searchDocuments({ query: 'How do I reset my password?' });The constructor accepts an optional { baseUrl } for self-hosted instances.
What's covered
- Documents — search, import, full CRUD (FAQ, document, product)
- SmartForms — list, fetch, submit (one-by-one or batch), file upload, share links
- Sequences — multi-form workflows, delegation, batch submit, instance tracking, quiz analysis
- SmartFlows — execute workflows, list/install/uninstall templates
- Categories — CRUD on content categories
- Chat model — configuration, AI models & packs, avatar, theme, biography (versioned + translation)
- Integrations — list available integrations and connection status
- Plan & usage — tokens, documents, agents, seats
- Simple storage — key/value scoped to the chat model
- CRM — bulk customer import
- User & permissions — current user, permissions across chat models (OAuth)
Full method list and types are available via TypeScript autocomplete after install. See the API docs for endpoint details.
Examples
SmartForms
const forms = await client.listSmartForms();
const form = await client.getSmartForm('form-id');
// Single-shot submission
await client.batchSubmitSmartForm('form-id', {
answers: { name: 'Alice', email: '[email protected]' },
executeWorkflow: true
});
// File field — upload first, then submit the JSON as the answer value
const upload = await client.uploadSmartFormFile('form-id', formData);
await client.batchSubmitSmartForm('form-id', {
answers: { resume: JSON.stringify(upload.data) }
});Sequences
const sequences = await client.listSequences({ categoryId: 'cat-id' });
const start = await client.startSequence('seq-id', { email: '[email protected]' });
const next = await client.answerSequenceQuestion('seq-id', start.instanceId, {
value: 'My answer'
});
// Batch submit an entire sequence
await client.batchSubmitSequence('seq-id', {
formAnswers: {
form_a: { company_name: 'Acme' },
form_b: { contact_email: '[email protected]' }
}
});
// Quiz scoring with per-answer breakdown
const scored = await client.getSequenceInstanceAnswers('seq-id', start.instanceId);
console.log(scored.summary.overallPercentage, '%');Documents
const list = await client.listDocuments({ page: 1, limit: 20, statusFilter: 'ACTIVE' });
await client.createDocument({
type: 'faq',
question: 'How do I reset my password?',
answer: 'Go to Settings > Security > Reset Password.'
});
await client.updateDocument('doc-id', { favorite: true });
await client.deleteDocument('doc-id');Chat model
// Pick a preset model pack (sovereign, openai, custom, …)
await client.applyAIModelPack({ packKey: 'sovereign' });
// Or set models individually
await client.updateAIModels({ aiModelType: 'GPT4O_MINI' });
// Versioned biography
await client.createBiographyVersion({
configurationType: 'CHAT_ANONYMOUS',
responseBiography: 'You are a helpful assistant…'
});Categories
const categories = await client.getCategories();
await client.createCategory({ name: 'Help', type: ['KNOWLEDGE'] });Error handling
Errors are thrown as { message, status } objects with the API's response message and HTTP status.
try {
await client.getSmartForm('missing-id');
} catch (err) {
console.error(err.status, err.message);
}Development
git clone https://github.com/AI-SmartTalk/aismarttalk-sdk.git
cd aismarttalk-sdk
npm install
npm run buildIntegration tests hit a live API. Copy .env.example to .env and fill in the values:
npm run test:integration
npm run test:document
npm run test:sequence
# …etcReleasing
Pushing a v* tag triggers the Publish to npm GitHub Action. Bump package.json, update CHANGELOG.md, commit, then:
git tag -a vX.Y.Z -m "..."
git push origin vX.Y.ZThe workflow checks that the tag matches package.json before publishing.
