Skip to content

Commit c6e9a26

Browse files
committed
Use basePath
1 parent 11e685f commit c6e9a26

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

chatbot-integration/openai-chatgpt/server.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import OpenAI from "openai";
44

55
const appId = "<APP_ID>";
66
const talkJSSecretKey = "<TALKJS_SECRET_KEY>";
7+
const basePath = "https://api.talkjs.com";
78

89
const openAISecretKey = "<OPENAI_SECRET_KEY>";
910
const openai = new OpenAI({ apiKey: openAISecretKey });
@@ -22,7 +23,7 @@ async function getCompletion(messageHistory) {
2223

2324
async function sendInitialMessage(conversationId) {
2425
const response = await fetch(
25-
`https://api.talkjs.com/v1/${appId}/conversations/${conversationId}/messages`,
26+
`${basePath}/v1/${appId}/conversations/${conversationId}/messages`,
2627
{
2728
method: "POST",
2829
headers: {
@@ -47,7 +48,7 @@ async function sendInitialMessage(conversationId) {
4748

4849
async function updateBotMessage(conversationId, messageId, text) {
4950
return fetch(
50-
`https://api.talkjs.com/v1/${appId}/conversations/${conversationId}/messages/${messageId}`,
51+
`${basePath}/v1/${appId}/conversations/${conversationId}/messages/${messageId}`,
5152
{
5253
method: "PUT",
5354
headers: {
@@ -64,7 +65,7 @@ async function updateBotMessage(conversationId, messageId, text) {
6465

6566
async function setUserAccess(conversationId, userId, access) {
6667
return fetch(
67-
`https://api.talkjs.com/v1/${appId}/conversations/${conversationId}/participants/${userId}`,
68+
`${basePath}/v1/${appId}/conversations/${conversationId}/participants/${userId}`,
6869
{
6970
method: "PUT",
7071
headers: {

0 commit comments

Comments
 (0)