@fonoster/autopilot 0.22.4 → 0.22.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -63,6 +63,7 @@ const loadAssistantConfigFromFile_1 = require("./loadAssistantConfigFromFile");
|
|
|
63
63
|
const loadAssistantFromAPI_1 = require("./loadAssistantFromAPI");
|
|
64
64
|
const createLanguageModel_1 = require("./models/createLanguageModel");
|
|
65
65
|
const sendConversationEndedEvent_1 = require("./sendConversationEndedEvent");
|
|
66
|
+
const sendConversationStartedEvent_1 = require("./sendConversationStartedEvent");
|
|
66
67
|
const _1 = __importStar(require("."));
|
|
67
68
|
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
68
69
|
async function handleVoiceRequest(req, res) {
|
|
@@ -124,6 +125,13 @@ async function handleVoiceRequest(req, res) {
|
|
|
124
125
|
languageModel: languageModel
|
|
125
126
|
});
|
|
126
127
|
await autopilot.start();
|
|
128
|
+
if (assistantConfig.eventsHook?.url) {
|
|
129
|
+
await (0, sendConversationStartedEvent_1.sendConversationStartedEvent)(assistantConfig.eventsHook, {
|
|
130
|
+
appRef,
|
|
131
|
+
callRef,
|
|
132
|
+
phone: ingressNumber
|
|
133
|
+
});
|
|
134
|
+
}
|
|
127
135
|
res.on(common_1.StreamEvent.END, async () => {
|
|
128
136
|
autopilot.stop();
|
|
129
137
|
const rawChatHistory = await languageModel.getChatHistoryMessages();
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendConversationStartedEvent = sendConversationStartedEvent;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the MIT License (the "License");
|
|
11
|
+
* you may not use this file except in compliance with
|
|
12
|
+
* the License. You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://opensource.org/licenses/MIT
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
const common_1 = require("@fonoster/common");
|
|
23
|
+
const logger_1 = require("@fonoster/logger");
|
|
24
|
+
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
25
|
+
async function sendConversationStartedEvent(eventsHook, data) {
|
|
26
|
+
const { phone, appRef, callRef } = data;
|
|
27
|
+
if (!eventsHook?.events.includes(common_1.EventsHookAllowedEvents.CONVERSATION_STARTED) &&
|
|
28
|
+
!eventsHook?.events.includes(common_1.EventsHookAllowedEvents.ALL)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const parsedEventsHook = common_1.eventsHookSchema.parse(eventsHook);
|
|
32
|
+
const params = {
|
|
33
|
+
eventType: common_1.EventsHookAllowedEvents.CONVERSATION_STARTED,
|
|
34
|
+
appRef,
|
|
35
|
+
callRef,
|
|
36
|
+
phone
|
|
37
|
+
};
|
|
38
|
+
logger.verbose("dispatching conversation.started webhook", {
|
|
39
|
+
url: parsedEventsHook.url,
|
|
40
|
+
eventType: params.eventType,
|
|
41
|
+
appRef,
|
|
42
|
+
callRef
|
|
43
|
+
});
|
|
44
|
+
try {
|
|
45
|
+
await (0, common_1.sendHttpRequest)({
|
|
46
|
+
url: parsedEventsHook.url,
|
|
47
|
+
method: common_1.AllowedHttpMethod.POST,
|
|
48
|
+
headers: parsedEventsHook.headers,
|
|
49
|
+
waitForResponse: false,
|
|
50
|
+
params
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
logger.error("failed to send conversation.started webhook", {
|
|
55
|
+
url: parsedEventsHook.url,
|
|
56
|
+
method: common_1.AllowedHttpMethod.POST,
|
|
57
|
+
waitForResponse: false,
|
|
58
|
+
appRef,
|
|
59
|
+
callRef,
|
|
60
|
+
error: e instanceof Error ? e.message : e
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/autopilot",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.7",
|
|
4
4
|
"description": "Voice AI for the Fonoster platform",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@dmitryrechkin/json-schema-to-zod": "^1.0.1",
|
|
38
38
|
"@fonoster/common": "^0.22.3",
|
|
39
39
|
"@fonoster/logger": "^0.22.0",
|
|
40
|
-
"@fonoster/sdk": "^0.22.
|
|
41
|
-
"@fonoster/types": "^0.22.
|
|
42
|
-
"@fonoster/voice": "^0.22.
|
|
40
|
+
"@fonoster/sdk": "^0.22.7",
|
|
41
|
+
"@fonoster/types": "^0.22.7",
|
|
42
|
+
"@fonoster/voice": "^0.22.7",
|
|
43
43
|
"@langchain/anthropic": "^1.3.3",
|
|
44
44
|
"@langchain/community": "^1.1.1",
|
|
45
45
|
"@langchain/core": "^1.1.8",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"xstate": "^5.17.3",
|
|
60
60
|
"zod": "^3.25.76"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "af2404e51a423e45e59515282495ecdec27e0eed"
|
|
63
63
|
}
|