telephony.incoming / web.incoming

ഒരു ഇൻബൗണ്ട് ഫോൺ കോൾ അസൈൻ ചെയ്ത ഏജന്റ് ഇല്ലാത്ത ഒരു നമ്പറിലെത്തുമ്പോഴോ, അല്ലെങ്കിൽ mode="webhook"-ലുള്ള ഒരു publishable key-യിൽ വെബ് വിഡ്ജറ്റ് സെഷൻ ആരംഭിക്കുമ്പോഴോ, ThunderPhone നിങ്ങളുടെ ലെഗസി webhook URL-ലേക്ക് ഒരു ബ്ലോക്കിംഗ് telephony.incoming / web.incoming അഭ്യർത്ഥന അയക്കുകയും കോൺഫിഗറേഷൻ പ്രതികരണത്തിനായി പരമാവധി 10 സെക്കൻഡ് കാത്തിരിക്കുകയും ചെയ്യുന്നു. ഓരോ കോളിനും prompt, വോയ്‌സ്, ടൂളുകൾ എന്നിവ ഡൈനാമിക്കായി തിരഞ്ഞെടുക്കാൻ ഈ കൈമാറ്റം ഉപയോഗിക്കുക — പൂർണ്ണമായ പാറ്റേണിനായി ഡൈനാമിക് കോൾ കോൺഫിഗറേഷൻ ഗൈഡ് കാണുക.

ഈ ബ്ലോക്കിംഗ് കൈമാറ്റത്തിന് ഫാൾബാക്കില്ല: നിങ്ങളുടെ ഹാൻഡ്‌ലർ 2xx അല്ലാത്ത സ്റ്റാറ്റസ് മടക്കിനൽകുകയോ, ടൈംഔട്ട് ആകുകയോ, അല്ലെങ്കിൽ വാലിഡേഷൻ പരാജയപ്പെടുന്ന ഒരു കോൺഫിഗറേഷൻ മടക്കിനൽകുകയോ ചെയ്താൽ, കോൾ നിരസിക്കപ്പെടും (ഫോൺ കോൾ കണക്റ്റ് ആകില്ല; വിഡ്ജറ്റ് സെഷൻ അഭ്യർത്ഥന 502/422 ഉപയോഗിച്ച് പരാജയപ്പെടും). വേഗത്തിൽ മറുപടി നൽകുക — നിങ്ങൾ തീരുമാനിക്കുന്നതിനിടെ വിളിക്കുന്നയാൾ റിങ്ബാക്ക് കേൾക്കുകയാണ്.

അഭ്യർത്ഥന പേലോഡ്

ഫോൺ കോളുകൾക്കായി (telephony.incoming):

{
  "type": "telephony.incoming",
  "data": {
    "call_id":     987654321,
    "from_number": "+14155550199",
    "to_number":   "+15551234567"
  }
}
ഫീൽഡ്തരംവിവരണം
call_idintegerകോൾ id — ഈ കോളിനായുള്ള എല്ലാ ഇവന്റുകളിലും സ്ഥിരതയുള്ളത്
from_numberstringE.164 വിളിക്കുന്നയാളുടെ നമ്പർ
to_numberstringE.164 ലക്ഷ്യസ്ഥാനം (നിങ്ങളുടെ ThunderPhone നമ്പറുകളിൽ ഒന്ന്)

വെബ് വിഡ്ജറ്റ് സെഷനുകൾക്ക് (web.incoming) data, ഫോൺ നമ്പറുകൾക്ക് പകരം എംബെഡ് ചെയ്യുന്ന പേജിനെ തിരിച്ചറിയുന്നു:

{
  "type": "web.incoming",
  "data": {
    "call_id": 987654322,
    "origin_domain": "https://example.com",
    "publishable_key_prefix": "pk_live_a1b2"
  }
}
ഫീൽഡ്തരംവിവരണം
call_idintegerകോൾ id
origin_domainstringവിഡ്ജറ്റ് ഹോസ്റ്റ് ചെയ്യുന്ന പേജ് ഒറിജിൻ
publishable_key_prefixstringസെഷൻ ആരംഭിച്ച publishable key-യുടെ ആദ്യ അക്ഷരങ്ങൾ
language, primary_languagestringവിഡ്ജറ്റ് സെഷൻ ഭാഷാ ഓവർറൈഡ് അഭ്യർത്ഥിച്ചപ്പോൾ ലഭ്യമാകും
voicestringവിഡ്ജറ്റ് സെഷൻ വോയ്‌സ് ഓവർറൈഡ് അഭ്യർത്ഥിച്ചപ്പോൾ ലഭ്യമാകും
website_contextstringവിഡ്ജറ്റ് ഓരോ സെഷനിലെയും പേജ് കോൺടെക്സ്റ്റ് കൈമാറിയപ്പോൾ ലഭ്യമാകും

