Typeform Connector
เชื่อมต่อ Typeform กับ Brevo ผ่าน Tajo เพื่อซิงค์ผลตอบแบบฟอร์มโดยอัตโนมัติ จับ leads จากฟอร์มแบบสนทนา และทริกเกอร์ระบบอัตโนมัติทางการตลาดตามการส่งแบบสำรวจและผลลัพธ์ quiz
ภาพรวม
| คุณสมบัติ | ค่า |
|---|---|
| แพลตฟอร์ม | Typeform |
| หมวดหมู่ | Forms & Surveys (แบบกำหนดเอง) |
| ความซับซ้อนในการตั้งค่า | ง่าย |
| การผสานรวมอย่างเป็นทางการ | ไม่ |
| ข้อมูลที่ซิงค์ | ผลตอบ ผู้ติดต่อ เหตุการณ์ แบบฟอร์ม |
| วิธีการยืนยันตัวตน | OAuth 2.0 / Personal Access Token |
ฟีเจอร์
- การซิงค์ผลตอบแบบเรียลไทม์ - จับการส่งฟอร์มโดยอัตโนมัติผ่าน webhooks
- การสร้างผู้ติดต่อ - สร้างหรืออัปเดตผู้ติดต่อ Brevo จากผลตอบฟอร์ม
- Lead scoring - ใช้คะแนน quiz และข้อมูลฟอร์มสำหรับการคัดเลือก lead
- Hidden Fields - ส่งข้อมูลลูกค้าผ่าน Hidden Fields สำหรับฟอร์มที่เป็นส่วนตัว
- การแมปแบบมีเงื่อนไข - แมปฟิลด์ฟอร์มที่แตกต่างกันตาม response logic
- รองรับหลายฟอร์ม - เชื่อมต่อหลาย typeforms กับรายการ Brevo ที่แตกต่างกัน
ข้อกำหนดเบื้องต้น
ก่อนเริ่มต้น ตรวจสอบให้แน่ใจว่าคุณมี:
- บัญชี Typeform (แผน Basic หรือสูงกว่าสำหรับ webhooks)
- Personal Access Token จาก Typeform Account Settings
- บัญชี Brevo ที่มีสิทธิ์เข้าถึง API
- บัญชี Tajo ที่มีสิทธิ์ connector
การยืนยันตัวตน
Personal Access Token
# Generate a token at https://admin.typeform.com/account#/section/tokensexport TYPEFORM_ACCESS_TOKEN=tfp_your_personal_access_tokenexport TAJO_API_KEY=your_tajo_api_keyexport BREVO_API_KEY=your_brevo_api_keyOAuth 2.0
// OAuth 2.0 Authorization Flowconst authUrl = 'https://api.typeform.com/oauth/authorize?' + new URLSearchParams({ client_id: process.env.TYPEFORM_CLIENT_ID, redirect_uri: 'https://your-app.com/callback', scope: 'forms:read responses:read webhooks:write accounts:read', state: generateState() });
// Exchange authorization code for access tokenconst tokenResponse = await fetch('https://api.typeform.com/oauth/token', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ grant_type: 'authorization_code', code: authorizationCode, client_id: process.env.TYPEFORM_CLIENT_ID, client_secret: process.env.TYPEFORM_CLIENT_SECRET, redirect_uri: 'https://your-app.com/callback' })});การกำหนดค่า
การตั้งค่าพื้นฐาน
connectors: typeform: enabled: true access_token: "${TYPEFORM_ACCESS_TOKEN}"
forms: - form_id: "abc123" list_id: 5 mapping: email_field: "email" name_field: "full_name" - form_id: "xyz789" list_id: 6 mapping: email_field: "work_email"
sync: responses: true contacts: true events: true
webhook: enabled: true secret: "${TYPEFORM_WEBHOOK_SECRET}"การแมปฟิลด์
field_mapping: # Map Typeform field references to Brevo attributes email: email name: FIRSTNAME company: COMPANY phone: SMS score: LEAD_SCORE quiz_result: QUIZ_SCORE nps_rating: NPS_SCORE feedback: LAST_FEEDBACKAPI Endpoints
| Endpoint | เมธอด | คำอธิบาย |
|---|---|---|
https://api.typeform.com/forms | GET | แสดงรายการฟอร์มทั้งหมด |
https://api.typeform.com/forms/{form_id} | GET | ดึงฟอร์ม |
https://api.typeform.com/forms | POST | สร้างฟอร์ม |
https://api.typeform.com/forms/{form_id} | PUT | อัปเดตฟอร์ม |
https://api.typeform.com/forms/{form_id}/responses | GET | ดึงผลตอบ |
https://api.typeform.com/forms/{form_id}/responses | DELETE | ลบผลตอบ |
https://api.typeform.com/forms/{form_id}/webhooks/{tag} | PUT | สร้าง/อัปเดต webhook |
https://api.typeform.com/forms/{form_id}/webhooks/{tag} | GET | ดู webhook |
https://api.typeform.com/forms/{form_id}/webhooks | GET | แสดงรายการ webhooks |
ตัวอย่างโค้ด
เริ่มต้น Connector
import { TajoClient } from '@tajo/sdk';
const tajo = new TajoClient({ apiKey: process.env.TAJO_API_KEY, brevoApiKey: process.env.BREVO_API_KEY});
await tajo.connectors.connect('typeform', { accessToken: process.env.TYPEFORM_ACCESS_TOKEN, forms: ['abc123', 'xyz789']});ดึงผลตอบแบบฟอร์ม
// Fetch responses using the Responses APIconst response = await fetch( 'https://api.typeform.com/forms/abc123/responses?' + new URLSearchParams({ page_size: 25, since: '2024-01-01T00:00:00Z', completed: 'true' }), { headers: { 'Authorization': `Bearer ${process.env.TYPEFORM_ACCESS_TOKEN}` } });
const data = await response.json();
// Sync each response to Brevofor (const item of data.items) { const answers = item.answers; const email = answers.find(a => a.field.ref === 'email')?.email;
if (email) { await tajo.contacts.sync({ email, attributes: { FIRSTNAME: answers.find(a => a.field.ref === 'name')?.text, LEAD_SCORE: item.calculated?.score || 0 }, listIds: [5] }); }}ตั้งค่า Webhooks
// Register a webhook for real-time response notificationsawait fetch( 'https://api.typeform.com/forms/abc123/webhooks/tajo-sync', { method: 'PUT', headers: { 'Authorization': `Bearer ${process.env.TYPEFORM_ACCESS_TOKEN}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ url: 'https://api.tajo.io/webhooks/typeform', enabled: true, secret: process.env.TYPEFORM_WEBHOOK_SECRET }) });จัดการเหตุการณ์ Webhook
app.post('/webhooks/typeform', async (req, res) => { // Verify webhook signature const signature = req.headers['typeform-signature']; const isValid = verifyTypeformSignature( req.rawBody, signature, process.env.TYPEFORM_WEBHOOK_SECRET );
if (!isValid) return res.status(401).send('Unauthorized');
const { form_response } = req.body;
await tajo.connectors.handleWebhook('typeform', { topic: 'form_response', payload: form_response });
res.status(200).send('OK');});ขีดจำกัดอัตรา
| Endpoint | ขีดจำกัดอัตรา | หมายเหตุ |
|---|---|---|
| Create API | 2 คำขอ/วินาที | การสร้างและอัปเดตฟอร์ม |
| Responses API | 2 คำขอ/วินาที | การดึงผลตอบ |
| Webhooks API | 2 คำขอ/วินาที | การจัดการ webhook |
| ทุก endpoints | 120 คำขอ/นาที | ขีดจำกัดอัตราทั่วโลก |
การแบ่งหน้าผลตอบ
Responses API ส่งคืนสูงสุด 1,000 ผลตอบต่อคำขอ ใช้พารามิเตอร์ cursor before หรือ after สำหรับการแบ่งหน้าเมื่อดึงชุดผลตอบขนาดใหญ่
การแก้ไขปัญหา
| ปัญหา | สาเหตุ | วิธีแก้ |
|---|---|---|
| ไม่ได้รับ webhook | Webhook ถูกปิดใช้งาน | เปิดใช้งาน webhook ใน Typeform dashboard |
| ผลตอบหายไป | ตัวกรองถูกใช้งาน | ตรวจสอบพารามิเตอร์ since/until และ completed |
| ข้อผิดพลาด auth 401 | Token หมดอายุ | สร้าง Personal Access Token ใหม่ |
| Rate limit 429 | คำขอมากเกินไป | ใช้การจำกัดคำขอ |
| คำตอบว่างเปล่า | ฟิลด์ไม่บังคับ | จัดการค่า null/undefined ของคำตอบ |
โหมด Debug
connectors: typeform: debug: true log_level: verbose log_webhooks: true log_responses: trueแนวทางปฏิบัติที่ดีที่สุด
- ใช้ webhooks - ต้องการ webhooks มากกว่าการ polling สำหรับการจับผลตอบแบบเรียลไทม์
- ตรวจสอบลายเซ็น - ตรวจสอบลายเซ็น webhook เสมอเพื่อความปลอดภัย
- ใช้ Hidden Fields - กรอกข้อมูลลูกค้าที่ทราบอยู่แล้วล่วงหน้าในฟอร์ม
- แมป field references - ใช้ค่า
refของฟิลด์ที่เสถียรแทนที่จะใช้ field IDs - จัดการผลตอบบางส่วน - รับมือกับคำถามที่เป็นทางเลือกและถูกข้ามไป
- ตั้งค่า retry logic - ใช้การประมวลผล webhook แบบ idempotent
ความปลอดภัย
- OAuth 2.0 - การยืนยันตัวตนแบบ scoped token
- Webhook signatures - การตรวจสอบลายเซ็น SHA-256 HMAC
- HTTPS เท่านั้น - API endpoints ทั้งหมดต้องการ TLS
- Token scoping - ขอ OAuth scopes ขั้นต่ำที่จำเป็น
- การจัดการ secret - เก็บ tokens ในตัวแปรสภาพแวดล้อมหรือ secret managers
- ความสอดคล้องกับ GDPR - ใช้ Delete Responses API สำหรับคำขอการลบข้อมูล