Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spelling errors #64

Merged
merged 3 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions config/AppSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const AppSettings: Array<ISetting> = [
packageValue: true,
i18nLabel: 'Enable Dialogflow Events (Optional)',
i18nDescription:
'Enabling this setting will automatically trigger a Dialogflow event based after the chat is ended with the agent. Please enter event name you want to cofigure in the following field(s).',
'Enabling this setting will automatically trigger a Dialogflow event based after the chat is ended with the agent. Please enter event name you want to configure in the following field(s)',
required: false,
},
{
Expand All @@ -114,7 +114,7 @@ export const AppSettings: Array<ISetting> = [
type: SettingType.STRING,
packageValue: 'end_live_chat',
i18nLabel: 'Dialogflow Agent Ended Chat Event Name (Optional)',
i18nDescription: 'Enter the Dialogflow event name you want app to trigger as soon as the chat is sucessfully ended by agent.',
i18nDescription: 'Enter the Dialogflow event name you want app to trigger as soon as the chat is successfully ended by agent.',
required: false,
},
{
Expand All @@ -123,7 +123,7 @@ export const AppSettings: Array<ISetting> = [
type: SettingType.STRING,
packageValue: 'end_live_chat',
i18nLabel: 'Dialogflow Customer Ended Chat Event Name (Optional)',
i18nDescription: 'Enter the Dialogflow event name you want app to trigger as soon as the chat is sucessfully ended by customer.',
i18nDescription: 'Enter the Dialogflow event name you want app to trigger as soon as the chat is successfully ended by customer.',
required: false,
},
{
Expand Down Expand Up @@ -213,7 +213,7 @@ export const AppSettings: Array<ISetting> = [
type: SettingType.STRING,
packageValue: 'Sorry we are unable to complete your request right now.',
i18nLabel: 'Technical Difficulty Message',
i18nDescription: 'Enter message to show to user when there is some tehnical error.',
i18nDescription: 'Enter message to show to user when there is some technical error.',
required: true,
},
{
Expand Down Expand Up @@ -251,7 +251,7 @@ export const AppSettings: Array<ISetting> = [
},
{
key: '2',
i18nLabel: '2_Erros_Information_and_Debug',
i18nLabel: '2_Errors_Information_and_Debug',
},
],
i18nLabel: 'Salesforce App Log Level',
Expand Down
4 changes: 2 additions & 2 deletions endpoints/HandoverEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export class HandoverEndpoint extends ApiEndpoint {
console.log(InfoLogs.HANDOVER_ENDPOINT_REQUEST_RECEIVED);
try {
const assoc = getRoomAssoc(request.content.roomId);
const { persisantAffinity, persistantKey } = await retrievePersistentTokens(read, assoc);
const { persistentAffinity, persistentKey } = await retrievePersistentTokens(read, assoc);

if (persisantAffinity !== null && persistantKey !== null) {
if (persistentAffinity !== null && persistentKey !== null) {
console.log(ErrorLogs.HANDOVER_ENDPOINT_REQUEST_FAILED);
return createHttpResponse(
HttpStatusCode.NOT_ACCEPTABLE,
Expand Down
16 changes: 8 additions & 8 deletions enum/ErrorLogs.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export enum ErrorLogs {
HANDOVER_ENDPOINT_REQUEST_FAILED = 'Error completing recieved handover endpoint request.',
AVAILABILITY_ENDPOINT_REQUEST_ERROR = 'Error completing recieved availability endpoint request.',
CHECKING_AVAILABILITY_ERROR = 'Error checking availabilty from Salesforce Org.',
HANDOVER_ENDPOINT_REQUEST_FAILED = 'Error completing received handover endpoint request.',
AVAILABILITY_ENDPOINT_REQUEST_ERROR = 'Error completing received availability endpoint request.',
CHECKING_AVAILABILITY_ERROR = 'Error checking availability from Salesforce Org.',
SALESFORCE_CHAT_API_NOT_FOUND = 'Salesforce Chat API endpoint not found.',
ROCKETCHAT_SERVERURL_NOT_FOUND = 'Rocket Chat Server URL not found.',
GETTING_LIVEAGENT_RESPONSE_ERROR = 'Error getting Liveagent response.',
SENDING_LIVEAGENT_CHAT_REQUEST_ERROR = 'Error sending Liveagent chat request.',
GENERATING_LIVEAGENT_SESSION_ID_ERROR = 'Error generating Liveagent session ID.',
CLOSING_LIVEAGENT_SESSION_ERROR = 'Error closing Liveagent Session.',
SENDING_MESSAGE_TO_LIVEAGENT_ERROR = 'Error sending message to Liveagent.',
LIVEAGENT_SESSION_CLASS_FAILED = 'Unexpected error occured in LiveAgentSession class.',
UNCALCULATED_AGENT_EVENT_TYPE = 'Uncalculated agent event type recieved.',
LIVEAGENT_SESSION_CLASS_FAILED = 'Unexpected error occurred in LiveAgentSession class.',
UNCALCULATED_AGENT_EVENT_TYPE = 'Uncalculated agent event type received.',
ALL_LIVEAGENTS_UNAVAILABLE = 'No Liveagent available right now.',
APP_CONFIGURATION_INVALID = 'Entered app configurations are invalid. Please recheck.',
SALESFORCE_INTERNAL_FAILURE = 'Internal failure in Saleforce Org. Please check your org for potential issues.',
UNKNOWN_ERROR_IN_CHECKING_AGENT_RESPONSE = 'Unknown error occured while checking for Liveagent chat request.',
SALESFORCE_INTERNAL_FAILURE = 'Internal failure in Salesforce Org. Please check your org for potential issues.',
UNKNOWN_ERROR_IN_CHECKING_AGENT_RESPONSE = 'Unknown error occurred while checking for Liveagent chat request.',
LIVEAGENT_SESSION_EXPIRED = 'Liveagent session expired.',
INVALID_ROOM_ID = 'Room Id not valid.',
INVALID_VISITOR_TOKEN = 'Visitor token not found.',
Expand All @@ -25,5 +25,5 @@ export enum ErrorLogs {
ENDCHAT_EVENT_API_CALL_FAIL = 'Cannot successfully call Dialogflow app incoming endpoint.',
DIALOGFLOW_ERROR_SESSION = 'Error encountered in session. Triggering DIALOGFLOW_SESSION_ERROR_EVENT',
CHASITOR_TYPING_API_CALL_FAIL = 'Cannot successfully call ChasitorTyping/ChasitorNotTyping api.',
CHASITOR_SNEAKPEAK_API_CALL_FAIL = 'Cannot successfully call ChasitorSneakPeek api.',
CHASITOR_SNEAKPEEK_API_CALL_FAIL = 'Cannot successfully call ChasitorSneakPeek api.',
}
8 changes: 4 additions & 4 deletions enum/InfoLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export enum InfoLogs {
LIVEAGENT_CHAT_REQUEST_SENT = 'Liveagent chat request sent.',
LIVEAGENT_SESSION_CLOSED = 'Liveagent Session closed.',
MESSAGE_SENT_TO_LIVEAGENT = 'Message sent to Liveagent.',
LIVAGENT_CURRENTLY_TYPING = 'Liveagent currently typing.',
LIVEAGENT_CURRENTLY_TYPING = 'Liveagent currently typing.',
LIVEAGENT_ACCEPTED_CHAT_REQUEST = 'Chat request accepted by Liveagent.',
SUCCESSFULLY_RECIEVED_LIVEAGENT_RESPONSE = 'Successfully recieved Liveagent Response.',
HANDOVER_ENDPOINT_REQUEST_RECEIVED = 'Handover endpoint request recieved',
AVAILABILITY_ENDPOINT_REQUEST_RECEIVED = 'Availability endpoint request recieved',
SUCCESSFULLY_RECEIVED_LIVEAGENT_RESPONSE = 'Successfully received Liveagent Response.',
HANDOVER_ENDPOINT_REQUEST_RECEIVED = 'Handover endpoint request received',
AVAILABILITY_ENDPOINT_REQUEST_RECEIVED = 'Availability endpoint request received',
CHATBOT_NOT_CONFIGURED = 'Chatbot is not configured in app settings.',
ENDCHAT_EVENT_NOT_ENABLED = 'Dialogflow endchat event not enabled.',
UNHANDLED_BLOCK_ACTION_ID = 'Visitor interacted with unhandled actionId block.',
Expand Down
2 changes: 1 addition & 1 deletion handlers/InitiateSalesforceSessionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class InitiateSalesforceSession {
);
await pullMessages(this.http, salesforceChatApiEndpoint, affinityToken, key)
.then(async (pullMessagesres) => {
console.log(InfoLogs.SUCCESSFULLY_RECIEVED_LIVEAGENT_RESPONSE);
console.log(InfoLogs.SUCCESSFULLY_RECEIVED_LIVEAGENT_RESPONSE);
const pullMessagesContent = pullMessagesres.content;
const pullMessagesContentParsed = JSON.parse(pullMessagesContent || '{}');
const pullMessagesMessageArray = pullMessagesContentParsed.messages;
Expand Down
6 changes: 3 additions & 3 deletions handlers/LiveAgentSessionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export class LiveAgentSession {

const salesforceChatApiEndpoint = await getSalesforceChatAPIEndpoint(this.read);
const assoc = getRoomAssoc(this.message.room.id);
const { persisantAffinity, persistantKey } = await retrievePersistentTokens(this.read, assoc);
const { persistentAffinity, persistentKey } = await retrievePersistentTokens(this.read, assoc);

if (this.message.text !== 'Closed by visitor' && persisantAffinity !== null && persistantKey !== null) {
if (this.message.text !== 'Closed by visitor' && persistentAffinity !== null && persistentKey !== null) {
const livechatRoom: ILivechatRoom = this.message.room as ILivechatRoom;
const livechatAgent: IUser = livechatRoom.servedBy ? livechatRoom.servedBy : this.message.sender;

Expand All @@ -46,7 +46,7 @@ export class LiveAgentSession {
if (this.message.text) {
messageText = this.message.text;
}
await sendMessages(this.http, salesforceChatApiEndpoint, persisantAffinity, persistantKey, messageText)
await sendMessages(this.http, salesforceChatApiEndpoint, persistentAffinity, persistentKey, messageText)
.then(async (response) => {
if (response.statusCode === 403) {
console.error('Send Message: Chat session is expired.', getError(response));
Expand Down
10 changes: 5 additions & 5 deletions handlers/SalesforceAgentAssignedHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export class SalesforceAgentAssigned {
}

const assoc = getRoomAssoc(this.data.room.id);
const persitedData = await retrievePersistentTokens(this.read, assoc);
const { persisantAffinity, persistantKey } = persitedData;
const persistedData = await retrievePersistentTokens(this.read, assoc);
const { persistentAffinity, persistentKey } = persistedData;
const salesforceAgentName = (await retrievePersistentData(this.read, assoc)).salesforceAgentName;
const technicalDifficultyMessage: string = await getAppSettingValue(this.read, AppSettingId.TECHNICAL_DIFFICULTY_MESSAGE);

Expand All @@ -45,7 +45,7 @@ export class SalesforceAgentAssigned {
const connectedToAgentMessage = `${InfoLogs.CONNECTING_TO_SALESFORCE_LIVEAGENT} ${salesforceAgentName}.`;
await sendLCMessage(this.read, this.modify, this.data.room, connectedToAgentMessage, this.data.agent);

if (persisantAffinity !== null && persistantKey !== null) {
if (persistentAffinity !== null && persistentKey !== null) {
// Executing subscribe function to listen to Liveagent messages.
const subscribeLiveAgentClass = new SubscribeToLiveAgent(
this.app,
Expand All @@ -58,8 +58,8 @@ export class SalesforceAgentAssigned {
salesforceChatApiEndpoint,
LAChatEndedMessage,
technicalDifficultyMessage,
persisantAffinity,
persistantKey,
persistentAffinity,
persistentKey,
);
await subscribeLiveAgentClass.subscribeToLiveAgent();
}
Expand Down
22 changes: 11 additions & 11 deletions helperFunctions/PersistenceHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export async function retrievePersistentTokens(read: IRead, assoc: RocketChatAss

return {
id: contentParsed.id,
persisantAffinity: contentParsed.affinityToken as string,
persistantKey: contentParsed.key as string,
persistentAffinity: contentParsed.affinityToken as string,
persistentKey: contentParsed.key as string,
};
}

return {
id: null,
persisantAffinity: null,
persistantKey: null,
persistentAffinity: null,
persistentKey: null,
};
} catch (error) {
throw new Error(error);
Expand All @@ -37,8 +37,8 @@ export async function retrievePersistentData(read: IRead, assoc: RocketChatAssoc
return {
id: contentParsed.id,
chasitorIdleTimeout: contentParsed.chasitorIdleTimeout,
persisantAffinity: contentParsed.affinityToken as string,
persistantKey: contentParsed.key as string,
persistentAffinity: contentParsed.affinityToken as string,
persistentKey: contentParsed.key as string,
sneakPeekEnabled: contentParsed.sneakPeekEnabled as boolean,
salesforceAgentName: contentParsed.salesforceAgentName as string,
isIdleSessionTimerScheduled: contentParsed.isIdleSessionTimerScheduled as boolean,
Expand All @@ -49,8 +49,8 @@ export async function retrievePersistentData(read: IRead, assoc: RocketChatAssoc
return {
id: null,
chasitorIdleTimeout: null,
persisantAffinity: null,
persistantKey: null,
persistentAffinity: null,
persistentKey: null,
sneakPeekEnabled: null,
salesforceAgentName: null,
isIdleSessionTimerScheduled: null,
Expand All @@ -64,11 +64,11 @@ export async function retrievePersistentData(read: IRead, assoc: RocketChatAssoc
export async function updatePersistentData(read: IRead, persistence: IPersistence, assoc: RocketChatAssociationRecord, data: object) {
try {
const persistentData = await retrievePersistentData(read, assoc);
const { persisantAffinity, persistantKey } = persistentData;
const { persistentAffinity, persistentKey } = persistentData;
const updatedData = {
...persistentData,
affinityToken: persisantAffinity,
key: persistantKey,
affinityToken: persistentAffinity,
key: persistentKey,
...data,
};
await persistence.updateByAssociation(assoc, updatedData, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export class CheckChatStatus {
return;
} else if (response.statusCode === 204 || response.statusCode === 409) {
// Empty Response from Liveagent
const { persisantAffinity, persistantKey } = await retrievePersistentTokens(this.read, this.assoc);
if (persisantAffinity !== null && persistantKey !== null) {
const { persistentAffinity, persistentKey } = await retrievePersistentTokens(this.read, this.assoc);
if (persistentAffinity !== null && persistentKey !== null) {
await this.checkCurrentChatStatus();
} else {
await checkAgentStatusDirectCallback.checkAgentStatusCallbackError(this.technicalDifficultyMessage);
return;
}
} else {
console.log(InfoLogs.SUCCESSFULLY_RECIEVED_LIVEAGENT_RESPONSE, response);
console.log(InfoLogs.SUCCESSFULLY_RECEIVED_LIVEAGENT_RESPONSE, response);
const { content } = response;
const contentParsed = JSON.parse(content || '{}');
const messageArray = contentParsed.messages;
Expand All @@ -82,12 +82,19 @@ export class CheckChatStatus {
const chatEstablishedMessage = messageArray[0].message;
const chasitorIdleTimeout = chatEstablishedMessage.chasitorIdleTimeout || false;
const sneakPeekEnabled = chatEstablishedMessage.sneakPeekEnabled;
const { id, persisantAffinity, persistantKey } = await retrievePersistentTokens(this.read, this.assoc);
const { id, persistentAffinity, persistentKey } = await retrievePersistentTokens(this.read, this.assoc);
const salesforceAgentName = chatEstablishedMessage.name;

await this.persistence.updateByAssociation(
this.assoc,
{ id, affinityToken: persisantAffinity, key: persistantKey, chasitorIdleTimeout, sneakPeekEnabled, salesforceAgentName },
{
id,
affinityToken: persistentAffinity,
key: persistentKey,
chasitorIdleTimeout,
sneakPeekEnabled,
salesforceAgentName,
},
true,
);

Expand Down Expand Up @@ -121,8 +128,8 @@ export class CheckChatStatus {
await checkAgentStatusDirectCallback.checkAgentStatusCallbackError(this.technicalDifficultyMessage);
return;
} else {
const { persisantAffinity, persistantKey } = await retrievePersistentTokens(this.read, this.assoc);
if (persisantAffinity !== null && persistantKey !== null) {
const { persistentAffinity, persistentKey } = await retrievePersistentTokens(this.read, this.assoc);
if (persistentAffinity !== null && persistentKey !== null) {
await this.checkCurrentChatStatus();
} else {
await checkAgentStatusDirectCallback.checkAgentStatusCallbackError(this.technicalDifficultyMessage);
Expand All @@ -131,8 +138,8 @@ export class CheckChatStatus {
}
} else {
console.error(ErrorLogs.UNKNOWN_ERROR_IN_CHECKING_AGENT_RESPONSE, response);
const { persisantAffinity, persistantKey } = await retrievePersistentTokens(this.read, this.assoc);
if (persisantAffinity !== null && persistantKey !== null) {
const { persistentAffinity, persistentKey } = await retrievePersistentTokens(this.read, this.assoc);
if (persistentAffinity !== null && persistentKey !== null) {
await this.checkCurrentChatStatus();
} else {
await checkAgentStatusDirectCallback.checkAgentStatusCallbackError(this.technicalDifficultyMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class SubscribeToLiveAgent {
private salesforceChatApiEndpoint: string,
private LAChatEndedMessage: string,
private technicalDifficultyMessage: string,
private persisantAffinity: string,
private persistantKey: string,
private persistentAffinity: string,
private persistentKey: string,
) {}

public async subscribeToLiveAgent() {
Expand All @@ -37,23 +37,23 @@ export class SubscribeToLiveAgent {
this.assoc,
this.technicalDifficultyMessage,
);
await pullMessages(this.http, this.salesforceChatApiEndpoint, this.persisantAffinity, this.persistantKey)
await pullMessages(this.http, this.salesforceChatApiEndpoint, this.persistentAffinity, this.persistentKey)
.then(async (response) => {
if (response.statusCode === 403) {
console.log(ErrorLogs.LIVEAGENT_SESSION_EXPIRED);
await handleEndChatCallback.handleEndChat();
return;
} else if (response.statusCode === 204 || response.statusCode === 409) {
const { persisantAffinity, persistantKey } = await retrievePersistentTokens(this.read, this.assoc);
if (persisantAffinity !== null && persistantKey !== null) {
const { persistentAffinity, persistentKey } = await retrievePersistentTokens(this.read, this.assoc);
if (persistentAffinity !== null && persistentKey !== null) {
await this.subscribeToLiveAgent();
} else {
console.log(ErrorLogs.LIVEAGENT_SESSION_EXPIRED);
await handleEndChatCallback.handleEndChat();
return;
}
} else {
console.log(InfoLogs.SUCCESSFULLY_RECIEVED_LIVEAGENT_RESPONSE, response);
console.log(InfoLogs.SUCCESSFULLY_RECEIVED_LIVEAGENT_RESPONSE, response);
const { content } = response;
const contentParsed = JSON.parse(content || '{}');
const messageArray = contentParsed.messages;
Expand All @@ -74,8 +74,8 @@ export class SubscribeToLiveAgent {
this.assoc,
this.persistence,
);
const { persisantAffinity, persistantKey } = await retrievePersistentTokens(this.read, this.assoc);
if (persisantAffinity !== null && persistantKey !== null) {
const { persistentAffinity, persistentKey } = await retrievePersistentTokens(this.read, this.assoc);
if (persistentAffinity !== null && persistentKey !== null) {
await this.subscribeToLiveAgent();
} else {
console.log(ErrorLogs.LIVEAGENT_SESSION_EXPIRED);
Expand Down
4 changes: 2 additions & 2 deletions lib/IdleSessionTimeoutProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export class IdleSessionTimeoutProcessor implements IProcessor {

public async processor(jobContext: IJobContext, read: IRead, modify: IModify, http: IHttp, persis: IPersistence): Promise<void> {
const assoc = getRoomAssoc(jobContext.rid);
const { persisantAffinity, persistantKey } = await retrievePersistentTokens(read, assoc);
const { persistentAffinity, persistentKey } = await retrievePersistentTokens(read, assoc);

if (persisantAffinity !== null && persistantKey !== null) {
if (persistentAffinity !== null && persistentKey !== null) {
const room = (await read.getRoomReader().getById(jobContext.rid)) as ILivechatRoom;
if (!room) {
throw new Error(`${ErrorLogs.INVALID_ROOM_ID} ${jobContext.rid}`);
Expand Down
6 changes: 3 additions & 3 deletions lib/LivechatRoomClosedHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export class LivechatRoomClosedClass {

public async closeChatFromSalesforce() {
const { customFields, id: rid } = this.room;
const { persisantAffinity, persistantKey } = await retrievePersistentTokens(this.read, getRoomAssoc(rid));
const { persistentAffinity, persistentKey } = await retrievePersistentTokens(this.read, getRoomAssoc(rid));
const salesforceChatApiEndpoint = await getSalesforceChatAPIEndpoint(this.read);

if (persisantAffinity !== null && persistantKey !== null) {
if (persistentAffinity !== null && persistentKey !== null) {
let reason = '';
if (customFields && customFields.customerIdleTimeout === true) {
reason = 'clientIdleTimeout';
}
await closeChat(this.http, salesforceChatApiEndpoint, persisantAffinity, persistantKey, reason)
await closeChat(this.http, salesforceChatApiEndpoint, persistentAffinity, persistentKey, reason)
.then(async () => {
console.log(InfoLogs.LIVEAGENT_SESSION_CLOSED);
await this.persistence.removeByAssociation(getRoomAssoc(rid));
Expand Down
Loading