പ്രതികരണ സ്കീമ

ഈ കോളിനായുള്ള ഏജന്റ് കോൺഫിഗറേഷൻ വിവരിക്കുന്ന ഒരു JSON ഒബ്ജക്റ്റ് മടക്കിനൽകുക. prompt, voice എന്നിവ നിർബന്ധമാണ്; മറ്റെല്ലാം ഐച്ഛികമാണ്.

{
  "prompt":  "You are a helpful booking assistant for Acme Restaurant.",
  "voice":   "john",
  "product": "spark",
  "background_track": null,
  "tools":   []
}
ഫീൽഡ്തരംനിർബന്ധംവിവരണം
promptstringഅതെഏജന്റിനെ നയിക്കുന്ന സിസ്റ്റം prompt
voicestringഅതെGET /v1/voices-ൽ നിന്നുള്ള വോയ്‌സ് ഐഡി, ഉദാ. john. voice_name ഒരു അപരനാമമായി സ്വീകരിക്കും. അറിയാത്ത വോയ്‌സുകൾ വാലിഡേഷൻ പരാജയപ്പെടുത്തി കോൾ നിരസിക്കും
productstringഇല്ലഡിഫോൾട്ട് spark. അനുവദനീയം: spark, bolt, storm-base, storm-base-with-ack, storm-extra, storm-extra-with-ack
thinking_levelstringഇല്ലminimal, base (ഡിഫോൾട്ട്), അല്ലെങ്കിൽ extra. Storm ഉൽപ്പന്നങ്ങൾക്കായി മറികടക്കും: storm-extra* extra നിർബന്ധമാക്കും, മറ്റ് storm-* base നിർബന്ധമാക്കും
audio_context_modestringഇല്ലfull (ഡിഫോൾട്ട്) അല്ലെങ്കിൽ reduced
watchdog_enabledbooleanഇല്ലഈ കോളിനായി മേൽനോട്ടം പ്രവർത്തനക്ഷമമാക്കുക. ഡിഫോൾട്ട് false
storm_feedback_modestringഇല്ലnone, acknowledgement (ഡിഫോൾട്ട്), അല്ലെങ്കിൽ tick
languagestringഇല്ലprimary_language-നുള്ള ചുരുക്കരൂപം
primary_languagestringഇല്ലഭാഷാ കോഡ്, സാധാരണവൽക്കരിച്ചത് (ഡിഫോൾട്ട് en). പരിഹരിക്കാനാകാത്ത കോഡുകൾ കോൾ നിരസിക്കും
has_additional_languagesbooleanഇല്ലഡിഫോൾട്ട് false
additional_languagesarray of stringഇല്ലഏജന്റിന് മാറാനാകുന്ന അധിക ഭാഷകൾ
background_trackstring | nullഇല്ലആംബിയന്റ് ഓഡിയോ ഐഡി അല്ലെങ്കിൽ null
acknowledgement_prompt_modestringഇല്ലauto (ഡിഫോൾട്ട്) അല്ലെങ്കിൽ manual (Storm-with-ack ഉൽപ്പന്നങ്ങൾ)
acknowledgement_promptstringഇല്ലacknowledgement_prompt_mode="manual" ആയിരിക്കുമ്പോൾ ഉപയോഗിക്കും
silence_interval_secondsinteger | nullഇല്ല5–120. ഒരു ചെക്ക്-ഇന്നിന് മുമ്പുള്ള കോളറുടെ നിശ്ശബ്ദതയുടെ സെക്കൻഡുകൾ
silence_max_checkinsinteger | nullഇല്ല1–10
silence_checkins_enabledbooleanഇല്ലഡിഫോൾട്ട് true
connect_tone_enabledbooleanഇല്ലഡിഫോൾട്ട് false
voicemail_actionstringഇല്ലprompt (ഡിഫോൾട്ട്), hangup, അല്ലെങ്കിൽ message
voicemail_messagestringഇല്ലvoicemail_action="message" ആയിരിക്കുമ്പോൾ ഉപയോഗിക്കും
agent_namestringഇല്ലഡാഷ്ബോർഡുകളിലും വിഡ്ജറ്റിലും കാണിക്കുന്ന പ്രദർശന നാമം
org_namestringഇല്ലഏജന്റിന്റെ വ്യക്തിത്വത്തിനായുള്ള ഓർഗനൈസേഷൻ പ്രദർശന നാമം
toolsarrayഇല്ലഇൻലൈൻ ഫംഗ്ഷൻ-ടൂൾ സ്കീമകൾ (Function Tools കാണുക)
call_idintegerഇല്ലഅഭ്യർത്ഥനയുടെ കോൾ ഐഡിയുടെ ഐച്ഛിക എക്കോ; അവഗണിക്കും

