@@ -4,6 +4,7 @@ import OpenAI from "openai";
44
55const appId = "<APP_ID>" ;
66const talkJSSecretKey = "<TALKJS_SECRET_KEY>" ;
7+ const basePath = "https://api.talkjs.com" ;
78
89const openAISecretKey = "<OPENAI_SECRET_KEY>" ;
910const openai = new OpenAI ( { apiKey : openAISecretKey } ) ;
@@ -22,7 +23,7 @@ async function getCompletion(messageHistory) {
2223
2324async 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
4849async 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
6566async 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