UNPKG

@tixae-labs/web-sdk

Version:

Javascript Web SDK for doing WebRTC AI Voice Calls with Convocore.

548 lines (547 loc) 16.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defaultSystemTools = exports.calendlyMethodEnum = exports.shopifyMethodEnum = exports.airtableMethodEnum = exports.sheetsMethodEnum = exports.calendarMethodEnum = exports.defaultSystemToolsKeys = exports.calendlyVariablesIds = exports.shopifyVariablesIds = exports.airtableVariablesIds = exports.sheetsVariablesIds = exports.calendarVariablesIds = exports.defaultSystemVariables = exports.systemVariablesKeys = void 0; const zod_1 = require("zod"); // import { // FinalUIEngineResponseSchema, // UIEngineMessageType, // } from "./uiEngineMessageSchemas"; // import { printNode, zodToTs } from "zod-to-ts"; exports.systemVariablesKeys = zod_1.z.enum([ "phone_number", "timestamp", "channel", "calendar_availability_day", "calendar_event_summary", "calendar_event_description", "calendar_event_attendees", "calendar_event_start_time", "calendar_event_end_time", "calendar_method", "calendar_event_to_delete_id", ]); // exports.defaultSystemVariables = [ { id: "phone_number", type: "string", required: true, key: "phone_number", in: "input", isEnv: true, description: "The phone number of the caller.", isSystem: true, }, { id: "channel", type: "string", required: true, key: "channel", in: "input", isEnv: true, description: "The channel of the current conversation, web-chat, voice, whatsapp, etc..", isSystem: true, }, { id: "timestamp", type: "string", required: true, key: "timestamp", in: "input", isEnv: true, description: "The timestamp of the current conversation in ISO 8601 format.", isSystem: true, }, { id: "calendar_availability_day", type: "string", key: "calendar_availability_day", required: false, isSystem: true, description: "The date in which to get the available slots in it", }, { id: "calendar_event_summary", type: "string", key: "calendar_event_summary", required: false, isSystem: true, description: "The summary of the event, it can be the name of the event or the name of the person you are meeting with", }, { id: "calendar_event_description", type: "string", key: "calendar_event_description", required: false, isSystem: true, description: "The description of the event, it could include the meeting point, the date, the time, user's contact information, etc.", }, { id: "calendar_event_attendees", type: "string", key: "calendar_event_attendees", required: false, isSystem: true, description: "The attendee emails of the event separated by comma (,) like this: email1,email2,email3", }, { id: "calendar_event_start_time", type: "string", key: "calendar_event_start_time", required: false, isSystem: true, description: "The start time of the event", }, { id: "calendar_event_end_time", type: "string", key: "calendar_event_end_time", required: false, isSystem: true, description: "The end time of the event", }, { id: "calendar_method", type: "string", key: "calendar_method", description: "The method to use for the calendar operation it can be one of the following: list-calendars, create-event, check-availability, get-slots, delete-event", required: true, isSystem: true, }, { id: "calendar_event_to_delete_id", type: "string", key: "calendar_event_to_delete_id", required: false, isSystem: true, description: "The id of the event to delete, you can get it from the previous chat, its the eid of the created event", }, { id: "sheets_method", type: "string", key: "sheets_method", description: "The method to use for the sheets operation, it can be either 'read' or 'write'", required: true, isSystem: true, }, { id: "sheets_sheet_id", type: "string", key: "sheets_sheet_id", description: "The ID of the sheet to interact with", required: false, isSystem: true, }, { id: "sheets_range", type: "string", key: "sheets_range", description: "The range to interact with in A1 notation (e.g., 'Sheet1!A1:D10')", required: false, isSystem: true, }, { id: "sheets_data", type: "string", key: "sheets_data", description: "The data to append to the sheet in JSON format", required: false, isSystem: true, }, { id: "sheets_query", type: "string", key: "sheets_query", description: "The query to search for data in the sheet", required: false, isSystem: true, }, // Airtable variables { id: "airtable_method", type: "string", key: "airtable_method", description: "The method to use for the Airtable operation: 'read', 'create', 'update', or 'upsert'", required: true, isSystem: true, }, { id: "airtable_base_id", type: "string", key: "airtable_base_id", description: "The ID of the Airtable base to interact with", required: false, isSystem: true, }, { id: "airtable_table_id", type: "string", key: "airtable_table_id", description: "The ID or name of the Airtable table to interact with", required: false, isSystem: true, }, { id: "airtable_record_data", type: "string", key: "airtable_record_data", description: "The record data to create or update in JSON format", required: false, isSystem: true, }, { id: "airtable_filter_formula", type: "string", key: "airtable_filter_formula", description: "Filter formula to query records (e.g., '{Email} = \"user@example.com\"')", required: false, isSystem: true, }, { id: "airtable_identifier_field", type: "string", key: "airtable_identifier_field", description: "Field name to use as identifier for upsert operations", required: false, isSystem: true, }, { id: "airtable_identifier_value", type: "string", key: "airtable_identifier_value", description: "Value of the identifier field for upsert operations", required: false, isSystem: true, }, // Shopify variables { id: "shopify_method", type: "string", key: "shopify_method", description: "The method to use for the Shopify operation: only 'read' is supported", required: true, isSystem: true, }, { id: "shopify_resource", type: "string", key: "shopify_resource", description: "The Shopify resource to interact with: 'orders', 'products', 'product_listings', 'customers' (read-only)", required: true, isSystem: true, }, { id: "shopify_resource_id", type: "string", key: "shopify_resource_id", description: "The ID of the specific resource to get (optional for single item lookup)", required: false, isSystem: true, }, { id: "shopify_query", type: "string", key: "shopify_query", description: "Query parameters for filtering read operations", required: false, isSystem: true, }, // Calendly variables { id: "calendly_method", type: "string", key: "calendly_method", description: "The method to use for the Calendly operation: 'list_event_types', 'check_availability', 'create_event', 'list_scheduled_events', or 'cancel_event'", required: true, isSystem: true, }, { id: "calendly_event_type_uri", type: "string", key: "calendly_event_type_uri", description: "The URI of the Calendly event type (required for check_availability and create_event)", required: false, isSystem: true, }, { id: "calendly_start_time", type: "string", key: "calendly_start_time", description: "Start time in ISO 8601 format (required for check_availability and create_event)", required: false, isSystem: true, }, { id: "calendly_end_time", type: "string", key: "calendly_end_time", description: "End time in ISO 8601 format (required for check_availability and create_event)", required: false, isSystem: true, }, { id: "calendly_event_uri", type: "string", key: "calendly_event_uri", description: "The URI of the scheduled event (required for cancel_event)", required: false, isSystem: true, }, { id: "calendly_invitee_email", type: "string", key: "calendly_invitee_email", description: "Email address of the invitee (required for create_event)", required: false, isSystem: true, }, { id: "calendly_invitee_name", type: "string", key: "calendly_invitee_name", description: "Name of the invitee (optional for create_event)", required: false, isSystem: true, }, { id: "calendly_timezone", type: "string", key: "calendly_timezone", description: "Timezone for the event (optional, defaults to user's timezone)", required: false, isSystem: true, }, { id: "team_key", type: "string", key: "team_key", description: "The team to notify when the handoff is initiated.", required: false, isSystem: true, }, { id: "issue_summary", type: "string", key: "issue_summary", description: "The summary of the conversation to be used for the handoff.", required: false, isSystem: true, }, ]; // calendar variables ids exports.calendarVariablesIds = [ "calendar_availability_day", "calendar_event_summary", "calendar_event_description", "calendar_event_attendees", "calendar_event_start_time", "calendar_event_end_time", "calendar_method", "calendar_event_to_delete_id", ]; // sheets variables ids exports.sheetsVariablesIds = ["sheets_method", "sheets_sheet_id"]; // airtable variables ids exports.airtableVariablesIds = [ "airtable_method", "airtable_base_id", "airtable_table_id", "airtable_record_data", "airtable_filter_formula", "airtable_identifier_field", "airtable_identifier_value", ]; // shopify variables ids exports.shopifyVariablesIds = [ "shopify_method", "shopify_resource", "shopify_resource_id", "shopify_query", ]; // calendly variables ids exports.calendlyVariablesIds = [ "calendly_method", "calendly_event_type_uri", "calendly_start_time", "calendly_end_time", "calendly_event_uri", "calendly_invitee_email", "calendly_invitee_name", "calendly_timezone", ]; exports.defaultSystemToolsKeys = zod_1.z.enum([ "forward-call", "end-call", "human-handoff", "google-calendar", "google-sheets", "airtable", "shopify", "calendly", ]); exports.calendarMethodEnum = zod_1.z.enum([ "list-calendars", "create-event", "check-availability", "get-slots", "delete-event", ]); exports.sheetsMethodEnum = zod_1.z.enum(["read", "write"]); exports.airtableMethodEnum = zod_1.z.enum([ "read", "create", "update", "upsert", ]); exports.shopifyMethodEnum = zod_1.z.enum(["read"]); exports.calendlyMethodEnum = zod_1.z.enum([ "list_event_types", "check_availability", "create_event", "list_scheduled_events", "cancel_event", ]); function generateId() { return (Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)); } exports.defaultSystemTools = [ { id: "end-call", name: "end-call", description: "This tool instantly ends the call once used.", variablesIds: [], channels: ["telephony", "voice"], }, { id: "forward-call", name: "forward-call", description: "Forward a call to the given phone number and only works on phone channels (Twilio)", variablesIds: ["phone_number"], channels: ["telephony"], }, { id: "human-handoff", name: "human-handoff", description: "Hand off the call to a human agent, works on all channels including voice so be careful when to use it.", variablesIds: ["team_key", "issue_summary"], channels: [ "telephony", "web-chat", "whatsapp", "instagram", "telegram", "discord", "messenger", ], }, { id: "google-calendar", name: "google-calendar", description: "Interact with Google Calendar - create events, check availability, get slots, delete events, if an event is created you can use the delete-event method to delete it", variablesIds: [ "calendar_availability_day", "calendar_event_summary", "calendar_event_description", "calendar_event_attendees", "calendar_event_start_time", "calendar_event_end_time", "calendar_method", "calendar_event_to_delete_id", ], channels: [ "web-chat", "whatsapp", "instagram", "telegram", "discord", "messenger", ], }, { id: "google-sheets", name: "google-sheets", description: "Interact with Google Sheets - access lead data, query, and manage spreadsheets", variablesIds: [ "sheets_method", "sheets_sheet_id", "sheets_range", "sheets_data", "sheets_query", ], channels: [ "web-chat", "whatsapp", "instagram", "telegram", "discord", "messenger", ], }, { id: "airtable", name: "airtable", description: "Interact with Airtable - create, read, update records in your connected bases and tables", variablesIds: [ "airtable_method", "airtable_base_id", "airtable_table_id", "airtable_record_data", "airtable_filter_formula", "airtable_identifier_field", "airtable_identifier_value", ], channels: [ "web-chat", "whatsapp", "instagram", "telegram", "discord", "messenger", ], }, { id: "shopify", name: "shopify", description: "Read data from Shopify - view orders, products, product listings, and customers (read-only access)", variablesIds: [ "shopify_method", "shopify_resource", "shopify_resource_id", "shopify_query", ], channels: [ "web-chat", "whatsapp", "instagram", "telegram", "discord", "messenger", ], }, { id: "calendly", name: "calendly", description: "Interact with Calendly scheduling - FIRST list event types to see available meeting types, then check availability for specific dates, create bookings with invitee details, view scheduled events, and cancel existing bookings. Always start with list_event_types before checking availability.", variablesIds: [ "calendly_method", "calendly_event_type_uri", "calendly_start_time", "calendly_end_time", "calendly_event_uri", "calendly_invitee_email", "calendly_invitee_name", "calendly_timezone", ], channels: [ "web-chat", "whatsapp", "instagram", "telegram", "discord", "messenger", "telephony", "voice", ], }, ];