Running jddemo

Id: 01K31J7PN507WVV3Y21S6EJG3P https://fn-01k31j7p-jddemo.fn.svaml.net node Updated 3d ago
Documentation
Updated Aug 19, 2025 at 4:22 PM using Sinch AI

Function Documentation

Overview

This Sinch Voice function implements a simple interactive voice response (IVR) system that greets callers and asks them to press a key to respond to a question. The question is: "Press 1 for Yes, press 2 for No, or press 3 if it is not your phone." Based on the caller’s input, the system provides a tailored response and then ends the call. This function is designed to quickly gather a simple confirmation or acknowledgment from the caller, making it useful for basic surveys, confirmations, or phone ownership verification.

Caller Experience

  1. When the caller dials the number, they hear a welcome message that includes the company name (defaulting to "Your Company" if not configured).
  2. The caller is prompted: "Press 1 for Yes, press 2 for No, or press 3 if it is not even your phone."
  3. The system waits up to 5 seconds for the caller to press a single digit.
  4. If the caller presses:
    • 1: They hear "Great! You selected Yes." followed by "Thank you for calling. Goodbye!" and the call ends.
    • 2: They hear "Okay, you selected No." followed by "Thank you for calling. Goodbye!" and the call ends.
    • 3: They hear "No worries! If it's not your phone, please let the owner know." followed by "Thank you for calling. Goodbye!" and the call ends.
  5. If the caller presses an invalid key or does not respond within the timeout:
    • The system says "Invalid selection. Please try again."
    • The menu is repeated once more with the same options.
  6. If the caller again fails to provide a valid input after the retry, the call will end (implicit from no further retries).
  7. When the call ends, the system logs the call duration and reason for disconnect but does not provide any further interaction.

Key Features

  • Simple IVR Menu: Provides a straightforward 3-option menu for quick caller input.
  • Configurable Company Name: Uses a configurable variable to personalize the greeting.
  • Input Validation and Retry: Handles invalid inputs and timeouts by prompting the caller to try again once.
  • Clear Call Termination: After a valid selection, the system thanks the caller and cleanly ends the call.
  • Logging on Disconnect: Captures call end reason and duration for analytics or troubleshooting.

Integration Points

  • Universal Config Utility: Retrieves environment variables such as COMPANY_NAME for dynamic prompts.
  • Menu Builder Utility: Constructs the IVR menu prompts and options in a reusable way.
  • SVAML Builders: Uses Sinch’s SVAML builder pattern (createIceBuilder, createPieBuilder) to generate voice responses and menus.
  • Logging: Uses console logging for call events and analytics (no external API calls or databases).

Error Handling

  • Invalid Input: If the caller presses a key outside the valid options (1, 2, 3), the system informs them of the invalid selection and repeats the menu once.
  • Timeouts: If no input is received within 5 seconds, the menu is repeated once.
  • Max Retries: After one retry on invalid input or timeout, no further retries are offered, and the call will end naturally.
  • Fallback: The system defaults to a generic company name if none is configured, ensuring the prompt always makes sense.

Technical Notes

  • The function handles three Sinch Voice callback types:
    • ICE (Incoming Call Event): Plays the initial menu prompt.
    • PIE (Prompt Input Event): Processes the caller’s DTMF input and responds accordingly.
    • DICE (Disconnect Call Event): Logs call end details; no SVAML response is returned.
  • The IVR menu is built using a fluent builder pattern with options mapped to return values (yes, no, not_my_phone).
  • The PIE handler uses a switch statement to branch logic based on the caller’s input.
  • The retry menu is constructed similarly to the initial menu but allows only one repeat.
  • The function uses English (en-US) for all spoken prompts.
  • The call ends with a hangup() SVAML command after the final message.
  • The function logs key events for monitoring but does not persist data externally.

Call Flow Diagram

%%{init: {
  "theme": "base",
  "themeVariables": {
    "primaryColor": "#F5F5F5",
    "primaryTextColor": "#000000",
    "primaryBorderColor": "#666666",
    "lineColor": "#1565C0",
    "secondaryColor": "#E8F5E8",
    "tertiaryColor": "#FFF3E0",
    "background": "#FFFFFF",
    "mainBkg": "#F5F5F5",
    "secondaryBorderColor": "#28A745",
    "tertiaryBorderColor": "#FF9800",
    "primaryColorLight": "#F5F5F5",
    "edgeLabelBackground": "#FFFFFF",
    "nodeTextColor": "#000000"
  },
  "flowchart": {
    "curve": "linear"
  }
}}%%
graph TD
    A[Incoming Call] --> B[Play Welcome Message]:::voiceOutput
    B --> C{Main Menu Choice}:::inputCollection
    C -->|Press 1| D[Say Yes Response]:::voiceOutput
    C -->|Press 2| E[Say No Response]:::voiceOutput
    C -->|Press 3| F[Say Not My Phone Response]:::voiceOutput
    C -->|Invalid Input| G[Say Invalid Selection]:::errorHandling
    C -->|Timeout| G
    G --> H[Retry Menu]:::inputCollection
    H -->|Press 1| D
    H -->|Press 2| E
    H -->|Press 3| F
    H -->|Invalid Input| I[End Call Without Response]:::callControl
    H -->|Timeout| I
    D --> J[Say Goodbye and Hangup]:::voiceOutput
    E --> J
    F --> J

Documentation generated on 8/19/2025, 9:22:43 AM using Sinch AI

Quick Stats (30 days)
Requests:
164280
Response:
742 ms
Error Rate:
5%
Memory:
19 MB
Billing Metrics
Current Month
Requests 117,013
Cost $0.023403
Last 30 Days
Requests 164,280
Cost $0.032856
Live
Loading requests...

Please wait while we fetch your function requests.

Performance Metrics

Detailed analytics and trends for your function

Performance Summary
-
Total Requests
-
Avg Response Time
-
Avg CPU Time
-
Avg Memory
-
Error Rate
-
Total Billable Time
Response Times
Request Volume
Error Rates
CPU Usage (Billable Time)

Function Settings

Environment Variables 5
Name Value Created
COMPANY_NAME Cool as company Aug 19, 2025
SALES_NUMBER +15551234567 Aug 19, 2025
SINCH_API_KEY 0bcf2128-91fb-448a-93eb-aafdb17be371 Aug 19, 2025
SINCH_PROJECT_ID 31196b37-7298-4269-b920-c978825799ac Aug 19, 2025
SINCH_VOICE_APPLICATION_KEY af742efa-2432-4f8d-bcba-b57a9abb0892 Aug 19, 2025
Secrets 2
Secret values are hidden by default for security. Click the button to reveal values. These secrets are available to your function via environment variables.
Name Value Created
SINCH_API_SECRET
••••••••
Aug 19, 2025
SINCH_VOICE_APPLICATION_SECRET
••••••••
Aug 19, 2025
Configuration Management