prompt, voice എന്നിവ നിർബന്ധമായതിനാൽ, {} അല്ലെങ്കിൽ വാലിഡേഷൻ പരാജയപ്പെടുന്ന ഏതെങ്കിലും പ്രതികരണം മടക്കിനൽകുന്നത് 422 ഉപയോഗിച്ച് കോൾ നിരസിക്കും — ഈ പാതയിൽ സ്റ്റാറ്റിക്-ഏജന്റ് ഫാൾബാക്ക് ഇല്ല (വെബ്ഹുക്ക് മോഡിലെ ഒരു നമ്പറിനോ കീക്കോ നിയോഗിച്ച ഏജന്റ് ഉണ്ടാകില്ല).


പ്രതികരണ വലുപ്പ പരിധി


ഉദാഹരണ ഹാൻഡ്‌ലർ

import hashlib
import hmac
import json
import os

from fastapi import FastAPI, HTTPException, Request

app = FastAPI()
WEBHOOK_SECRET = os.environ["THUNDERPHONE_WEBHOOK_SECRET"]

def verify(body: bytes, signature: str) -> bool:
    expected = hmac.new(WEBHOOK_SECRET.encode(), body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature or "")

@app.post("/thunderphone-webhook")
async def webhook(request: Request):
    body = await request.body()
    if not verify(body, request.headers.get("X-ThunderPhone-Signature", "")):
        raise HTTPException(status_code=401)

    event = json.loads(body)
    if event["type"] == "telephony.incoming":
        caller = event["data"]["from_number"]
        prompt = (
            "Greet the caller as a San Francisco local…"
            if caller.startswith("+1415")
            else "You are a friendly customer support agent…"
        )
        return {
            "prompt": prompt,
            "voice": "john",
            "product": "spark",
        }
    if event["type"] == "web.incoming":
        return {
            "prompt": "You are the website's helpful voice assistant…",
            "voice": "john",
            "product": "spark",
        }
    return {}
import crypto from "node:crypto";
import express from "express";

const app = express();
const SECRET = process.env.THUNDERPHONE_WEBHOOK_SECRET;

function verify(body, signature) {
  const expected = crypto
    .createHmac("sha256", SECRET)
    .update(body)
    .digest("hex");
  return signature &&
    crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature));
}

app.post(
  "/thunderphone-webhook",
  express.raw({ type: "application/json" }),
  (req, res) => {
    if (!verify(req.body, req.header("X-ThunderPhone-Signature"))) {
      return res.sendStatus(401);
    }
    const event = JSON.parse(req.body.toString("utf8"));

    if (event.type === "telephony.incoming" || event.type === "web.incoming") {
      const caller = event.data.from_number || "web";
      const prompt = caller.startsWith("+1415")
        ? "Greet the caller as a San Francisco local…"
        : "You are a friendly customer support agent…";
      return res.json({
        prompt,
        voice: "john",
        product: "spark",
      });
    }
    res.json({});
  },
);

ഫംഗ്ഷൻ ടൂളുകളുള്ള പ്രതികരണം

സംഭാഷണത്തിനിടെ AI-ക്ക് നിങ്ങളുടെ API-കൾ വിളിക്കാൻ കഴിയുന്നതിനായി ടൂളുകൾ അറ്റാച്ച് ചെയ്യുക:

{
  "prompt":  "You are a booking assistant. Use the available tools to help customers schedule appointments.",
  "voice":   "john",
  "product": "spark",
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "search_appointments",
        "description": "Find available appointment slots",
        "parameters": {
          "type": "object",
          "properties": {
            "date": { "type": "string", "description": "YYYY-MM-DD" },
            "service": { "type": "string" }
          },
          "required": ["date"]
        }
      },
      "endpoint": {
        "url": "https://api.example.com/appointments/search",
        "method": "POST",
        "headers": {
          "X-Api-Key": "your-key"
        }
      }
    }
  ]
}

ഉൽപ്പന്ന ടിയർ ദ്രുതസൂചിക

ഉൽപ്പന്നംലേറ്റൻസിറീസണിംഗ്സ്ഥിരീകരണം
sparkഏറ്റവും കുറവ്അടിസ്ഥാന
boltകുറവ്മെച്ചപ്പെടുത്തിയത്
storm-baseഇടത്തരംശക്തമായ
storm-base-with-ackഇടത്തരംശക്തമായചിന്തിക്കുമ്പോൾ സ്വയമേവയുള്ള ഫില്ലർ
storm-extraകൂടുതൽആഴത്തിലുള്ള
storm-extra-with-ackകൂടുതൽആഴത്തിലുള്ളചിന്തിക്കുമ്പോൾ സ്വയമേവയുള്ള ഫില്ലർ

ബന്ധപ്പെട്ടത്