make-call.ts — tsimport { Firetell } from '@firetell/firetell-node-sdk';const firetell = new Firetell({domain: 'yourcompany.firetell.app',secretKey: process.env.FIRETELL_SECRET_KEY!,});const call = await firetell.calls.make({from: { number: '+14155550100', name: 'Customer Support' },to: { number: '+12125550123', name: 'John Doe' },actions: [{ action: 'connect_agent', params: { agent_id: 'agt_abc123', timeout: 30 } },],});
| Phương thức | Header | Trường hợp sử dụng |
|---|---|---|
| API Key | Authorization: ApiKey sk-... | Gọi server-to-server từ backend (Workspace API) |
| JWT Token | Authorization: Bearer <jwt> | Gọi từ ứng dụng web hoặc di động (Agent API & SDK) |
| Sự kiện | Kích hoạt khi |
|---|---|
| call.created | Có cuộc gọi đến hoặc gọi ra mới được tạo |
| call.answered | Cuộc gọi được nhấc máy |
| call.ended | Cuộc gọi kết thúc hoặc thất bại, kèm thời lượng và lý do |
| call.recording.ready | File ghi âm đã xử lý xong và sẵn sàng tải về |
| call.transcription.completed | Bản chép lời đầy đủ và các thực thể trích xuất đã hoàn tất |
| message.received | Có SMS/MMS gửi đến một đầu số của bạn |
| agent.state | Tổng đài viên thay đổi trạng thái trực tuyến |
| workspace.credit.updated | Số dư tín dụng của workspace thay đổi |
webhook.ts — tsimport express from 'express';import { constructWebhookEvent } from '@firetell/firetell-node-sdk';const app = express();app.post('/webhooks/firetell', express.raw({ type: 'application/json' }), (req, res) => {const signature = req.header('x-webhook-signature') ?? '';try {const event = constructWebhookEvent(req.body,signature,process.env.FIRETELL_WEBHOOK_SECRET!,);// handle event.event: 'call.ended', 'call.recording.ready', ...console.log('Verified event:', event.event, event.data);res.sendStatus(200);} catch {res.status(400).send('Invalid signature');}});