Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2d9bd65eb |
@@ -33,8 +33,6 @@ gem 'liquid'
|
||||
gem 'commonmarker'
|
||||
# Validate Data against JSON Schema
|
||||
gem 'json_schemer'
|
||||
# used in swagger build
|
||||
gem 'json_refs'
|
||||
# Rack middleware for blocking & throttling abusive requests
|
||||
gem 'rack-attack', '>= 6.7.0'
|
||||
# a utility tool for streaming, flexible and safe downloading of remote files
|
||||
@@ -198,6 +196,9 @@ group :development do
|
||||
gem 'scss_lint', require: false
|
||||
gem 'web-console', '>= 4.2.1'
|
||||
|
||||
# used in swagger build
|
||||
gem 'json_refs'
|
||||
|
||||
# When we want to squash migrations
|
||||
gem 'squasher'
|
||||
|
||||
|
||||
@@ -152,13 +152,11 @@ class Messages::Instagram::BaseMessageBuilder < Messages::Messenger::MessageBuil
|
||||
end
|
||||
|
||||
def message_already_exists?
|
||||
find_message_by_source_id(@messaging[:message][:mid]).present?
|
||||
end
|
||||
cw_message = conversation.messages.where(
|
||||
source_id: @messaging[:message][:mid]
|
||||
).first
|
||||
|
||||
def find_message_by_source_id(source_id)
|
||||
return unless source_id
|
||||
|
||||
@message = Message.find_by(source_id: source_id)
|
||||
cw_message.present?
|
||||
end
|
||||
|
||||
def all_unsupported_files?
|
||||
|
||||
@@ -68,7 +68,7 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
|
||||
|
||||
def article_params
|
||||
params.require(:article).permit(
|
||||
:title, :slug, :position, :content, :description, :category_id, :author_id, :associated_article_id, :status,
|
||||
:title, :slug, :position, :content, :description, :position, :category_id, :author_id, :associated_article_id, :status,
|
||||
:locale, meta: [:title,
|
||||
:description,
|
||||
{ tags: [] }]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class Platform::Api::V1::UsersController < PlatformController
|
||||
# ref: https://stackoverflow.com/a/45190318/939299
|
||||
# set resource is called for other actions already in platform controller
|
||||
# we want to add login and token to that chain as well
|
||||
before_action(only: [:login, :token]) { set_resource }
|
||||
before_action(only: [:login, :token]) { validate_platform_app_permissible }
|
||||
# we want to add login to that chain as well
|
||||
before_action(only: [:login]) { set_resource }
|
||||
before_action(only: [:login]) { validate_platform_app_permissible }
|
||||
|
||||
def show; end
|
||||
|
||||
@@ -18,8 +18,6 @@ class Platform::Api::V1::UsersController < PlatformController
|
||||
render json: { url: @resource.generate_sso_link }
|
||||
end
|
||||
|
||||
def token; end
|
||||
|
||||
def update
|
||||
@resource.assign_attributes(user_update_params)
|
||||
|
||||
|
||||
@@ -134,6 +134,10 @@ class ConversationApi extends ApiClient {
|
||||
return axios.get(`${this.url}/${conversationId}/attachments`);
|
||||
}
|
||||
|
||||
requestCopilot(conversationId, body) {
|
||||
return axios.post(`${this.url}/${conversationId}/copilot`, body);
|
||||
}
|
||||
|
||||
getInboxAssistant(conversationId) {
|
||||
return axios.get(`${this.url}/${conversationId}/inbox_assistant`);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
}
|
||||
|
||||
.tabs--container--with-border {
|
||||
@apply border-b border-b-n-weak;
|
||||
@apply border-b border-n-weak;
|
||||
}
|
||||
|
||||
.tabs--container--compact.tab--chat-type {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
import { nextTick, ref, watch, computed } from 'vue';
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useTrack } from 'dashboard/composables';
|
||||
import { COPILOT_EVENTS } from 'dashboard/helper/AnalyticsHelper/events';
|
||||
|
||||
@@ -7,10 +8,8 @@ import CopilotInput from './CopilotInput.vue';
|
||||
import CopilotLoader from './CopilotLoader.vue';
|
||||
import CopilotAgentMessage from './CopilotAgentMessage.vue';
|
||||
import CopilotAssistantMessage from './CopilotAssistantMessage.vue';
|
||||
import CopilotThinkingGroup from './CopilotThinkingGroup.vue';
|
||||
import ToggleCopilotAssistant from './ToggleCopilotAssistant.vue';
|
||||
import CopilotHeader from './CopilotHeader.vue';
|
||||
import CopilotEmptyState from './CopilotEmptyState.vue';
|
||||
import Icon from '../icon/Icon.vue';
|
||||
|
||||
const props = defineProps({
|
||||
supportAgent: {
|
||||
@@ -27,7 +26,7 @@ const props = defineProps({
|
||||
},
|
||||
conversationInboxType: {
|
||||
type: String,
|
||||
default: '',
|
||||
required: true,
|
||||
},
|
||||
assistants: {
|
||||
type: Array,
|
||||
@@ -39,13 +38,22 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['sendMessage', 'reset', 'setAssistant', 'close']);
|
||||
const emit = defineEmits(['sendMessage', 'reset', 'setAssistant']);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const COPILOT_USER_ROLES = ['assistant', 'system'];
|
||||
|
||||
const sendMessage = message => {
|
||||
emit('sendMessage', message);
|
||||
useTrack(COPILOT_EVENTS.SEND_MESSAGE);
|
||||
};
|
||||
|
||||
const useSuggestion = opt => {
|
||||
emit('sendMessage', t(opt.prompt));
|
||||
useTrack(COPILOT_EVENTS.SEND_SUGGESTED);
|
||||
};
|
||||
|
||||
const handleReset = () => {
|
||||
emit('reset');
|
||||
};
|
||||
@@ -59,28 +67,20 @@ const scrollToBottom = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const groupedMessages = computed(() => {
|
||||
const result = [];
|
||||
let thinkingGroup = [];
|
||||
|
||||
props.messages.forEach(message => {
|
||||
if (message.role === 'assistant_thinking') {
|
||||
thinkingGroup.push(message);
|
||||
} else {
|
||||
if (thinkingGroup.length > 0) {
|
||||
result.push({ type: 'thinking_group', messages: thinkingGroup });
|
||||
thinkingGroup = [];
|
||||
}
|
||||
result.push({ type: 'message', message });
|
||||
}
|
||||
});
|
||||
|
||||
if (thinkingGroup.length > 0) {
|
||||
result.push({ type: 'thinking_group', messages: thinkingGroup });
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
const promptOptions = [
|
||||
{
|
||||
label: 'CAPTAIN.COPILOT.PROMPTS.SUMMARIZE.LABEL',
|
||||
prompt: 'CAPTAIN.COPILOT.PROMPTS.SUMMARIZE.CONTENT',
|
||||
},
|
||||
{
|
||||
label: 'CAPTAIN.COPILOT.PROMPTS.SUGGEST.LABEL',
|
||||
prompt: 'CAPTAIN.COPILOT.PROMPTS.SUGGEST.CONTENT',
|
||||
},
|
||||
{
|
||||
label: 'CAPTAIN.COPILOT.PROMPTS.RATE.LABEL',
|
||||
prompt: 'CAPTAIN.COPILOT.PROMPTS.RATE.CONTENT',
|
||||
},
|
||||
];
|
||||
|
||||
watch(
|
||||
[() => props.messages, () => props.isCaptainTyping],
|
||||
@@ -93,62 +93,60 @@ watch(
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col h-full text-sm leading-6 tracking-tight w-full">
|
||||
<CopilotHeader
|
||||
:has-messages="messages.length > 0"
|
||||
@reset="handleReset"
|
||||
@close="$emit('close')"
|
||||
/>
|
||||
<div
|
||||
ref="chatContainer"
|
||||
class="flex-1 flex px-4 py-4 overflow-y-auto items-start"
|
||||
>
|
||||
<div v-if="messages.length" class="space-y-6 flex-1 flex flex-col w-full">
|
||||
<template
|
||||
v-for="item in groupedMessages"
|
||||
:key="item.type === 'message' ? item.message.id : 'thinking-group'"
|
||||
>
|
||||
<template v-if="item.type === 'message'">
|
||||
<CopilotAgentMessage
|
||||
v-if="item.message.role === 'user'"
|
||||
:support-agent="supportAgent"
|
||||
:message="item.message"
|
||||
/>
|
||||
<CopilotAssistantMessage
|
||||
v-else-if="
|
||||
item.message.role === 'assistant' ||
|
||||
item.message.role === 'system'
|
||||
"
|
||||
:message="item.message"
|
||||
:conversation-inbox-type="conversationInboxType"
|
||||
/>
|
||||
</template>
|
||||
<CopilotThinkingGroup
|
||||
v-else
|
||||
:messages="item.messages"
|
||||
:has-assistant-message-after="
|
||||
groupedMessages[groupedMessages.indexOf(item) + 1]?.message
|
||||
?.role === 'assistant'
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
<div ref="chatContainer" class="flex-1 px-4 py-4 space-y-6 overflow-y-auto">
|
||||
<template v-for="message in messages" :key="message.id">
|
||||
<CopilotAgentMessage
|
||||
v-if="message.role === 'user'"
|
||||
:support-agent="supportAgent"
|
||||
:message="message"
|
||||
/>
|
||||
<CopilotAssistantMessage
|
||||
v-else-if="COPILOT_USER_ROLES.includes(message.role)"
|
||||
:message="message"
|
||||
:conversation-inbox-type="conversationInboxType"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<CopilotLoader v-if="isCaptainTyping" />
|
||||
<CopilotLoader v-if="isCaptainTyping" />
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="!messages.length"
|
||||
class="h-full w-full flex items-center justify-center"
|
||||
>
|
||||
<div class="h-fit px-3 py-3 space-y-1">
|
||||
<span class="text-xs text-n-slate-10">
|
||||
{{ $t('COPILOT.TRY_THESE_PROMPTS') }}
|
||||
</span>
|
||||
<button
|
||||
v-for="prompt in promptOptions"
|
||||
:key="prompt.label"
|
||||
class="px-2 py-1 rounded-md border border-n-weak bg-n-slate-2 text-n-slate-11 flex items-center gap-1"
|
||||
@click="() => useSuggestion(prompt)"
|
||||
>
|
||||
<span>{{ t(prompt.label) }}</span>
|
||||
<Icon icon="i-lucide-chevron-right" />
|
||||
</button>
|
||||
</div>
|
||||
<CopilotEmptyState
|
||||
v-if="!messages.length"
|
||||
@use-suggestion="sendMessage"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="mx-3 mt-px mb-2">
|
||||
<div class="flex items-center gap-2 justify-between w-full mb-1">
|
||||
<ToggleCopilotAssistant
|
||||
v-if="assistants.length > 1"
|
||||
v-if="assistants.length"
|
||||
:assistants="assistants"
|
||||
:active-assistant="activeAssistant"
|
||||
@set-assistant="$event => emit('setAssistant', $event)"
|
||||
/>
|
||||
<div v-else />
|
||||
<button
|
||||
v-if="messages.length"
|
||||
class="text-xs flex items-center gap-1 hover:underline"
|
||||
@click="handleReset"
|
||||
>
|
||||
<i class="i-lucide-refresh-ccw" />
|
||||
<span>{{ $t('CAPTAIN.COPILOT.RESET') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<CopilotInput class="mb-1 w-full" @send="sendMessage" />
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@ const props = defineProps({
|
||||
},
|
||||
conversationInboxType: {
|
||||
type: String,
|
||||
default: '',
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import Icon from '../icon/Icon.vue';
|
||||
|
||||
const emit = defineEmits(['useSuggestion']);
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const routePromptMap = {
|
||||
conversations: [
|
||||
{
|
||||
label: 'CAPTAIN.COPILOT.PROMPTS.SUMMARIZE.LABEL',
|
||||
prompt: 'CAPTAIN.COPILOT.PROMPTS.SUMMARIZE.CONTENT',
|
||||
},
|
||||
{
|
||||
label: 'CAPTAIN.COPILOT.PROMPTS.SUGGEST.LABEL',
|
||||
prompt: 'CAPTAIN.COPILOT.PROMPTS.SUGGEST.CONTENT',
|
||||
},
|
||||
{
|
||||
label: 'CAPTAIN.COPILOT.PROMPTS.RATE.LABEL',
|
||||
prompt: 'CAPTAIN.COPILOT.PROMPTS.RATE.CONTENT',
|
||||
},
|
||||
],
|
||||
dashboard: [
|
||||
{
|
||||
label: 'High priority conversations',
|
||||
prompt: 'Get me a summary of all high priority open conversations',
|
||||
},
|
||||
{
|
||||
label: 'List contacts',
|
||||
prompt: 'Show me the list of contacts',
|
||||
},
|
||||
{
|
||||
label: 'Summarize articles',
|
||||
prompt: 'List articles that are in draft',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const getCurrentRoute = () => {
|
||||
const path = route.path;
|
||||
if (path.includes('/conversations')) return 'conversations';
|
||||
if (path.includes('/dashboard')) return 'dashboard';
|
||||
if (path.includes('/contacts')) return 'contacts';
|
||||
if (path.includes('/articles')) return 'articles';
|
||||
return 'dashboard';
|
||||
};
|
||||
|
||||
const promptOptions = computed(() => {
|
||||
const currentRoute = getCurrentRoute();
|
||||
return routePromptMap[currentRoute] || routePromptMap.conversations;
|
||||
});
|
||||
|
||||
const handleSuggestion = opt => {
|
||||
emit('useSuggestion', t(opt.prompt));
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex-1 flex flex-col gap-6 px-2">
|
||||
<div class="flex flex-col space-y-4 py-4">
|
||||
<Icon icon="i-woot-captain" class="text-n-slate-9 text-4xl" />
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base font-medium text-n-slate-12 leading-8">
|
||||
{{ $t('CAPTAIN.COPILOT.PANEL_TITLE') }}
|
||||
</h3>
|
||||
<p class="text-sm text-n-slate-11 leading-6">
|
||||
{{ $t('CAPTAIN.COPILOT.KICK_OFF_MESSAGE') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full space-y-2">
|
||||
<span class="text-xs text-n-slate-10 block">
|
||||
{{ $t('CAPTAIN.COPILOT.TRY_THESE_PROMPTS') }}
|
||||
</span>
|
||||
<div class="space-y-1">
|
||||
<button
|
||||
v-for="prompt in promptOptions"
|
||||
:key="prompt.label"
|
||||
class="w-full px-3 py-2 rounded-md border border-n-weak bg-n-slate-2 text-n-slate-11 flex items-center justify-between hover:bg-n-slate-3 transition-colors"
|
||||
@click="handleSuggestion(prompt)"
|
||||
>
|
||||
<span>{{ t(prompt.label) }}</span>
|
||||
<Icon icon="i-lucide-chevron-right" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -11,7 +11,7 @@ defineEmits(['reset', 'close']);
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex items-center justify-between px-4 py-2 border-b border-n-weak h-12"
|
||||
class="flex items-center justify-between px-5 py-2 border-b border-n-weak h-12"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-2 flex-1">
|
||||
<span class="font-medium text-sm text-n-slate-12">
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useStore } from 'vuex';
|
||||
import { useRoute } from 'vue-router';
|
||||
import Button from 'dashboard/components-next/button/Button.vue';
|
||||
import { useMapGetter } from 'dashboard/composables/store';
|
||||
|
||||
const store = useStore();
|
||||
const route = useRoute();
|
||||
|
||||
const getUIState = useMapGetter('uiState/getUIState');
|
||||
const isSidebarOpen = computed(() => getUIState.value('isCopilotSidebarOpen'));
|
||||
|
||||
const isConversationRoute = computed(() => {
|
||||
const CONVERSATION_ROUTES = [
|
||||
'inbox_conversation',
|
||||
'conversation_through_inbox',
|
||||
'conversations_through_label',
|
||||
'team_conversations_through_label',
|
||||
'conversations_through_folders',
|
||||
'conversation_through_mentions',
|
||||
'conversation_through_unattended',
|
||||
'conversation_through_participating',
|
||||
];
|
||||
return CONVERSATION_ROUTES.includes(route.name);
|
||||
});
|
||||
|
||||
const toggleSidebar = () => {
|
||||
store.dispatch('uiState/toggle', 'isCopilotSidebarOpen');
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="fixed bottom-4 right-4 z-50">
|
||||
<div
|
||||
v-if="!isSidebarOpen && !isConversationRoute"
|
||||
class="rounded-full bg-n-solid-2 p-2 hover:bg-n-solid-3"
|
||||
>
|
||||
<Button
|
||||
icon="i-woot-captain"
|
||||
class="!rounded-full !bg-n-alpha-2 text-n-slate-12 text-xl"
|
||||
lg
|
||||
@click="toggleSidebar"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -519,7 +519,7 @@ const menuItems = computed(() => {
|
||||
</div>
|
||||
</section>
|
||||
<nav class="grid flex-grow gap-2 px-2 pb-5 overflow-y-scroll no-scrollbar">
|
||||
<ul class="flex flex-col gap-1.5 m-0 list-none">
|
||||
<ul class="flex flex-col gap-2 m-0 list-none">
|
||||
<SidebarGroup
|
||||
v-for="item in menuItems"
|
||||
:key="item.name"
|
||||
|
||||
@@ -824,7 +824,7 @@ watch(conversationFilters, (newVal, oldVal) => {
|
||||
class="flex flex-col flex-shrink-0 bg-n-solid-1 conversations-list-wrap"
|
||||
:class="[
|
||||
{ hidden: !showConversationList },
|
||||
isOnExpandedLayout ? 'basis-full' : 'w-[21rem] 2xl:w-[26rem]',
|
||||
isOnExpandedLayout ? 'basis-full' : 'w-[360px] 2xl:w-[420px]',
|
||||
]"
|
||||
>
|
||||
<slot />
|
||||
|
||||
@@ -80,14 +80,16 @@ const toggleConversationLayout = () => {
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex items-center justify-between gap-2 px-3 h-12 pt-3 pb-3"
|
||||
class="flex items-center justify-between gap-2 px-4"
|
||||
:class="{
|
||||
'border-b border-n-strong': hasAppliedFiltersOrActiveFolders,
|
||||
'pb-3 border-b border-n-strong': hasAppliedFiltersOrActiveFolders,
|
||||
'pt-3 pb-2': showV4View,
|
||||
'mb-2 pb-0': !showV4View,
|
||||
}"
|
||||
>
|
||||
<div class="flex items-center justify-center min-w-0">
|
||||
<h1
|
||||
class="text-base font-medium truncate text-n-slate-12"
|
||||
class="text-lg font-medium truncate text-n-slate-12"
|
||||
:title="pageTitle"
|
||||
>
|
||||
{{ pageTitle }}
|
||||
|
||||
@@ -1,24 +1,31 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ref, computed, onMounted, watchEffect } from 'vue';
|
||||
import { useStore } from 'dashboard/composables/store';
|
||||
import Copilot from 'dashboard/components-next/copilot/Copilot.vue';
|
||||
import ConversationAPI from 'dashboard/api/inbox/conversation';
|
||||
import { useMapGetter } from 'dashboard/composables/store';
|
||||
import { useUISettings } from 'dashboard/composables/useUISettings';
|
||||
|
||||
const props = defineProps({
|
||||
conversationId: {
|
||||
type: [Number, String],
|
||||
required: true,
|
||||
},
|
||||
conversationInboxType: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const store = useStore();
|
||||
const currentUser = useMapGetter('getCurrentUser');
|
||||
const assistants = useMapGetter('captainAssistants/getRecords');
|
||||
const inboxAssistant = useMapGetter('getCopilotAssistant');
|
||||
const { uiSettings, updateUISettings } = useUISettings();
|
||||
const currentChat = useMapGetter('getSelectedChat');
|
||||
|
||||
const getUIState = useMapGetter('uiState/getUIState');
|
||||
const isSidebarOpen = computed(() => getUIState.value('isCopilotSidebarOpen'));
|
||||
|
||||
const messages = ref([]);
|
||||
const isCaptainTyping = ref(false);
|
||||
const selectedAssistantId = ref(null);
|
||||
const copilotConnector = ref(null);
|
||||
|
||||
const activeAssistant = computed(() => {
|
||||
const preferredId = uiSettings.value.preferred_captain_assistant_id;
|
||||
@@ -52,12 +59,7 @@ const handleReset = () => {
|
||||
messages.value = [];
|
||||
};
|
||||
|
||||
const sendMessage = message => {
|
||||
// Ensure WebSocket is connected before sending
|
||||
if (!copilotConnector.value || !isSidebarOpen.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sendMessage = async message => {
|
||||
// Add user message
|
||||
messages.value.push({
|
||||
id: messages.value.length + 1,
|
||||
@@ -66,71 +68,55 @@ const sendMessage = message => {
|
||||
});
|
||||
isCaptainTyping.value = true;
|
||||
|
||||
copilotConnector.value.sendMessage({
|
||||
assistantId: activeAssistant.value.id,
|
||||
conversationId: currentChat.value?.id,
|
||||
previousHistory: messages.value
|
||||
.filter(m => m.role !== 'assistant_thinking')
|
||||
.map(m => ({
|
||||
role: m.role,
|
||||
content: m.content,
|
||||
}))
|
||||
.slice(0, -1),
|
||||
message,
|
||||
});
|
||||
try {
|
||||
const { data } = await ConversationAPI.requestCopilot(
|
||||
props.conversationId,
|
||||
{
|
||||
previous_history: messages.value
|
||||
.map(m => ({
|
||||
role: m.role,
|
||||
content: m.content,
|
||||
}))
|
||||
.slice(0, -1),
|
||||
message,
|
||||
assistant_id: selectedAssistantId.value,
|
||||
}
|
||||
);
|
||||
messages.value.push({
|
||||
id: new Date().getTime(),
|
||||
role: 'assistant',
|
||||
content: data.message,
|
||||
});
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line
|
||||
console.log(error);
|
||||
} finally {
|
||||
isCaptainTyping.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
store.dispatch('captainAssistants/get');
|
||||
});
|
||||
|
||||
// const onCopilotResponse = data => {
|
||||
// if (data.type === 'final_response') {
|
||||
// messages.value.push({
|
||||
// id: new Date().getTime(),
|
||||
// role: 'assistant',
|
||||
// content: data.response.response,
|
||||
// });
|
||||
// isCaptainTyping.value = false;
|
||||
// } else if (data.type === 'ui_event') {
|
||||
// if (data.event === 'ui:linear_ticket_create') {
|
||||
// emitter.emit('ui:linear_ticket_create');
|
||||
// setTimeout(() => {
|
||||
// emitter.emit('ui:linear_ticket_create_data', data.response);
|
||||
// }, 100);
|
||||
// }
|
||||
// } else {
|
||||
// messages.value.push({
|
||||
// id: new Date().getTime(),
|
||||
// role: 'assistant_thinking',
|
||||
// content: data.response.response,
|
||||
// reasoning: data.response.reasoning,
|
||||
// });
|
||||
// }
|
||||
// };
|
||||
|
||||
const handleClose = () => {
|
||||
store.dispatch('uiState/set', { isCopilotSidebarOpen: false });
|
||||
};
|
||||
watchEffect(() => {
|
||||
if (props.conversationId) {
|
||||
store.dispatch('getInboxCaptainAssistantById', props.conversationId);
|
||||
selectedAssistantId.value = activeAssistant.value?.id;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="isSidebarOpen"
|
||||
class="border-l border-n-weak w-[20rem] min-w-[20rem]"
|
||||
>
|
||||
<Copilot
|
||||
:messages="messages"
|
||||
:support-agent="currentUser"
|
||||
:is-captain-typing="isCaptainTyping"
|
||||
:conversation-inbox-type="conversationInboxType"
|
||||
:assistants="assistants"
|
||||
:active-assistant="activeAssistant"
|
||||
@set-assistant="setAssistant"
|
||||
@send-message="sendMessage"
|
||||
@reset="handleReset"
|
||||
@close="handleClose"
|
||||
/>
|
||||
</div>
|
||||
<div v-else class="hidden" />
|
||||
<Copilot
|
||||
:messages="messages"
|
||||
:support-agent="currentUser"
|
||||
:is-captain-typing="isCaptainTyping"
|
||||
:conversation-inbox-type="conversationInboxType"
|
||||
:assistants="assistants"
|
||||
:active-assistant="activeAssistant"
|
||||
@set-assistant="setAssistant"
|
||||
@send-message="sendMessage"
|
||||
@reset="handleReset"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -48,7 +48,7 @@ useKeyboardEvents(keyboardEvents);
|
||||
<template>
|
||||
<woot-tabs
|
||||
:index="activeTabIndex"
|
||||
class="w-full px-3 -mt-1 py-0 tab--chat-type"
|
||||
class="w-full px-4 py-0 tab--chat-type"
|
||||
@change="onTabChange"
|
||||
>
|
||||
<woot-tabs-item
|
||||
|
||||
@@ -83,7 +83,7 @@ export default {
|
||||
|
||||
<!-- eslint-disable-next-line vue/no-root-v-if -->
|
||||
<template>
|
||||
<div v-if="hasOpenedAtleastOnce" class="flex-1">
|
||||
<div v-if="hasOpenedAtleastOnce" class="dashboard-app--container">
|
||||
<div
|
||||
v-for="(configItem, index) in config"
|
||||
:key="index"
|
||||
@@ -115,7 +115,6 @@ export default {
|
||||
.dashboard-app--list iframe {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.dashboard-app_loading-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -4,9 +4,11 @@ import ConversationHeader from './ConversationHeader.vue';
|
||||
import DashboardAppFrame from '../DashboardApp/Frame.vue';
|
||||
import EmptyState from './EmptyState/EmptyState.vue';
|
||||
import MessagesView from './MessagesView.vue';
|
||||
import ConversationSidebar from './ConversationSidebar.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ConversationSidebar,
|
||||
ConversationHeader,
|
||||
DashboardAppFrame,
|
||||
EmptyState,
|
||||
@@ -23,11 +25,16 @@ export default {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isContactPanelOpen: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
isOnExpandedLayout: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
emits: ['contactPanelToggle'],
|
||||
data() {
|
||||
return { activeIndex: 0 };
|
||||
},
|
||||
@@ -50,6 +57,9 @@ export default {
|
||||
})),
|
||||
];
|
||||
},
|
||||
showContactPanel() {
|
||||
return this.isContactPanelOpen && this.currentChat.id;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
'currentChat.inbox_id': {
|
||||
@@ -76,6 +86,9 @@ export default {
|
||||
}
|
||||
this.$store.dispatch('conversationLabels/get', this.currentChat.id);
|
||||
},
|
||||
onToggleContactPanel() {
|
||||
this.$emit('contactPanelToggle');
|
||||
},
|
||||
onDashboardAppTabChange(index) {
|
||||
this.activeIndex = index;
|
||||
},
|
||||
@@ -85,7 +98,7 @@ export default {
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="conversation-details-wrap bg-n-background relative"
|
||||
class="conversation-details-wrap bg-n-background"
|
||||
:class="{
|
||||
'border-l rtl:border-l-0 rtl:border-r border-n-weak': !isOnExpandedLayout,
|
||||
}"
|
||||
@@ -94,12 +107,14 @@ export default {
|
||||
v-if="currentChat.id"
|
||||
:chat="currentChat"
|
||||
:is-inbox-view="isInboxView"
|
||||
:is-contact-panel-open="isContactPanelOpen"
|
||||
:show-back-button="isOnExpandedLayout && !isInboxView"
|
||||
@contact-panel-toggle="onToggleContactPanel"
|
||||
/>
|
||||
<woot-tabs
|
||||
v-if="dashboardApps.length && currentChat.id"
|
||||
:index="activeIndex"
|
||||
class="-mt-px border-t border-t-n-background bg-n-background dashboard-app--tabs"
|
||||
class="-mt-px bg-white dashboard-app--tabs dark:bg-slate-900"
|
||||
@change="onDashboardAppTabChange"
|
||||
>
|
||||
<woot-tabs-item
|
||||
@@ -110,17 +125,23 @@ export default {
|
||||
:show-badge="false"
|
||||
/>
|
||||
</woot-tabs>
|
||||
<div v-show="!activeIndex" class="flex-1 h-full min-h-0 m-0">
|
||||
<div v-show="!activeIndex" class="flex h-full min-h-0 m-0">
|
||||
<MessagesView
|
||||
v-if="currentChat.id"
|
||||
:inbox-id="inboxId"
|
||||
:is-inbox-view="isInboxView"
|
||||
:is-contact-panel-open="isContactPanelOpen"
|
||||
@contact-panel-toggle="onToggleContactPanel"
|
||||
/>
|
||||
<EmptyState
|
||||
v-if="!currentChat.id && !isInboxView"
|
||||
:is-on-expanded-layout="isOnExpandedLayout"
|
||||
/>
|
||||
<slot />
|
||||
<ConversationSidebar
|
||||
v-if="showContactPanel"
|
||||
:current-chat="currentChat"
|
||||
@toggle-contact-panel="onToggleContactPanel"
|
||||
/>
|
||||
</div>
|
||||
<DashboardAppFrame
|
||||
v-for="(dashboardApp, index) in dashboardApps"
|
||||
|
||||
@@ -243,7 +243,7 @@ export default {
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="relative flex items-start flex-grow-0 flex-shrink-0 w-auto max-w-full px-3 py-0 border-t-0 border-b-0 border-l-2 border-r-0 border-transparent border-solid cursor-pointer conversation hover:bg-n-alpha-1 dark:hover:bg-n-alpha-3 group"
|
||||
class="relative flex items-start flex-grow-0 flex-shrink-0 w-auto max-w-full px-4 py-0 border-t-0 border-b-0 border-l-2 border-r-0 border-transparent border-solid cursor-pointer conversation hover:bg-n-alpha-1 dark:hover:bg-n-alpha-3 group"
|
||||
:class="{
|
||||
'active animate-card-select bg-n-alpha-1 dark:bg-n-alpha-3 border-n-weak':
|
||||
isActiveChat,
|
||||
@@ -278,7 +278,7 @@ export default {
|
||||
:badge="inboxBadge"
|
||||
:username="currentContact.name"
|
||||
:status="currentContact.availability_status"
|
||||
size="32px"
|
||||
size="40px"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import { useKeyboardEvents } from 'dashboard/composables/useKeyboardEvents';
|
||||
import BackButton from '../BackButton.vue';
|
||||
import inboxMixin from 'shared/mixins/inboxMixin';
|
||||
import InboxName from '../InboxName.vue';
|
||||
@@ -12,6 +13,8 @@ import { snoozedReopenTime } from 'dashboard/helper/snoozeHelpers';
|
||||
import { FEATURE_FLAGS } from 'dashboard/featureFlags';
|
||||
import Linear from './linear/index.vue';
|
||||
|
||||
import NextButton from 'dashboard/components-next/button/Button.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
BackButton,
|
||||
@@ -20,6 +23,7 @@ export default {
|
||||
Thumbnail,
|
||||
SLACardLabel,
|
||||
Linear,
|
||||
NextButton,
|
||||
},
|
||||
mixins: [inboxMixin],
|
||||
props: {
|
||||
@@ -27,6 +31,10 @@ export default {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
isContactPanelOpen: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
showBackButton: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@@ -36,6 +44,15 @@ export default {
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
emits: ['contactPanelToggle'],
|
||||
setup(props, { emit }) {
|
||||
const keyboardEvents = {
|
||||
'Alt+KeyO': {
|
||||
action: () => emit('contactPanelToggle'),
|
||||
},
|
||||
};
|
||||
useKeyboardEvents(keyboardEvents);
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
currentChat: 'getSelectedChat',
|
||||
@@ -82,7 +99,13 @@ export default {
|
||||
}
|
||||
return this.$t('CONVERSATION.HEADER.SNOOZED_UNTIL_NEXT_REPLY');
|
||||
},
|
||||
|
||||
contactPanelToggleText() {
|
||||
return `${
|
||||
this.isContactPanelOpen
|
||||
? this.$t('CONVERSATION.HEADER.CLOSE')
|
||||
: this.$t('CONVERSATION.HEADER.OPEN')
|
||||
} ${this.$t('CONVERSATION.HEADER.DETAILS')}`;
|
||||
},
|
||||
inbox() {
|
||||
const { inbox_id: inboxId } = this.chat;
|
||||
return this.$store.getters['inboxes/getInbox'](inboxId);
|
||||
@@ -110,7 +133,7 @@ export default {
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-col items-center justify-between px-3 border-b bg-n-background border-n-weak md:flex-row h-12"
|
||||
class="flex flex-col items-center justify-between px-4 py-2 border-b bg-n-background border-n-weak md:flex-row"
|
||||
>
|
||||
<div
|
||||
class="flex flex-col items-center justify-center flex-1 w-full min-w-0"
|
||||
@@ -127,18 +150,20 @@ export default {
|
||||
:badge="inboxBadge"
|
||||
:username="currentContact.name"
|
||||
:status="currentContact.availability_status"
|
||||
size="32px"
|
||||
/>
|
||||
<div
|
||||
class="flex flex-col items-start min-w-0 ml-2 overflow-hidden rtl:ml-0 rtl:mr-2 w-fit"
|
||||
>
|
||||
<div class="flex items-center max-w-full gap-1 p-0 m-0 w-fit">
|
||||
<span
|
||||
class="text-sm font-medium truncate leading-tight text-n-slate-12"
|
||||
>
|
||||
{{ currentContact.name }}
|
||||
</span>
|
||||
|
||||
<div
|
||||
class="flex flex-row items-center max-w-full gap-1 p-0 m-0 w-fit"
|
||||
>
|
||||
<NextButton link slate @click.prevent="$emit('contactPanelToggle')">
|
||||
<span
|
||||
class="text-base font-medium truncate leading-tight text-n-slate-12"
|
||||
>
|
||||
{{ currentContact.name }}
|
||||
</span>
|
||||
</NextButton>
|
||||
<fluent-icon
|
||||
v-if="!isHMACVerified"
|
||||
v-tooltip="$t('CONVERSATION.UNVERIFIED_SESSION')"
|
||||
@@ -155,11 +180,19 @@ export default {
|
||||
<span v-if="isSnoozed" class="font-medium text-n-amber-10">
|
||||
{{ snoozedDisplayText }}
|
||||
</span>
|
||||
<NextButton
|
||||
link
|
||||
xs
|
||||
blue
|
||||
:label="contactPanelToggleText"
|
||||
@click="$emit('contactPanelToggle')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex flex-row items-center justify-end flex-grow gap-2 mt-3 header-actions-wrap lg:mt-0"
|
||||
:class="{ 'justify-end': isContactPanelOpen }"
|
||||
>
|
||||
<SLACardLabel v-if="hasSlaPolicyId" :chat="chat" show-extended-info />
|
||||
<Linear
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import CopilotContainer from '../../copilot/CopilotContainer.vue';
|
||||
import ContactPanel from 'dashboard/routes/dashboard/conversation/ContactPanel.vue';
|
||||
import Button from 'dashboard/components-next/button/Button.vue';
|
||||
import { computed } from 'vue';
|
||||
import { useMapGetter, useStore } from 'dashboard/composables/store';
|
||||
import TabBar from 'dashboard/components-next/tabbar/TabBar.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMapGetter } from 'dashboard/composables/store';
|
||||
import { FEATURE_FLAGS } from '../../../featureFlags';
|
||||
|
||||
const props = defineProps({
|
||||
currentChat: {
|
||||
@@ -11,48 +14,69 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
const getUIState = useMapGetter('uiState/getUIState');
|
||||
const isCopilotSidebarOpen = computed(() =>
|
||||
getUIState.value('isCopilotSidebarOpen')
|
||||
);
|
||||
const isConversationSidebarOpen = computed(() =>
|
||||
getUIState.value('isConversationSidebarOpen')
|
||||
);
|
||||
const emit = defineEmits(['toggleContactPanel']);
|
||||
|
||||
const showConversationSidebar = computed(
|
||||
() =>
|
||||
props.currentChat.id &&
|
||||
!isCopilotSidebarOpen.value &&
|
||||
isConversationSidebarOpen.value
|
||||
);
|
||||
const { t } = useI18n();
|
||||
|
||||
const store = useStore();
|
||||
const closeConversationPanel = () => {
|
||||
store.dispatch('uiState/set', { isConversationSidebarOpen: false });
|
||||
const channelType = computed(() => props.currentChat?.meta?.channel || '');
|
||||
|
||||
const CONTACT_TABS_OPTIONS = [
|
||||
{ key: 'CONTACT', value: 'contact' },
|
||||
{ key: 'COPILOT', value: 'copilot' },
|
||||
];
|
||||
|
||||
const tabs = computed(() => {
|
||||
return CONTACT_TABS_OPTIONS.map(tab => ({
|
||||
label: t(`CONVERSATION.SIDEBAR.${tab.key}`),
|
||||
value: tab.value,
|
||||
}));
|
||||
});
|
||||
const activeTab = ref(0);
|
||||
const toggleContactPanel = () => {
|
||||
emit('toggleContactPanel');
|
||||
};
|
||||
|
||||
const handleTabChange = selectedTab => {
|
||||
activeTab.value = tabs.value.findIndex(
|
||||
tabItem => tabItem.value === selectedTab.value
|
||||
);
|
||||
};
|
||||
const currentAccountId = useMapGetter('getCurrentAccountId');
|
||||
const isFeatureEnabledonAccount = useMapGetter(
|
||||
'accounts/isFeatureEnabledonAccount'
|
||||
);
|
||||
|
||||
const showCopilotTab = computed(() =>
|
||||
isFeatureEnabledonAccount.value(currentAccountId.value, FEATURE_FLAGS.CAPTAIN)
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="showConversationSidebar"
|
||||
class="ltr:border-l rtl:border-r border-n-weak h-full overflow-hidden z-10 w-[20rem] min-w-[20rem] flex flex-col"
|
||||
class="ltr:border-l rtl:border-r border-n-weak h-full overflow-hidden z-10 w-80 min-w-80 2xl:min-w-96 2xl:w-96 flex flex-col bg-n-background"
|
||||
>
|
||||
<div class="flex flex-1 flex-col overflow-auto">
|
||||
<div
|
||||
class="flex items-center justify-between gap-2 px-4 py-2 border-b border-n-weak h-12"
|
||||
>
|
||||
<span class="font-medium text-sm text-n-slate-12">
|
||||
{{ $t('CONVERSATION.SIDEBAR.ACTIONS') }}
|
||||
</span>
|
||||
<div class="flex items-center">
|
||||
<Button icon="i-lucide-x" ghost sm @click="closeConversationPanel" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="showCopilotTab" class="p-2">
|
||||
<TabBar
|
||||
:tabs="tabs"
|
||||
:initial-active-tab="activeTab"
|
||||
class="w-full [&>button]:w-full"
|
||||
@tab-changed="handleTabChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-1 overflow-auto">
|
||||
<ContactPanel
|
||||
:conversation-id="props.currentChat.id"
|
||||
:inbox-id="props.currentChat.inbox_id"
|
||||
v-if="!activeTab"
|
||||
:conversation-id="currentChat.id"
|
||||
:inbox-id="currentChat.inbox_id"
|
||||
:on-toggle="toggleContactPanel"
|
||||
/>
|
||||
<CopilotContainer
|
||||
v-else-if="activeTab === 1 && showCopilotTab"
|
||||
:key="currentChat.id"
|
||||
:conversation-inbox-type="channelType"
|
||||
:conversation-id="currentChat.id"
|
||||
class="flex-1"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="hidden" />
|
||||
</template>
|
||||
|
||||
@@ -38,6 +38,8 @@ import { LOCAL_STORAGE_KEYS } from 'dashboard/constants/localStorage';
|
||||
import { FEATURE_FLAGS } from '../../../featureFlags';
|
||||
import { INBOX_TYPES } from 'dashboard/helper/inbox';
|
||||
|
||||
import NextButton from 'dashboard/components-next/button/Button.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Message,
|
||||
@@ -45,8 +47,20 @@ export default {
|
||||
ReplyBox,
|
||||
Banner,
|
||||
ConversationLabelSuggestion,
|
||||
NextButton,
|
||||
},
|
||||
mixins: [inboxMixin],
|
||||
props: {
|
||||
isContactPanelOpen: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isInboxView: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
emits: ['contactPanelToggle'],
|
||||
setup() {
|
||||
const isPopOutReplyBox = ref(false);
|
||||
const { isEnterprise } = useConfig();
|
||||
@@ -185,6 +199,12 @@ export default {
|
||||
isATweet() {
|
||||
return this.conversationType === 'tweet';
|
||||
},
|
||||
isRightOrLeftIcon() {
|
||||
if (this.isContactPanelOpen) {
|
||||
return 'arrow-chevron-right';
|
||||
}
|
||||
return 'arrow-chevron-left';
|
||||
},
|
||||
getLastSeenAt() {
|
||||
const { contact_last_seen_at: contactLastSeenAt } = this.currentChat;
|
||||
return contactLastSeenAt;
|
||||
@@ -420,6 +440,9 @@ export default {
|
||||
relevantMessages
|
||||
);
|
||||
},
|
||||
onToggleContactPanel() {
|
||||
this.$emit('contactPanelToggle');
|
||||
},
|
||||
setScrollParams() {
|
||||
this.heightBeforeLoad = this.conversationPanel.scrollHeight;
|
||||
this.scrollTopBeforeLoad = this.conversationPanel.scrollTop;
|
||||
@@ -503,7 +526,19 @@ export default {
|
||||
class="mx-2 mt-2 overflow-hidden rounded-lg"
|
||||
:banner-message="$t('CONVERSATION.OLD_INSTAGRAM_INBOX_REPLY_BANNER')"
|
||||
/>
|
||||
|
||||
<div class="flex justify-end">
|
||||
<NextButton
|
||||
faded
|
||||
xs
|
||||
slate
|
||||
class="!rounded-r-none rtl:rotate-180 !rounded-2xl !fixed z-10"
|
||||
:icon="
|
||||
isContactPanelOpen ? 'i-ph-caret-right-fill' : 'i-ph-caret-left-fill'
|
||||
"
|
||||
:class="isInboxView ? 'top-52 md:top-40' : 'top-32'"
|
||||
@click="onToggleContactPanel"
|
||||
/>
|
||||
</div>
|
||||
<NextMessageList
|
||||
v-if="showNextBubbles"
|
||||
class="conversation-panel"
|
||||
|
||||
@@ -10,7 +10,6 @@ import { parseLinearAPIErrorResponse } from 'dashboard/store/utils/api';
|
||||
import SearchableDropdown from './SearchableDropdown.vue';
|
||||
import { LINEAR_EVENTS } from 'dashboard/helper/AnalyticsHelper/events';
|
||||
import Button from 'dashboard/components-next/button/Button.vue';
|
||||
import { useEmitter } from 'dashboard/composables/emitter';
|
||||
|
||||
const props = defineProps({
|
||||
conversationId: {
|
||||
@@ -205,12 +204,6 @@ const createIssue = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
useEmitter('ui:linear_ticket_create_data', data => {
|
||||
formState.title = data.title;
|
||||
formState.description = data.description;
|
||||
formState.priority = data.priority;
|
||||
});
|
||||
|
||||
onMounted(getTeams);
|
||||
</script>
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import { useTrack } from 'dashboard/composables';
|
||||
import { LINEAR_EVENTS } from 'dashboard/helper/AnalyticsHelper/events';
|
||||
import { parseLinearAPIErrorResponse } from 'dashboard/store/utils/api';
|
||||
import Button from 'dashboard/components-next/button/Button.vue';
|
||||
import { useEmitter } from 'dashboard/composables/emitter';
|
||||
|
||||
const props = defineProps({
|
||||
conversationId: {
|
||||
@@ -95,10 +94,6 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
useEmitter('ui:linear_ticket_create', () => {
|
||||
shouldShowPopup.value = true;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
loadLinkedIssue();
|
||||
});
|
||||
|
||||
@@ -234,7 +234,8 @@
|
||||
}
|
||||
},
|
||||
"SIDEBAR": {
|
||||
"ACTIONS": "Actions"
|
||||
"CONTACT": "Contact",
|
||||
"COPILOT": "Copilot"
|
||||
}
|
||||
},
|
||||
"EMAIL_TRANSCRIPT": {
|
||||
@@ -379,6 +380,9 @@
|
||||
"TWO": "{user} and {secondUser} are typing",
|
||||
"MULTIPLE": "{user} and {count} others are typing"
|
||||
},
|
||||
"COPILOT": {
|
||||
"TRY_THESE_PROMPTS": "Try these prompts"
|
||||
},
|
||||
"GALLERY_VIEW": {
|
||||
"ERROR_DOWNLOADING": "Unable to download attachment. Please try again"
|
||||
}
|
||||
|
||||
@@ -328,17 +328,14 @@
|
||||
"HEADER_KNOW_MORE": "Know more",
|
||||
"COPILOT": {
|
||||
"TITLE": "Copilot",
|
||||
"TRY_THESE_PROMPTS": "Try these prompts",
|
||||
"PANEL_TITLE": "Get started with Copilot",
|
||||
"KICK_OFF_MESSAGE": "Need a quick summary, want to check past conversations, or draft a better reply? Copilot’s here to speed things up.",
|
||||
"SEND_MESSAGE": "Send message...",
|
||||
"EMPTY_MESSAGE": "There was an error generating the response. Please try again.",
|
||||
"LOADER": "Captain is thinking",
|
||||
"YOU": "You",
|
||||
"USE": "Use this",
|
||||
"RESET": "Reset",
|
||||
"SELECT_ASSISTANT": "Select Assistant",
|
||||
"SHOW_STEPS": "Show steps",
|
||||
"SELECT_ASSISTANT": "Select Assistant",
|
||||
"PROMPTS": {
|
||||
"SUMMARIZE": {
|
||||
"LABEL": "Summarize this conversation",
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
<script setup>
|
||||
import {
|
||||
defineAsyncComponent,
|
||||
ref,
|
||||
computed,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
nextTick,
|
||||
watch,
|
||||
} from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useMapGetter } from 'dashboard/composables/store';
|
||||
<script>
|
||||
import { defineAsyncComponent, ref } from 'vue';
|
||||
import { mapGetters } from 'vuex';
|
||||
|
||||
import NextSidebar from 'next/sidebar/Sidebar.vue';
|
||||
import WootKeyShortcutModal from 'dashboard/components/widgets/modal/WootKeyShortcutModal.vue';
|
||||
@@ -18,8 +9,6 @@ import AccountSelector from 'dashboard/components/layout/sidebarComponents/Accou
|
||||
import AddLabelModal from 'dashboard/routes/dashboard/settings/labels/AddLabel.vue';
|
||||
import NotificationPanel from 'dashboard/routes/dashboard/notifications/components/NotificationPanel.vue';
|
||||
import UpgradePage from 'dashboard/routes/dashboard/upgrade/UpgradePage.vue';
|
||||
import CopilotContainer from 'dashboard/components/copilot/CopilotContainer.vue';
|
||||
import CopilotLauncher from 'dashboard/components-next/copilot/CopilotLauncher.vue';
|
||||
|
||||
import { useUISettings } from 'dashboard/composables/useUISettings';
|
||||
import { useAccount } from 'dashboard/composables/useAccount';
|
||||
@@ -27,160 +16,178 @@ import { useAccount } from 'dashboard/composables/useAccount';
|
||||
import wootConstants from 'dashboard/constants/globals';
|
||||
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
||||
import { FEATURE_FLAGS } from 'dashboard/featureFlags';
|
||||
import { emitter } from 'shared/helpers/mitt';
|
||||
|
||||
const CommandBar = defineAsyncComponent(
|
||||
() => import('./commands/commandbar.vue')
|
||||
);
|
||||
|
||||
const Sidebar = defineAsyncComponent(
|
||||
() => import('../../components/layout/Sidebar.vue')
|
||||
);
|
||||
import { emitter } from 'shared/helpers/mitt';
|
||||
|
||||
const route = useRoute();
|
||||
export default {
|
||||
components: {
|
||||
NextSidebar,
|
||||
Sidebar,
|
||||
CommandBar,
|
||||
WootKeyShortcutModal,
|
||||
AddAccountModal,
|
||||
AccountSelector,
|
||||
AddLabelModal,
|
||||
NotificationPanel,
|
||||
UpgradePage,
|
||||
},
|
||||
setup() {
|
||||
const upgradePageRef = ref(null);
|
||||
const { uiSettings, updateUISettings } = useUISettings();
|
||||
const { accountId } = useAccount();
|
||||
|
||||
const upgradePageRef = ref(null);
|
||||
const { uiSettings, updateUISettings } = useUISettings();
|
||||
const { currentAccount } = useAccount();
|
||||
return {
|
||||
uiSettings,
|
||||
updateUISettings,
|
||||
accountId,
|
||||
upgradePageRef,
|
||||
};
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showAccountModal: false,
|
||||
showCreateAccountModal: false,
|
||||
showAddLabelModal: false,
|
||||
showShortcutModal: false,
|
||||
isNotificationPanel: false,
|
||||
displayLayoutType: '',
|
||||
hasBanner: '',
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
|
||||
}),
|
||||
currentRoute() {
|
||||
return ' ';
|
||||
},
|
||||
showUpgradePage() {
|
||||
return this.upgradePageRef?.shouldShowUpgradePage;
|
||||
},
|
||||
bypassUpgradePage() {
|
||||
return [
|
||||
'billing_settings_index',
|
||||
'settings_inbox_list',
|
||||
'agent_list',
|
||||
].includes(this.$route.name);
|
||||
},
|
||||
isSidebarOpen() {
|
||||
const { show_secondary_sidebar: showSecondarySidebar } = this.uiSettings;
|
||||
return showSecondarySidebar;
|
||||
},
|
||||
previouslyUsedDisplayType() {
|
||||
const {
|
||||
previously_used_conversation_display_type: conversationDisplayType,
|
||||
} = this.uiSettings;
|
||||
return conversationDisplayType;
|
||||
},
|
||||
previouslyUsedSidebarView() {
|
||||
const { previously_used_sidebar_view: showSecondarySidebar } =
|
||||
this.uiSettings;
|
||||
return showSecondarySidebar;
|
||||
},
|
||||
showNextSidebar() {
|
||||
return this.isFeatureEnabledonAccount(
|
||||
this.accountId,
|
||||
FEATURE_FLAGS.CHATWOOT_V4
|
||||
);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
displayLayoutType() {
|
||||
const { LAYOUT_TYPES } = wootConstants;
|
||||
this.updateUISettings({
|
||||
conversation_display_type:
|
||||
this.displayLayoutType === LAYOUT_TYPES.EXPANDED
|
||||
? LAYOUT_TYPES.EXPANDED
|
||||
: this.previouslyUsedDisplayType,
|
||||
show_secondary_sidebar:
|
||||
this.displayLayoutType === LAYOUT_TYPES.EXPANDED
|
||||
? false
|
||||
: this.previouslyUsedSidebarView,
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.handleResize();
|
||||
this.$nextTick(this.checkBanner);
|
||||
window.addEventListener('resize', this.handleResize);
|
||||
window.addEventListener('resize', this.checkBanner);
|
||||
emitter.on(BUS_EVENTS.TOGGLE_SIDEMENU, this.toggleSidebar);
|
||||
},
|
||||
unmounted() {
|
||||
window.removeEventListener('resize', this.handleResize);
|
||||
window.removeEventListener('resize', this.checkBanner);
|
||||
emitter.off(BUS_EVENTS.TOGGLE_SIDEMENU, this.toggleSidebar);
|
||||
},
|
||||
|
||||
const showAccountModal = ref(false);
|
||||
const showCreateAccountModal = ref(false);
|
||||
const showAddLabelModal = ref(false);
|
||||
const showShortcutModal = ref(false);
|
||||
const isNotificationPanel = ref(false);
|
||||
const displayLayoutType = ref('');
|
||||
const hasBanner = ref('');
|
||||
methods: {
|
||||
checkBanner() {
|
||||
this.hasBanner =
|
||||
document.getElementsByClassName('woot-banner').length > 0;
|
||||
},
|
||||
handleResize() {
|
||||
const { SMALL_SCREEN_BREAKPOINT, LAYOUT_TYPES } = wootConstants;
|
||||
let throttled = false;
|
||||
const delay = 150;
|
||||
|
||||
const isFeatureEnabledonAccount = useMapGetter(
|
||||
'accounts/isFeatureEnabledonAccount'
|
||||
);
|
||||
if (throttled) {
|
||||
return;
|
||||
}
|
||||
throttled = true;
|
||||
|
||||
const currentRoute = computed(() => ' ');
|
||||
|
||||
const showUpgradePage = computed(
|
||||
() => upgradePageRef.value?.shouldShowUpgradePage
|
||||
);
|
||||
|
||||
const bypassUpgradePage = computed(() =>
|
||||
['billing_settings_index', 'settings_inbox_list', 'agent_list'].includes(
|
||||
route.name
|
||||
)
|
||||
);
|
||||
|
||||
const isSidebarOpen = computed(() => {
|
||||
const { show_secondary_sidebar: showSecondarySidebar } = uiSettings;
|
||||
return showSecondarySidebar;
|
||||
});
|
||||
|
||||
const previouslyUsedDisplayType = computed(() => {
|
||||
const { previously_used_conversation_display_type: conversationDisplayType } =
|
||||
uiSettings;
|
||||
return conversationDisplayType;
|
||||
});
|
||||
|
||||
const previouslyUsedSidebarView = computed(() => {
|
||||
const { previously_used_sidebar_view: showSecondarySidebar } = uiSettings;
|
||||
return showSecondarySidebar;
|
||||
});
|
||||
|
||||
const showNextSidebar = computed(() =>
|
||||
isFeatureEnabledonAccount.value(
|
||||
currentAccount.value?.id,
|
||||
FEATURE_FLAGS.CHATWOOT_V4
|
||||
)
|
||||
);
|
||||
|
||||
const checkBanner = () => {
|
||||
hasBanner.value = document.getElementsByClassName('woot-banner').length > 0;
|
||||
setTimeout(() => {
|
||||
throttled = false;
|
||||
if (window.innerWidth <= SMALL_SCREEN_BREAKPOINT) {
|
||||
this.displayLayoutType = LAYOUT_TYPES.EXPANDED;
|
||||
} else {
|
||||
this.displayLayoutType = LAYOUT_TYPES.CONDENSED;
|
||||
}
|
||||
}, delay);
|
||||
},
|
||||
toggleSidebar() {
|
||||
this.updateUISettings({
|
||||
show_secondary_sidebar: !this.isSidebarOpen,
|
||||
previously_used_sidebar_view: !this.isSidebarOpen,
|
||||
});
|
||||
},
|
||||
openCreateAccountModal() {
|
||||
this.showAccountModal = false;
|
||||
this.showCreateAccountModal = true;
|
||||
},
|
||||
closeCreateAccountModal() {
|
||||
this.showCreateAccountModal = false;
|
||||
},
|
||||
toggleAccountModal() {
|
||||
this.showAccountModal = !this.showAccountModal;
|
||||
},
|
||||
toggleKeyShortcutModal() {
|
||||
this.showShortcutModal = true;
|
||||
},
|
||||
closeKeyShortcutModal() {
|
||||
this.showShortcutModal = false;
|
||||
},
|
||||
showAddLabelPopup() {
|
||||
this.showAddLabelModal = true;
|
||||
},
|
||||
hideAddLabelPopup() {
|
||||
this.showAddLabelModal = false;
|
||||
},
|
||||
openNotificationPanel() {
|
||||
this.isNotificationPanel = true;
|
||||
},
|
||||
closeNotificationPanel() {
|
||||
this.isNotificationPanel = false;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const handleResize = () => {
|
||||
const { SMALL_SCREEN_BREAKPOINT, LAYOUT_TYPES } = wootConstants;
|
||||
let throttled = false;
|
||||
const delay = 150;
|
||||
|
||||
if (throttled) return;
|
||||
throttled = true;
|
||||
|
||||
setTimeout(() => {
|
||||
throttled = false;
|
||||
displayLayoutType.value =
|
||||
window.innerWidth <= SMALL_SCREEN_BREAKPOINT
|
||||
? LAYOUT_TYPES.EXPANDED
|
||||
: LAYOUT_TYPES.CONDENSED;
|
||||
}, delay);
|
||||
};
|
||||
|
||||
const toggleSidebar = () => {
|
||||
updateUISettings({
|
||||
show_secondary_sidebar: !isSidebarOpen.value,
|
||||
previously_used_sidebar_view: !isSidebarOpen.value,
|
||||
});
|
||||
};
|
||||
|
||||
const openCreateAccountModal = () => {
|
||||
showAccountModal.value = false;
|
||||
showCreateAccountModal.value = true;
|
||||
};
|
||||
|
||||
const closeCreateAccountModal = () => {
|
||||
showCreateAccountModal.value = false;
|
||||
};
|
||||
|
||||
const toggleAccountModal = () => {
|
||||
showAccountModal.value = !showAccountModal.value;
|
||||
};
|
||||
|
||||
const toggleKeyShortcutModal = () => {
|
||||
showShortcutModal.value = true;
|
||||
};
|
||||
|
||||
const closeKeyShortcutModal = () => {
|
||||
showShortcutModal.value = false;
|
||||
};
|
||||
|
||||
const showAddLabelPopup = () => {
|
||||
showAddLabelModal.value = true;
|
||||
};
|
||||
|
||||
const hideAddLabelPopup = () => {
|
||||
showAddLabelModal.value = false;
|
||||
};
|
||||
|
||||
const openNotificationPanel = () => {
|
||||
isNotificationPanel.value = true;
|
||||
};
|
||||
|
||||
const closeNotificationPanel = () => {
|
||||
isNotificationPanel.value = false;
|
||||
};
|
||||
|
||||
watch(displayLayoutType, () => {
|
||||
const { LAYOUT_TYPES } = wootConstants;
|
||||
updateUISettings({
|
||||
conversation_display_type:
|
||||
displayLayoutType.value === LAYOUT_TYPES.EXPANDED
|
||||
? LAYOUT_TYPES.EXPANDED
|
||||
: previouslyUsedDisplayType.value,
|
||||
show_secondary_sidebar:
|
||||
displayLayoutType.value === LAYOUT_TYPES.EXPANDED
|
||||
? false
|
||||
: previouslyUsedSidebarView.value,
|
||||
});
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
handleResize();
|
||||
nextTick(checkBanner);
|
||||
window.addEventListener('resize', handleResize);
|
||||
window.addEventListener('resize', checkBanner);
|
||||
emitter.on(BUS_EVENTS.TOGGLE_SIDEMENU, toggleSidebar);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', handleResize);
|
||||
window.removeEventListener('resize', checkBanner);
|
||||
emitter.off(BUS_EVENTS.TOGGLE_SIDEMENU, toggleSidebar);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -211,8 +218,6 @@ onUnmounted(() => {
|
||||
/>
|
||||
<template v-if="!showUpgradePage">
|
||||
<router-view />
|
||||
<CopilotLauncher />
|
||||
<CopilotContainer />
|
||||
<CommandBar />
|
||||
<NotificationPanel
|
||||
v-if="isNotificationPanel"
|
||||
|
||||
@@ -29,6 +29,10 @@ const props = defineProps({
|
||||
type: Number,
|
||||
default: undefined,
|
||||
},
|
||||
onToggle: {
|
||||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
@@ -85,6 +89,8 @@ watch(conversationId, (newConversationId, prevConversationId) => {
|
||||
|
||||
watch(contactId, getContactDetails);
|
||||
|
||||
const onPanelToggle = props.onToggle;
|
||||
|
||||
const onDragEnd = () => {
|
||||
dragging.value = false;
|
||||
updateUISettings({
|
||||
@@ -101,7 +107,11 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<div class="w-full">
|
||||
<ContactInfo :contact="contact" :channel-type="channelType" />
|
||||
<ContactInfo
|
||||
:contact="contact"
|
||||
:channel-type="channelType"
|
||||
@toggle-panel="onPanelToggle"
|
||||
/>
|
||||
<div class="list-group pb-8">
|
||||
<Draggable
|
||||
:list="conversationSidebarItems"
|
||||
|
||||
@@ -10,17 +10,13 @@ import { BUS_EVENTS } from 'shared/constants/busEvents';
|
||||
import CmdBarConversationSnooze from 'dashboard/routes/dashboard/commands/CmdBarConversationSnooze.vue';
|
||||
import { emitter } from 'shared/helpers/mitt';
|
||||
import { FEATURE_FLAGS } from 'dashboard/featureFlags';
|
||||
import ConversationSidebar from 'dashboard/components/widgets/conversation/ConversationSidebar.vue';
|
||||
import PanelButtons from './PanelButtons.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ChatList,
|
||||
ConversationBox,
|
||||
ConversationSidebar,
|
||||
PopOverSearch,
|
||||
CmdBarConversationSnooze,
|
||||
PanelButtons,
|
||||
},
|
||||
beforeRouteLeave(to, from, next) {
|
||||
// Clear selected state if navigating away from a conversation to a route without a conversationId to prevent stale data issues
|
||||
@@ -91,6 +87,14 @@ export default {
|
||||
this.uiSettings;
|
||||
return conversationDisplayType !== CONDENSED;
|
||||
},
|
||||
isContactPanelOpen() {
|
||||
if (this.currentChat.id) {
|
||||
const { is_contact_sidebar_open: isContactSidebarOpen } =
|
||||
this.uiSettings;
|
||||
return isContactSidebarOpen;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
showPopOverSearch() {
|
||||
return !this.isFeatureEnabledonAccount(
|
||||
this.accountId,
|
||||
@@ -185,7 +189,11 @@ export default {
|
||||
this.$store.dispatch('clearSelectedState');
|
||||
}
|
||||
},
|
||||
|
||||
onToggleContactPanel() {
|
||||
this.updateUISettings({
|
||||
is_contact_sidebar_open: !this.isContactPanelOpen,
|
||||
});
|
||||
},
|
||||
onSearch() {
|
||||
this.showSearchModal = true;
|
||||
},
|
||||
@@ -217,11 +225,10 @@ export default {
|
||||
<ConversationBox
|
||||
v-if="showMessageView"
|
||||
:inbox-id="inboxId"
|
||||
:is-contact-panel-open="isContactPanelOpen"
|
||||
:is-on-expanded-layout="isOnExpandedLayout"
|
||||
>
|
||||
<PanelButtons v-if="currentChat.id" />
|
||||
</ConversationBox>
|
||||
<ConversationSidebar :current-chat="currentChat" />
|
||||
@contact-panel-toggle="onToggleContactPanel"
|
||||
/>
|
||||
<CmdBarConversationSnooze />
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
<script setup>
|
||||
import Button from 'dashboard/components-next/button/Button.vue';
|
||||
import { useStore } from 'vuex';
|
||||
|
||||
const store = useStore();
|
||||
|
||||
const handleConversationSidebarToggle = () => {
|
||||
store.dispatch('uiState/set', {
|
||||
isConversationSidebarOpen: true,
|
||||
isCopilotSidebarOpen: false,
|
||||
});
|
||||
};
|
||||
|
||||
const handleCopilotSidebarToggle = () => {
|
||||
store.dispatch('uiState/set', {
|
||||
isCopilotSidebarOpen: true,
|
||||
isConversationSidebarOpen: false,
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-col justify-center items-center absolute top-24 right-1 bg-n-alpha-2 border border-n-weak rounded-lg bg-n-background gap-2 py-0.5 px-0.5"
|
||||
>
|
||||
<Button
|
||||
ghost
|
||||
slate
|
||||
sm
|
||||
class="!text-sm"
|
||||
icon="i-ph-user-bold"
|
||||
@click="handleConversationSidebarToggle"
|
||||
/>
|
||||
<Button
|
||||
ghost
|
||||
class="!text-sm !text-n-iris-11"
|
||||
sm
|
||||
icon="i-woot-captain"
|
||||
@click="handleCopilotSidebarToggle"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -51,7 +51,6 @@ import captainDocuments from './captain/document';
|
||||
import captainResponses from './captain/response';
|
||||
import captainInboxes from './captain/inboxes';
|
||||
import captainBulkActions from './captain/bulkActions';
|
||||
import uiState from './modules/uiState';
|
||||
const plugins = [];
|
||||
|
||||
export default createStore({
|
||||
@@ -107,7 +106,6 @@ export default createStore({
|
||||
captainResponses,
|
||||
captainInboxes,
|
||||
captainBulkActions,
|
||||
uiState,
|
||||
},
|
||||
plugins,
|
||||
});
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
const initialState = {
|
||||
isCopilotSidebarOpen: false,
|
||||
isConversationSidebarOpen: true,
|
||||
};
|
||||
|
||||
const types = {
|
||||
SET_UI_STATE: 'SET_UI_STATE',
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
[types.SET_UI_STATE](state, { key, value }) {
|
||||
state[key] = value;
|
||||
},
|
||||
};
|
||||
|
||||
const getters = {
|
||||
getUIState: state => key => state[key],
|
||||
};
|
||||
|
||||
const actions = {
|
||||
toggle({ commit, state }, key) {
|
||||
commit(types.SET_UI_STATE, { key, value: !state[key] });
|
||||
},
|
||||
set({ commit }, payload) {
|
||||
Object.entries(payload).forEach(([key, value]) => {
|
||||
commit(types.SET_UI_STATE, { key, value });
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: initialState,
|
||||
getters,
|
||||
mutations,
|
||||
actions,
|
||||
};
|
||||
@@ -31,11 +31,7 @@ class Crm::Leadsquared::LeadFinderService
|
||||
def find_by_phone_number(contact)
|
||||
return if contact.phone_number.blank?
|
||||
|
||||
lead_data = Crm::Leadsquared::Mappers::ContactMapper.map(contact)
|
||||
|
||||
return if lead_data.blank? || lead_data['Mobile'].nil?
|
||||
|
||||
search_by_field(lead_data['Mobile'])
|
||||
search_by_field(contact.phone_number)
|
||||
end
|
||||
|
||||
def search_by_field(value)
|
||||
|
||||
@@ -20,29 +20,11 @@ class Crm::Leadsquared::Mappers::ContactMapper
|
||||
'FirstName' => contact.name.presence,
|
||||
'LastName' => contact.last_name.presence,
|
||||
'EmailAddress' => contact.email.presence,
|
||||
'Mobile' => formatted_phone_number,
|
||||
'Mobile' => contact.phone_number.presence,
|
||||
'Source' => brand_name
|
||||
}.compact
|
||||
end
|
||||
|
||||
def formatted_phone_number
|
||||
# it seems like leadsquared needs a different phone number format
|
||||
# it's not documented anywhere, so don't bother trying to look up online
|
||||
# After some trial and error, I figured out the format, its +<country_code>-<national_number>
|
||||
return nil if contact.phone_number.blank?
|
||||
|
||||
parsed = TelephoneNumber.parse(contact.phone_number)
|
||||
return contact.phone_number unless parsed.valid?
|
||||
|
||||
country_code = parsed.country.country_code
|
||||
e164 = parsed.e164_number
|
||||
e164 = e164.sub(/^\+/, '')
|
||||
|
||||
national_number = e164.sub(/^#{Regexp.escape(country_code)}/, '')
|
||||
|
||||
"+#{country_code}-#{national_number}"
|
||||
end
|
||||
|
||||
def brand_name
|
||||
::GlobalConfig.get('BRAND_NAME')['BRAND_NAME'] || 'Chatwoot'
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ class MessageTemplates::HookExecutionService
|
||||
return false unless message.incoming?
|
||||
# prevents sending out-of-office message if an agent has sent a message in last 5 minutes
|
||||
# ensures better UX by not interrupting active conversations at the end of business hours
|
||||
return false if conversation.messages.outgoing.where(private: false).exists?(['created_at > ?', 5.minutes.ago])
|
||||
return false if conversation.messages.outgoing.exists?(['created_at > ?', 5.minutes.ago])
|
||||
|
||||
inbox.out_of_office? && conversation.messages.today.template.empty? && inbox.out_of_office_message.present?
|
||||
end
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
json.access_token @resource.access_token.token
|
||||
json.expiry nil
|
||||
json.user do
|
||||
json.id @resource.id
|
||||
json.name @resource.name
|
||||
json.display_name @resource.display_name
|
||||
json.email @resource.email
|
||||
json.pubsub_token @resource.pubsub_token
|
||||
end
|
||||
@@ -15,6 +15,7 @@ Rails.application.config.middleware.insert_before 0, Rack::Cors do
|
||||
resource '*', headers: :any, methods: :any, expose: %w[access-token client uid expiry]
|
||||
end
|
||||
|
||||
# This is temporary fix for the issue the loading APIs from the frontend, we will remove this once we have a proper solution
|
||||
if ActiveModel::Type::Boolean.new.cast(ENV.fetch('ENABLE_API_CORS', false))
|
||||
resource '/api/*', headers: :any, methods: :any, expose: %w[access-token client uid expiry]
|
||||
end
|
||||
|
||||
+1
-1
@@ -127,6 +127,7 @@ Rails.application.routes.draw do
|
||||
post :unread
|
||||
post :custom_attributes
|
||||
get :attachments
|
||||
post :copilot
|
||||
get :inbox_assistant
|
||||
end
|
||||
end
|
||||
@@ -395,7 +396,6 @@ Rails.application.routes.draw do
|
||||
resources :users, only: [:create, :show, :update, :destroy] do
|
||||
member do
|
||||
get :login
|
||||
post :token
|
||||
end
|
||||
end
|
||||
resources :agent_bots, only: [:index, :create, :show, :update, :destroy] do
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
## Chatwoot Developer Documentation
|
||||
|
||||
Welcome to the official Chatwoot developer documentation. This guide contains everything you need to know about Chatwoot APIs and build custom flows on top of Chatwoot APIs.
|
||||
|
||||
### 👩💻 Development
|
||||
|
||||
Install the [Mintlify CLI](https://www.npmjs.com/package/mintlify) to preview the documentation changes locally. To install, use the following command
|
||||
|
||||
```
|
||||
npm i -g mintlify
|
||||
```
|
||||
|
||||
Run the following command at the root of your documentation (where mint.json is)
|
||||
|
||||
```
|
||||
mintlify dev
|
||||
```
|
||||
|
||||
### 😎 Publishing Changes
|
||||
|
||||
Changes will be deployed to production automatically after pushing to the default branch.
|
||||
|
||||
You can also preview changes using PRs, which generates a preview link of the docs.
|
||||
|
||||
#### Troubleshooting
|
||||
|
||||
- Mintlify dev isn't running - Run `mintlify install` it'll re-install dependencies.
|
||||
- Page loads as a 404 - Make sure you are running in a folder with `mint.json`
|
||||
@@ -1,100 +0,0 @@
|
||||
{
|
||||
"$schema": "https://mintlify.com/docs.json",
|
||||
"name": "Chatwoot Developer Docs",
|
||||
"description": "Official developer documentation for Chatwoot - the open-source customer support platform. Learn about our APIs, integrations, and development guidelines.",
|
||||
"logo": {
|
||||
"dark": "/logo/dark.png",
|
||||
"light": "/logo/light.png"
|
||||
},
|
||||
"favicon": "/favicon.png",
|
||||
"colors": {
|
||||
"primary": "#0069ED",
|
||||
"light": "#4D9CFF",
|
||||
"dark": "#0050B4"
|
||||
},
|
||||
"fonts": {
|
||||
"heading": {
|
||||
"family": "Haskoy",
|
||||
"weight": 500,
|
||||
"source": "https://d1j5ayohogpcd2.cloudfront.net/fonts/haskoy/Haskoy-Medium.woff2",
|
||||
"format": "woff2"
|
||||
},
|
||||
"body": {
|
||||
"family": "Haskoy",
|
||||
"weight": 400,
|
||||
"source": "https://d1j5ayohogpcd2.cloudfront.net/fonts/haskoy/Haskoy-Regular.woff2",
|
||||
"format": "woff2"
|
||||
}
|
||||
},
|
||||
"theme": "maple",
|
||||
"navigation": {
|
||||
"groups": [
|
||||
{
|
||||
"group": "API Reference",
|
||||
"pages": [
|
||||
"introduction"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Application API",
|
||||
"description": "APIs for managing application aspects of Chatwoot",
|
||||
"includeTags": [
|
||||
"Agents",
|
||||
"Automation Rule",
|
||||
"Account AgentBots",
|
||||
"Canned Responses",
|
||||
"Contact Labels",
|
||||
"Contacts",
|
||||
"Conversation Assignments",
|
||||
"Conversation Labels",
|
||||
"Conversations",
|
||||
"Custom Attributes",
|
||||
"Custom Filters",
|
||||
"Help Center",
|
||||
"Inboxes",
|
||||
"Integrations",
|
||||
"Messages",
|
||||
"Profile",
|
||||
"Reports",
|
||||
"Teams",
|
||||
"Webhooks"
|
||||
],
|
||||
"openapi": "https://raw.githubusercontent.com/chatwoot/chatwoot/develop/swagger/tag_groups/application_swagger.json"
|
||||
},
|
||||
{
|
||||
"group": "Platform API",
|
||||
"description": "APIs for managing platform aspects of Chatwoot",
|
||||
"includeTags": [
|
||||
"Accounts",
|
||||
"Account Users",
|
||||
"AgentBots",
|
||||
"Users"
|
||||
],
|
||||
"openapi": "https://raw.githubusercontent.com/chatwoot/chatwoot/develop/swagger/tag_groups/platform_swagger.json"
|
||||
},
|
||||
{
|
||||
"group": "Client API",
|
||||
"description": "APIs for client applications",
|
||||
"includeTags": [
|
||||
"Contacts API",
|
||||
"Conversations API",
|
||||
"Messages API"
|
||||
],
|
||||
"openapi": "https://raw.githubusercontent.com/chatwoot/chatwoot/develop/swagger/tag_groups/client_swagger.json"
|
||||
},
|
||||
{
|
||||
"group": "Other APIs",
|
||||
"description": "Other Chatwoot APIs",
|
||||
"includeTags": [
|
||||
"CSAT Survey Page"
|
||||
],
|
||||
"openapi": "https://raw.githubusercontent.com/chatwoot/chatwoot/develop/swagger/tag_groups/other_swagger.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"footerSocials": {
|
||||
"twitter": "https://twitter.com/chatwootapp",
|
||||
"github": "https://github.com/chatwoot",
|
||||
"linkedin": "https://www.linkedin.com/company/chatwoot"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.7 KiB |
@@ -1,49 +0,0 @@
|
||||
---
|
||||
title: Introduction to Chatwoot APIs
|
||||
description: Learn how to use Chatwoot APIs to build integrations, customize chat experiences, and manage your installation.
|
||||
sidebarTitle: Introduction
|
||||
---
|
||||
|
||||
Welcome to the Chatwoot API documentation. Whether you're building custom workflows for your support team, integrating Chatwoot into your product, or managing users across installations, our APIs provide the flexibility and power to help you do more with Chatwoot.
|
||||
|
||||
Chatwoot provides three categories of APIs, each designed with a specific use case in mind:
|
||||
|
||||
- **Application APIs** – For account-level automation and agent-facing integrations.
|
||||
- **Client APIs** – For building custom chat interfaces for end-users
|
||||
- **Platform APIs** – For managing and administering installations at scale
|
||||
|
||||
---
|
||||
|
||||
## Application APIs
|
||||
|
||||
Application APIs are designed for interacting with a Chatwoot account from an agent/admin perspective. Use them to build internal tools, automate workflows, or perform bulk operations like data import/export.
|
||||
|
||||
- **Authentication**: Requires a user `access_token`, which can be generated from **Profile Settings** after logging into your Chatwoot account.
|
||||
- **Availability**: Supported on both **Cloud** and **Self-hosted** Chatwoot installations.
|
||||
- **Example**: [Google Cloud Functions Demo](https://github.com/chatwoot/google-cloud-functions-demo)
|
||||
|
||||
---
|
||||
|
||||
## Client APIs
|
||||
|
||||
Client APIs are intended for building custom messaging experiences over Chatwoot. If you're not using the native website widget or want to embed chat in your mobile app, these APIs are the way to go.
|
||||
|
||||
- **Authentication**: Uses `inbox_identifier` (from **Settings → Configuration** in API inboxes) and `contact_identifier` (returned when creating a contact).
|
||||
- **Availability**: Supported on both **Cloud** and **Self-hosted** Chatwoot installations.
|
||||
- **Examples**:
|
||||
|
||||
- [Client API Demo](https://github.com/chatwoot/client-api-demo)
|
||||
- [Flutter SDK](https://github.com/chatwoot/chatwoot-flutter-sdk)
|
||||
|
||||
---
|
||||
|
||||
## Platform APIs
|
||||
|
||||
Platform APIs are used to manage Chatwoot installations at the admin level. These APIs allow you to control users, roles, and accounts, or sync data from external authentication systems.
|
||||
|
||||
- **Authentication**: Requires an `access_token` generated by a **Platform App**, which can be created in the **Super Admin Console**.
|
||||
- **Availability**: Available on **Self-hosted** / **Managed Hosting** Chatwoot installations only.
|
||||
|
||||
---
|
||||
|
||||
Use the right API for your use case, and you'll be able to extend, customize, and integrate Chatwoot into your stack with ease.
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 168 KiB |
@@ -4,6 +4,29 @@ module Enterprise::Api::V1::Accounts::ConversationsController
|
||||
before_action :set_assistant, only: [:copilot]
|
||||
end
|
||||
|
||||
def copilot
|
||||
# First try to get the user's preferred assistant from UI settings or from the request
|
||||
assistant_id = copilot_params[:assistant_id] || current_user.ui_settings&.dig('preferred_captain_assistant_id')
|
||||
|
||||
# Find the assistant either by ID or from inbox
|
||||
assistant = if assistant_id.present?
|
||||
Captain::Assistant.find_by(id: assistant_id, account_id: Current.account.id)
|
||||
else
|
||||
@conversation.inbox.captain_assistant
|
||||
end
|
||||
|
||||
return render json: { message: I18n.t('captain.copilot_error') } unless assistant
|
||||
|
||||
response = Captain::Copilot::ChatService.new(
|
||||
assistant,
|
||||
previous_messages: copilot_params[:previous_messages],
|
||||
conversation_history: @conversation.to_llm_text,
|
||||
language: @conversation.account.locale_english_name
|
||||
).generate_response(copilot_params[:message])
|
||||
|
||||
render json: { message: response['response'] }
|
||||
end
|
||||
|
||||
def inbox_assistant
|
||||
assistant = @conversation.inbox.captain_assistant
|
||||
|
||||
|
||||
@@ -12,13 +12,10 @@ module Captain::ChatHelper
|
||||
)
|
||||
|
||||
handle_response(response)
|
||||
rescue StandardError => e
|
||||
Rails.logger.error { "[CAPTAIN][ChatCompletion] #{e}" }
|
||||
raise e
|
||||
end
|
||||
|
||||
def handle_response(response)
|
||||
Rails.logger.info { "[CAPTAIN][ChatCompletion] #{response}" }
|
||||
Rails.logger.debug { "[CAPTAIN][ChatCompletion] #{response}" }
|
||||
message = response.dig('choices', 0, 'message')
|
||||
if message['tool_calls']
|
||||
process_tool_calls(message['tool_calls'])
|
||||
@@ -39,13 +36,11 @@ module Captain::ChatHelper
|
||||
arguments = JSON.parse(tool_call['function']['arguments'])
|
||||
function_name = tool_call['function']['name']
|
||||
tool_call_id = tool_call['id']
|
||||
function_name = tool_call['function']['name']
|
||||
arguments = JSON.parse(tool_call['function']['arguments'])
|
||||
|
||||
if @tool_registry.respond_to?(function_name)
|
||||
execute_tool(function_name, arguments, tool_call_id)
|
||||
else
|
||||
process_invalid_tool_call(tool_call_id, function_name)
|
||||
process_invalid_tool_call(tool_call_id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,6 +56,10 @@ module Captain::ChatHelper
|
||||
}
|
||||
end
|
||||
|
||||
def process_invalid_tool_call(tool_call_id)
|
||||
append_tool_response('Tool not available', tool_call_id)
|
||||
end
|
||||
|
||||
def append_tool_response(content, tool_call_id)
|
||||
@messages << {
|
||||
role: 'tool',
|
||||
@@ -68,37 +67,4 @@ module Captain::ChatHelper
|
||||
content: content
|
||||
}
|
||||
end
|
||||
|
||||
def publish_to_stream(response)
|
||||
@stream_writer&.call(response)
|
||||
end
|
||||
|
||||
def execute_tool_call(tool_call_id, function_name, arguments)
|
||||
publish_to_stream(
|
||||
{
|
||||
response: { response: "Processing tool call #{function_name}" },
|
||||
type: 'tool_calls_start'
|
||||
}
|
||||
)
|
||||
result = @tool_registry.send(function_name, arguments.merge('user_id' => @user_id))
|
||||
append_tool_response(result, tool_call_id)
|
||||
publish_to_stream(
|
||||
{
|
||||
response: { response: "Received tool response #{function_name}" },
|
||||
type: 'tool_response',
|
||||
tool: function_name
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def process_invalid_tool_call(tool_call_id, function_name)
|
||||
append_tool_response('Tool not implemented', tool_call_id)
|
||||
publish_to_stream(
|
||||
{
|
||||
response: { response: 'Tool not implemented' },
|
||||
type: 'tool_error',
|
||||
tool: function_name
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
class Captain::ProcessCopilotMessageJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(assistant_id:, message:, options: {})
|
||||
Rails.logger.info("[Captain::ProcessCopilotMessageJob] Starting job for assistant_id=#{assistant_id}")
|
||||
ensure_assistant(assistant_id)
|
||||
ensure_user(options[:user_id])
|
||||
process_message(message, options)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ensure_assistant(assistant_id)
|
||||
Rails.logger.info("[Captain::ProcessCopilotMessageJob] Finding assistant with id=#{assistant_id}")
|
||||
@assistant = Captain::Assistant.find(assistant_id)
|
||||
@account = @assistant.account
|
||||
Rails.logger.info("[Captain::ProcessCopilotMessageJob] Found assistant for account_id=#{@account.id}")
|
||||
end
|
||||
|
||||
def ensure_user(user_id)
|
||||
Rails.logger.info("[Captain::ProcessCopilotMessageJob] Finding user with id=#{user_id}")
|
||||
@user = @account.users.find(user_id)
|
||||
Rails.logger.info("[Captain::ProcessCopilotMessageJob] Found user #{@user.name}")
|
||||
end
|
||||
|
||||
def process_message(message, options)
|
||||
return unless @assistant
|
||||
|
||||
Rails.logger.info("[Captain::ProcessCopilotMessageJob] Processing message with conversation_id=#{options[:conversation_id]}")
|
||||
conversation = find_conversation(options[:conversation_id])
|
||||
generate_chat_response(message, conversation, options[:previous_history])
|
||||
end
|
||||
|
||||
def find_conversation(conversation_id)
|
||||
return unless conversation_id
|
||||
|
||||
@account.conversations.find_by(display_id: conversation_id)
|
||||
end
|
||||
|
||||
def generate_chat_response(message, conversation, previous_history)
|
||||
Rails.logger.info("[Captain::ProcessCopilotMessageJob] Generating chat response for conversation_id=#{conversation&.display_id}, user_id=#{@user.id}")
|
||||
Captain::Copilot::ChatService.new(
|
||||
@assistant,
|
||||
previous_messages: previous_history || [],
|
||||
stream_writer: ->(data) { broadcast_response(data) },
|
||||
additional_info: {
|
||||
language: @account.locale_english_name,
|
||||
conversation_id: conversation&.display_id,
|
||||
contact_id: conversation&.contact_id,
|
||||
user_id: @user.id
|
||||
}
|
||||
).generate_response(message)
|
||||
end
|
||||
|
||||
def broadcast_response(data)
|
||||
Rails.logger.info("[Captain::ProcessCopilotMessageJob] Broadcasting response to account_id=#{@account.id} user_id=#{@user.id}")
|
||||
ActionCable.server.broadcast(
|
||||
"copilot_#{@account.id}_#{@user.id}",
|
||||
{ event: 'copilot.response', data: data }
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -1,50 +1,27 @@
|
||||
require 'openai'
|
||||
|
||||
class Captain::Copilot::ChatService < Llm::BaseOpenAiService
|
||||
include Captain::ChatHelper
|
||||
|
||||
attr_reader :assistant, :language
|
||||
|
||||
def initialize(assistant, config = {})
|
||||
def initialize(assistant, config)
|
||||
super()
|
||||
|
||||
@assistant = assistant
|
||||
@tool_registry = Captain::ToolRegistryService.new(@assistant)
|
||||
@stream_writer = config[:stream_writer]
|
||||
setup_additional_info(config)
|
||||
@conversation_history = config[:conversation_history]
|
||||
@previous_messages = config[:previous_messages] || []
|
||||
@language = config[:language] || 'english'
|
||||
|
||||
register_tools
|
||||
@messages = build_initial_messages(config)
|
||||
end
|
||||
|
||||
def setup_additional_info(config)
|
||||
additional_info = config[:additional_info] || {}
|
||||
@language = additional_info[:language] || 'english'
|
||||
@conversation_id = additional_info[:conversation_id]
|
||||
@contact_id = additional_info[:contact_id]
|
||||
@user_id = additional_info[:user_id]
|
||||
Rails.logger.info("[Captain::Copilot::ChatService::User] user_id: #{@user_id}")
|
||||
end
|
||||
|
||||
def build_initial_messages(config)
|
||||
Rails.logger.info("[CAPTAIN][CopilotChatService] Building initial messages for conversation_id=#{@conversation_id}")
|
||||
messages = [system_message]
|
||||
messages += (config[:previous_messages] || [])
|
||||
Rails.logger.info("[CAPTAIN][CopilotChatService] Added #{config[:previous_messages]&.length || 0} previous messages")
|
||||
messages << current_viewing_history if @conversation_id
|
||||
Rails.logger.info("[CAPTAIN][CopilotChatService] Total messages built: #{messages.length}")
|
||||
messages
|
||||
@messages = [system_message, conversation_history_context] + @previous_messages
|
||||
@response = ''
|
||||
end
|
||||
|
||||
def generate_response(input)
|
||||
@messages << { role: 'user', content: input } if input.present?
|
||||
Rails.logger.info("[CAPTAIN][CopilotChatService] Initial Prompt: #{@messages}")
|
||||
response = request_chat_completion
|
||||
Rails.logger.info("[CAPTAIN][CopilotChatService] Incrementing response usage for #{@assistant.account.id}")
|
||||
@assistant.account.increment_response_usage
|
||||
|
||||
publish_to_stream(
|
||||
{
|
||||
response: response,
|
||||
type: 'final_response'
|
||||
}
|
||||
)
|
||||
response
|
||||
end
|
||||
|
||||
@@ -53,35 +30,22 @@ class Captain::Copilot::ChatService < Llm::BaseOpenAiService
|
||||
def register_tools
|
||||
@tool_registry = Captain::ToolRegistryService.new(@assistant)
|
||||
@tool_registry.register_tool(Captain::Tools::SearchDocumentationService)
|
||||
@tool_registry.register_tool(Captain::Tools::Copilot::GetArticleService)
|
||||
@tool_registry.register_tool(Captain::Tools::Copilot::GetContactService)
|
||||
@tool_registry.register_tool(Captain::Tools::Copilot::GetConversationService)
|
||||
@tool_registry.register_tool(Captain::Tools::Copilot::SearchArticlesService)
|
||||
@tool_registry.register_tool(Captain::Tools::Copilot::SearchContactsService)
|
||||
@tool_registry.register_tool(Captain::Tools::Copilot::SearchConversationsService)
|
||||
@tool_registry.register_tool(Captain::Tools::Copilot::SearchLinearIssuesService)
|
||||
end
|
||||
|
||||
def system_message
|
||||
Rails.logger.info("[CAPTAIN][CopilotChatService] Generating system message for product=#{@assistant.config['product_name']} language=#{@language}")
|
||||
{
|
||||
role: 'system',
|
||||
content: Captain::Llm::SystemPromptsService.copilot_response_generator(@assistant.config['product_name'], @language, @assistant.account_id)
|
||||
content: Captain::Llm::SystemPromptsService.copilot_response_generator(@assistant.config['product_name'], @language)
|
||||
}
|
||||
end
|
||||
|
||||
def current_viewing_history
|
||||
Rails.logger.info("[CAPTAIN][CopilotChatService] Fetching viewing history for conversation_id=#{@conversation_id}")
|
||||
return unless @conversation_id
|
||||
|
||||
def conversation_history_context
|
||||
{
|
||||
role: 'system',
|
||||
content: <<~HISTORY.strip
|
||||
You are currently viewing the conversation with the user with the following details:
|
||||
Conversation ID: #{@conversation_id}
|
||||
Contact ID: #{@contact_id}
|
||||
Account ID: #{@assistant.account.id}
|
||||
HISTORY
|
||||
content: "
|
||||
Message History with the user is below:
|
||||
#{@conversation_history}
|
||||
"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,15 +56,14 @@ class Captain::Llm::SystemPromptsService
|
||||
SYSTEM_PROMPT_MESSAGE
|
||||
end
|
||||
|
||||
def copilot_response_generator(product_name, language, account_id)
|
||||
def copilot_response_generator(product_name, language)
|
||||
<<~SYSTEM_PROMPT_MESSAGE
|
||||
[Identity]
|
||||
You are Captain, a helpful and friendly copilot assistant for support agents using the product #{product_name}. Your primary role is to assist support agents by retrieving information, compiling accurate responses, and guiding them through customer interactions.
|
||||
You should only provide information related to #{product_name} and must not address queries about other products or external events.
|
||||
You are an assistant for the account with ID: #{account_id}
|
||||
|
||||
[Context]
|
||||
Identify unresolved queries, and ensure responses are relevant and consistent with previous interactions. Always maintain a coherent and professional tone throughout the conversation.
|
||||
You will be provided with the message history between the support agent and the customer. Use this context to understand the conversation flow, identify unresolved queries, and ensure responses are relevant and consistent with previous interactions. Always maintain a coherent and professional tone throughout the conversation.
|
||||
|
||||
[Response Guidelines]
|
||||
- Use natural, polite, and conversational language that is clear and easy to follow. Keep sentences short and use simple words.
|
||||
@@ -91,9 +90,6 @@ class Captain::Llm::SystemPromptsService
|
||||
7. Write the response in multiple paragraphs and in markdown format.
|
||||
8. DO NOT use headings in Markdown
|
||||
9. Cite the sources if you used a tool to find the response.
|
||||
10. Do not use your own training data or assumptions to answer queries. Base responses strictly on the provided information.
|
||||
11. Always provide a reasoning for the response.
|
||||
12. Always double the check the information with tools unless you are very sure of the information.
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@ class CustomMarkdownRenderer < CommonMarker::HtmlRenderer
|
||||
VIMEO_REGEX = %r{https?://(?:www\.)?vimeo\.com/(\d+)}
|
||||
MP4_REGEX = %r{https?://(?:www\.)?.+\.(mp4)}
|
||||
ARCADE_REGEX = %r{https?://(?:www\.)?app\.arcade\.software/share/([^&/]+)}
|
||||
WISTIA_REGEX = %r{https?://(?:www\.)?([^/]+)\.wistia\.com/medias/([^&/]+)}
|
||||
|
||||
def text(node)
|
||||
content = node.string_content
|
||||
@@ -51,8 +50,7 @@ class CustomMarkdownRenderer < CommonMarker::HtmlRenderer
|
||||
VIMEO_REGEX => :make_vimeo_embed,
|
||||
MP4_REGEX => :make_video_embed,
|
||||
LOOM_REGEX => :make_loom_embed,
|
||||
ARCADE_REGEX => :make_arcade_embed,
|
||||
WISTIA_REGEX => :make_wistia_embed
|
||||
ARCADE_REGEX => :make_arcade_embed
|
||||
}
|
||||
|
||||
embedding_methods.each do |regex, method|
|
||||
@@ -78,30 +76,67 @@ class CustomMarkdownRenderer < CommonMarker::HtmlRenderer
|
||||
|
||||
def make_youtube_embed(youtube_match)
|
||||
video_id = youtube_match[1]
|
||||
EmbedRenderer.youtube(video_id)
|
||||
%(
|
||||
<div style="position: relative; padding-bottom: 62.5%; height: 0;">
|
||||
<iframe
|
||||
src="https://www.youtube-nocookie.com/embed/#{video_id}"
|
||||
frameborder="0"
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen></iframe>
|
||||
</div>
|
||||
)
|
||||
end
|
||||
|
||||
def make_loom_embed(loom_match)
|
||||
video_id = loom_match[1]
|
||||
EmbedRenderer.loom(video_id)
|
||||
%(
|
||||
<div style="position: relative; padding-bottom: 62.5%; height: 0;">
|
||||
<iframe
|
||||
src="https://www.loom.com/embed/#{video_id}"
|
||||
frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe>
|
||||
</div>
|
||||
)
|
||||
end
|
||||
|
||||
def make_vimeo_embed(vimeo_match)
|
||||
video_id = vimeo_match[1]
|
||||
EmbedRenderer.vimeo(video_id)
|
||||
%(
|
||||
<div style="position: relative; padding-bottom: 62.5%; height: 0;">
|
||||
<iframe
|
||||
src="https://player.vimeo.com/video/#{video_id}?dnt=true"
|
||||
frameborder="0"
|
||||
allow="autoplay; fullscreen; picture-in-picture"
|
||||
allowfullscreen
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe>
|
||||
</div>
|
||||
)
|
||||
end
|
||||
|
||||
def make_video_embed(link_url)
|
||||
EmbedRenderer.video(link_url)
|
||||
end
|
||||
|
||||
def make_wistia_embed(wistia_match)
|
||||
video_id = wistia_match[2]
|
||||
EmbedRenderer.wistia(video_id)
|
||||
%(
|
||||
<video width="640" height="360" controls>
|
||||
<source src="#{link_url}" type="video/mp4">
|
||||
Your browser does not support the video tag.
|
||||
</video>
|
||||
)
|
||||
end
|
||||
|
||||
def make_arcade_embed(arcade_match)
|
||||
video_id = arcade_match[1]
|
||||
EmbedRenderer.arcade(video_id)
|
||||
%(
|
||||
<div style="position: relative; padding-bottom: 62.5%; height: 0;">
|
||||
<iframe
|
||||
src="https://app.arcade.software/embed/#{video_id}"
|
||||
frameborder="0"
|
||||
webkitallowfullscreen
|
||||
mozallowfullscreen
|
||||
allowfullscreen
|
||||
allow="fullscreen"
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
|
||||
</iframe>
|
||||
</div>
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
module EmbedRenderer
|
||||
def self.youtube(video_id)
|
||||
%(
|
||||
<div style="position: relative; padding-bottom: 62.5%; height: 0;">
|
||||
<iframe
|
||||
src="https://www.youtube-nocookie.com/embed/#{video_id}"
|
||||
frameborder="0"
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen></iframe>
|
||||
</div>
|
||||
)
|
||||
end
|
||||
|
||||
def self.loom(video_id)
|
||||
%(
|
||||
<div style="position: relative; padding-bottom: 62.5%; height: 0;">
|
||||
<iframe
|
||||
src="https://www.loom.com/embed/#{video_id}"
|
||||
frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe>
|
||||
</div>
|
||||
)
|
||||
end
|
||||
|
||||
def self.vimeo(video_id)
|
||||
%(
|
||||
<div style="position: relative; padding-bottom: 62.5%; height: 0;">
|
||||
<iframe
|
||||
src="https://player.vimeo.com/video/#{video_id}?dnt=true"
|
||||
frameborder="0"
|
||||
allow="autoplay; fullscreen; picture-in-picture"
|
||||
allowfullscreen
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe>
|
||||
</div>
|
||||
)
|
||||
end
|
||||
|
||||
def self.video(link_url)
|
||||
%(
|
||||
<video width="640" height="360" controls>
|
||||
<source src="#{link_url}" type="video/mp4">
|
||||
Your browser does not support the video tag.
|
||||
</video>
|
||||
)
|
||||
end
|
||||
|
||||
# Generates an HTML embed for a Wistia video.
|
||||
# @param wistia_match [MatchData] A match object from the WISTIA_REGEX regex, where wistia_match[2] contains the video ID.
|
||||
def self.wistia(video_id)
|
||||
%(
|
||||
<div style="position: relative; padding-bottom: 56.25%; height: 0;">
|
||||
<script src="https://fast.wistia.com/player.js" async></script>
|
||||
<script src="https://fast.wistia.com/embed/#{video_id}.js" async type="module"></script>
|
||||
<style>
|
||||
wistia-player[media-id='#{video_id}']:not(:defined) {
|
||||
background: center / contain no-repeat url('https://fast.wistia.com/embed/medias/#{video_id}/swatch');
|
||||
display: block;
|
||||
filter: blur(5px);
|
||||
padding-top:56.25%;
|
||||
}
|
||||
</style>
|
||||
<wistia-player
|
||||
media-id="#{video_id}"
|
||||
aspect="1.7777777777777777"
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
|
||||
</wistia-player>
|
||||
</div>
|
||||
)
|
||||
end
|
||||
|
||||
def self.arcade(video_id)
|
||||
%(
|
||||
<div style="position: relative; padding-bottom: 62.5%; height: 0;">
|
||||
<iframe
|
||||
src="https://app.arcade.software/embed/#{video_id}"
|
||||
frameborder="0"
|
||||
webkitallowfullscreen
|
||||
mozallowfullscreen
|
||||
allowfullscreen
|
||||
allow="fullscreen"
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
|
||||
</iframe>
|
||||
</div>
|
||||
)
|
||||
end
|
||||
end
|
||||
+10
-144
@@ -1,156 +1,22 @@
|
||||
require 'json_refs'
|
||||
require 'fileutils'
|
||||
require 'pathname'
|
||||
require 'yaml'
|
||||
require 'json'
|
||||
namespace :swagger do
|
||||
desc 'build combined swagger.json file from all the fragmented definitions and paths inside swagger folder'
|
||||
task build: :environment do
|
||||
require 'json_refs'
|
||||
|
||||
module SwaggerTaskActions
|
||||
def self.execute_build
|
||||
swagger_dir = Rails.root.join('swagger')
|
||||
# Paths relative to swagger_dir for use within Dir.chdir
|
||||
index_yml_relative_path = 'index.yml'
|
||||
swagger_json_relative_path = 'swagger.json'
|
||||
|
||||
Dir.chdir(swagger_dir) do
|
||||
# Operations within this block are relative to swagger_dir
|
||||
swagger_index_content = File.read(index_yml_relative_path)
|
||||
swagger_index = YAML.safe_load(swagger_index_content)
|
||||
base_path = Rails.root.join('swagger')
|
||||
Dir.chdir(base_path) do
|
||||
swagger_index = YAML.safe_load(File.open('index.yml'))
|
||||
|
||||
final_build = JsonRefs.call(
|
||||
swagger_index,
|
||||
resolve_local_ref: false,
|
||||
resolve_file_ref: true, # Uses CWD (swagger_dir) for resolving file refs
|
||||
resolve_file_ref: true,
|
||||
logging: true
|
||||
)
|
||||
File.write(swagger_json_relative_path, JSON.pretty_generate(final_build))
|
||||
|
||||
# For user messages, provide the absolute path
|
||||
absolute_swagger_json_path = swagger_dir.join(swagger_json_relative_path)
|
||||
File.write('swagger.json', JSON.pretty_generate(final_build))
|
||||
puts 'Swagger build was successful.'
|
||||
puts "Generated #{absolute_swagger_json_path}"
|
||||
puts "Generated #{base_path}/swagger.json"
|
||||
puts 'Go to http://localhost:3000/swagger see the changes.'
|
||||
|
||||
# Trigger dependent task
|
||||
Rake::Task['swagger:build_tag_groups'].invoke
|
||||
end
|
||||
end
|
||||
|
||||
def self.execute_build_tag_groups
|
||||
base_swagger_path = Rails.root.join('swagger')
|
||||
tag_groups_output_dir = base_swagger_path.join('tag_groups')
|
||||
full_spec_path = base_swagger_path.join('swagger.json')
|
||||
index_yml_path = base_swagger_path.join('index.yml')
|
||||
|
||||
full_spec = JSON.parse(File.read(full_spec_path))
|
||||
swagger_index = YAML.safe_load(File.read(index_yml_path))
|
||||
tag_groups = swagger_index['x-tagGroups']
|
||||
|
||||
FileUtils.mkdir_p(tag_groups_output_dir)
|
||||
|
||||
tag_groups.each do |tag_group|
|
||||
_process_tag_group(tag_group, full_spec, tag_groups_output_dir)
|
||||
end
|
||||
|
||||
puts 'Tag-specific swagger files generated successfully.'
|
||||
end
|
||||
|
||||
def self.execute_build_for_docs
|
||||
Rake::Task['swagger:build'].invoke # Ensure all swagger files are built first
|
||||
|
||||
developer_docs_public_path = Rails.root.join('developer-docs/public')
|
||||
tag_groups_in_dev_docs_path = developer_docs_public_path.join('swagger/tag_groups')
|
||||
source_tag_groups_path = Rails.root.join('swagger/tag_groups')
|
||||
|
||||
FileUtils.mkdir_p(tag_groups_in_dev_docs_path)
|
||||
puts 'Creating symlinks for developer-docs...'
|
||||
|
||||
symlink_files = %w[platform_swagger.json application_swagger.json client_swagger.json other_swagger.json]
|
||||
symlink_files.each do |file|
|
||||
_create_symlink(source_tag_groups_path.join(file), tag_groups_in_dev_docs_path.join(file))
|
||||
end
|
||||
|
||||
puts 'Symlinks created successfully.'
|
||||
puts 'You can now run the Mintlify dev server to preview the documentation.'
|
||||
end
|
||||
|
||||
# Private helper methods
|
||||
class << self
|
||||
private
|
||||
|
||||
def _process_tag_group(tag_group, full_spec, output_dir)
|
||||
group_name = tag_group['name']
|
||||
tags_in_current_group = tag_group['tags']
|
||||
|
||||
tag_spec = JSON.parse(JSON.generate(full_spec)) # Deep clone
|
||||
|
||||
tag_spec['paths'] = _filter_paths_for_tag_group(tag_spec['paths'], tags_in_current_group)
|
||||
tag_spec['tags'] = _filter_tags_for_tag_group(tag_spec['tags'], tags_in_current_group)
|
||||
|
||||
output_filename = _determine_output_filename(group_name)
|
||||
File.write(output_dir.join(output_filename), JSON.pretty_generate(tag_spec))
|
||||
end
|
||||
|
||||
def _operation_has_matching_tags?(operation, tags_in_group)
|
||||
return false unless operation.is_a?(Hash)
|
||||
|
||||
operation_tags = operation['tags']
|
||||
return false unless operation_tags.is_a?(Array)
|
||||
|
||||
operation_tags.intersect?(tags_in_group)
|
||||
end
|
||||
|
||||
def _filter_paths_for_tag_group(paths_spec, tags_in_group)
|
||||
(paths_spec || {}).filter_map do |path, path_item|
|
||||
next unless path_item.is_a?(Hash)
|
||||
|
||||
operations_with_group_tags = path_item.any? do |_method, operation|
|
||||
_operation_has_matching_tags?(operation, tags_in_group)
|
||||
end
|
||||
[path, path_item] if operations_with_group_tags
|
||||
end.to_h
|
||||
end
|
||||
|
||||
def _filter_tags_for_tag_group(tags_spec, tags_in_group)
|
||||
if tags_spec.is_a?(Array)
|
||||
tags_spec.select { |tag_definition| tags_in_group.include?(tag_definition['name']) }
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def _determine_output_filename(group_name)
|
||||
return 'other_swagger.json' if group_name.casecmp('others').zero?
|
||||
|
||||
sanitized_group_name = group_name.downcase.tr(' ', '_').gsub(/[^a-z0-9_]+/, '')
|
||||
"#{sanitized_group_name}_swagger.json"
|
||||
end
|
||||
|
||||
def _create_symlink(source_file_path, target_file_path)
|
||||
FileUtils.rm_f(target_file_path) # Remove existing to avoid errors
|
||||
|
||||
if File.exist?(source_file_path)
|
||||
relative_source_path = Pathname.new(source_file_path).relative_path_from(target_file_path.dirname)
|
||||
FileUtils.ln_sf(relative_source_path, target_file_path)
|
||||
else
|
||||
puts "Warning: Source file #{source_file_path} not found. Skipping symlink for #{File.basename(target_file_path)}."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :swagger do
|
||||
desc 'build combined swagger.json file from all the fragmented definitions and paths inside swagger folder'
|
||||
task build: :environment do
|
||||
SwaggerTaskActions.execute_build
|
||||
end
|
||||
|
||||
desc 'build separate swagger files for each tag group'
|
||||
task build_tag_groups: :environment do
|
||||
SwaggerTaskActions.execute_build_tag_groups
|
||||
end
|
||||
|
||||
desc 'build swagger files and create symlinks in developer-docs'
|
||||
task build_for_docs: :environment do
|
||||
SwaggerTaskActions.execute_build_for_docs
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,18 +79,6 @@ describe Messages::Instagram::MessageBuilder do
|
||||
expect(instagram_inbox.messages.count).to be 1
|
||||
end
|
||||
|
||||
it 'discards duplicate messages from webhook events with the same message_id' do
|
||||
messaging = dm_params[:entry][0]['messaging'][0]
|
||||
described_class.new(messaging, instagram_inbox).perform
|
||||
|
||||
initial_message_count = instagram_inbox.messages.count
|
||||
expect(initial_message_count).to be 1
|
||||
|
||||
described_class.new(messaging, instagram_inbox).perform
|
||||
|
||||
expect(instagram_inbox.messages.count).to eq initial_message_count
|
||||
end
|
||||
|
||||
it 'creates message for shared reel' do
|
||||
messaging = shared_reel_params[:entry][0]['messaging'][0]
|
||||
described_class.new(messaging, instagram_inbox).perform
|
||||
@@ -163,15 +151,11 @@ describe Messages::Instagram::MessageBuilder do
|
||||
end
|
||||
|
||||
it 'does not create message for unsupported file type' do
|
||||
conversation
|
||||
|
||||
# try to create a message with unsupported file type
|
||||
story_mention_params[:entry][0][:messaging][0]['message']['attachments'][0]['type'] = 'unsupported_type'
|
||||
messaging = story_mention_params[:entry][0][:messaging][0]
|
||||
|
||||
described_class.new(messaging, instagram_inbox, outgoing_echo: false).perform
|
||||
|
||||
# Conversation should exist but no new message should be created
|
||||
expect(instagram_inbox.conversations.count).to be 1
|
||||
expect(instagram_inbox.messages.count).to be 0
|
||||
end
|
||||
|
||||
@@ -189,22 +189,19 @@ describe Messages::Instagram::Messenger::MessageBuilder do
|
||||
profile_pic: 'https://chatwoot-assets.local/sample.png'
|
||||
}.with_indifferent_access
|
||||
)
|
||||
|
||||
conversation
|
||||
|
||||
# create a message with unsupported file type
|
||||
story_mention_params[:entry][0][:messaging][0]['message']['attachments'][0]['type'] = 'unsupported_type'
|
||||
messaging = story_mention_params[:entry][0][:messaging][0]
|
||||
|
||||
contact_inbox
|
||||
described_class.new(messaging, instagram_messenger_inbox, outgoing_echo: false).perform
|
||||
|
||||
instagram_messenger_inbox.reload
|
||||
|
||||
# Conversation should exist but no new message should be created
|
||||
# we would have contact created but message and attachments won't be created
|
||||
expect(instagram_messenger_inbox.conversations.count).to be 1
|
||||
expect(instagram_messenger_inbox.messages.count).to be 0
|
||||
|
||||
contact = instagram_messenger_channel.inbox.contacts.first
|
||||
|
||||
expect(contact.name).to eq('Jane Dae')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -76,54 +76,6 @@ RSpec.describe 'Platform Users API', type: :request do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /platform/api/v1/users/{user_id}/token' do
|
||||
context 'when it is an unauthenticated platform app' do
|
||||
it 'returns unauthorized' do
|
||||
post "/platform/api/v1/users/#{user.id}/token"
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it is an invalid platform app token' do
|
||||
it 'returns unauthorized' do
|
||||
post "/platform/api/v1/users/#{user.id}/token", headers: { api_access_token: 'invalid' }, as: :json
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it is an authenticated platform app' do
|
||||
let(:platform_app) { create(:platform_app) }
|
||||
|
||||
it 'returns unauthorized when its not a permissible object' do
|
||||
post "/platform/api/v1/users/#{user.id}/token", headers: { api_access_token: platform_app.access_token.token }, as: :json
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
end
|
||||
|
||||
it 'returns access token for the user with expiry and user info' do
|
||||
create(:platform_app_permissible, platform_app: platform_app, permissible: user)
|
||||
|
||||
post "/platform/api/v1/users/#{user.id}/token",
|
||||
headers: { api_access_token: platform_app.access_token.token }, as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
data = response.parsed_body
|
||||
|
||||
# Check access token and expiry
|
||||
expect(data['access_token']).to eq(user.access_token.token)
|
||||
expect(data['expiry']).to be_nil
|
||||
|
||||
# Check user info
|
||||
expect(data['user']).to include(
|
||||
'id' => user.id,
|
||||
'name' => user.name,
|
||||
'display_name' => user.display_name,
|
||||
'email' => user.email,
|
||||
'pubsub_token' => user.pubsub_token
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /platform/api/v1/users/' do
|
||||
context 'when it is an unauthenticated platform app' do
|
||||
it 'returns unauthorized' do
|
||||
|
||||
@@ -143,17 +143,6 @@ describe CustomMarkdownRenderer do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when link is a wistia URL' do
|
||||
let(:wistia_url) { 'https://chatwoot.wistia.com/medias/kjwjeq6f9i' }
|
||||
|
||||
it 'renders a custom element with Wistia embed code' do
|
||||
output = render_markdown_link(wistia_url)
|
||||
expect(output).to include('<script src="https://fast.wistia.com/player.js" async></script>')
|
||||
expect(output).to include('<wistia-player')
|
||||
expect(output).to include('media-id="kjwjeq6f9i"')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when multiple links including Arcade are present' do
|
||||
it 'renders Arcade embed along with other content types' do
|
||||
markdown = "\n[arcade](https://app.arcade.software/share/ARCADE_ID)\n\n[youtube](https://www.youtube.com/watch?v=VIDEO_ID)\n"
|
||||
|
||||
@@ -16,7 +16,6 @@ RSpec.describe Crm::Leadsquared::Mappers::ContactMapper do
|
||||
name: 'John',
|
||||
last_name: 'Doe',
|
||||
email: 'john@example.com',
|
||||
# the phone number is intentionally wrong
|
||||
phone_number: '+1234567890'
|
||||
)
|
||||
|
||||
@@ -30,19 +29,6 @@ RSpec.describe Crm::Leadsquared::Mappers::ContactMapper do
|
||||
'Source' => 'Test Brand'
|
||||
)
|
||||
end
|
||||
|
||||
it 'represents the phone number correctly' do
|
||||
contact.update!(
|
||||
name: 'John',
|
||||
last_name: 'Doe',
|
||||
email: 'john@example.com',
|
||||
phone_number: '+917507684392'
|
||||
)
|
||||
|
||||
mapped_data = described_class.map(contact)
|
||||
|
||||
expect(mapped_data).to include('Mobile' => '+91-7507684392')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -194,44 +194,23 @@ describe MessageTemplates::HookExecutionService do
|
||||
expect(out_of_office_service).to have_received(:perform)
|
||||
end
|
||||
|
||||
context 'with recent outgoing messages' do
|
||||
it 'does not call ::MessageTemplates::Template::OutOfOffice when there are recent outgoing messages' do
|
||||
contact = create(:contact)
|
||||
conversation = create(:conversation, contact: contact)
|
||||
it 'does not call ::MessageTemplates::Template::OutOfOffice when there are recent outgoing messages' do
|
||||
contact = create(:contact)
|
||||
conversation = create(:conversation, contact: contact)
|
||||
|
||||
conversation.inbox.update(working_hours_enabled: true, out_of_office_message: 'We are out of office')
|
||||
conversation.inbox.working_hours.today.update!(closed_all_day: true)
|
||||
conversation.inbox.update(working_hours_enabled: true, out_of_office_message: 'We are out of office')
|
||||
conversation.inbox.working_hours.today.update!(closed_all_day: true)
|
||||
|
||||
create(:message, conversation: conversation, message_type: :outgoing, created_at: 2.minutes.ago)
|
||||
create(:message, conversation: conversation, message_type: :outgoing, created_at: 2.minutes.ago)
|
||||
|
||||
out_of_office_service = double
|
||||
allow(MessageTemplates::Template::OutOfOffice).to receive(:new).and_return(out_of_office_service)
|
||||
allow(out_of_office_service).to receive(:perform).and_return(true)
|
||||
out_of_office_service = double
|
||||
allow(MessageTemplates::Template::OutOfOffice).to receive(:new).and_return(out_of_office_service)
|
||||
allow(out_of_office_service).to receive(:perform).and_return(true)
|
||||
|
||||
create(:message, conversation: conversation)
|
||||
create(:message, conversation: conversation)
|
||||
|
||||
expect(MessageTemplates::Template::OutOfOffice).not_to have_received(:new)
|
||||
expect(out_of_office_service).not_to have_received(:perform)
|
||||
end
|
||||
|
||||
it 'ignores private note and calls ::MessageTemplates::Template::OutOfOffice' do
|
||||
contact = create(:contact)
|
||||
conversation = create(:conversation, contact: contact)
|
||||
|
||||
conversation.inbox.update(working_hours_enabled: true, out_of_office_message: 'We are out of office')
|
||||
conversation.inbox.working_hours.today.update!(closed_all_day: true)
|
||||
|
||||
create(:message, conversation: conversation, private: true, message_type: :outgoing, created_at: 2.minutes.ago)
|
||||
|
||||
out_of_office_service = double
|
||||
allow(MessageTemplates::Template::OutOfOffice).to receive(:new).and_return(out_of_office_service)
|
||||
allow(out_of_office_service).to receive(:perform).and_return(true)
|
||||
|
||||
create(:message, conversation: conversation)
|
||||
|
||||
expect(MessageTemplates::Template::OutOfOffice).to have_received(:new).with(conversation: conversation)
|
||||
expect(out_of_office_service).to have_received(:perform)
|
||||
end
|
||||
expect(MessageTemplates::Template::OutOfOffice).not_to have_received(:new)
|
||||
expect(out_of_office_service).not_to have_received(:perform)
|
||||
end
|
||||
|
||||
it 'will not calls ::MessageTemplates::Template::OutOfOffice when outgoing message' do
|
||||
|
||||
@@ -6,4 +6,4 @@ properties:
|
||||
errors:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/request_error'
|
||||
$ref: '#/definitions/request_error'
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
## ---------- ERRORS -------------- ##
|
||||
## ---------- ERRORS ------------- ##
|
||||
## -------------------------------- ##
|
||||
bad_request_error:
|
||||
$ref: ./error/bad_request.yml
|
||||
request_error:
|
||||
$ref: ./error/request.yml
|
||||
|
||||
## ---------- RESOURCE ------------ ##
|
||||
|
||||
|
||||
## ---------- RESOURCE ------------- ##
|
||||
## -------------------------------- ##
|
||||
|
||||
generic_id:
|
||||
@@ -16,20 +18,12 @@ custom_attribute:
|
||||
$ref: ./resource/custom_attribute.yml
|
||||
automation_rule:
|
||||
$ref: ./resource/automation_rule.yml
|
||||
automation_rule_item:
|
||||
$ref: ./resource/automation_rule_item.yml
|
||||
portal:
|
||||
$ref: ./resource/portal.yml
|
||||
portal_single:
|
||||
$ref: ./resource/portal_single.yml
|
||||
portal_config:
|
||||
$ref: ./resource/portal_config.yml
|
||||
portal_logo:
|
||||
$ref: ./resource/portal_logo.yml
|
||||
portal_meta:
|
||||
$ref: ./resource/portal_meta.yml
|
||||
portal_item:
|
||||
$ref: ./resource/portal_item.yml
|
||||
category:
|
||||
$ref: ./resource/category.yml
|
||||
article:
|
||||
$ref: ./resource/article.yml
|
||||
category:
|
||||
$ref: ./resource/category.yml
|
||||
article:
|
||||
@@ -46,8 +40,6 @@ agent:
|
||||
$ref: ./resource/agent.yml
|
||||
inbox:
|
||||
$ref: ./resource/inbox.yml
|
||||
inbox_contact:
|
||||
$ref: ./resource/inbox_contact.yml
|
||||
agent_bot:
|
||||
$ref: ./resource/agent_bot.yml
|
||||
contact_inboxes:
|
||||
@@ -60,8 +52,6 @@ webhook:
|
||||
$ref: ./resource/webhook.yml
|
||||
account:
|
||||
$ref: ./resource/account.yml
|
||||
account_user:
|
||||
$ref: ./resource/account_user.yml
|
||||
platform_account:
|
||||
$ref: ./resource/platform_account.yml
|
||||
team:
|
||||
@@ -81,18 +71,13 @@ public_message:
|
||||
public_inbox:
|
||||
$ref: ./resource/public/inbox.yml
|
||||
|
||||
## ---------- REQUEST ------------- ##
|
||||
|
||||
## ---------- REQUEST------------- ##
|
||||
## -------------------------------- ##
|
||||
|
||||
account_create_update_payload:
|
||||
$ref: ./request/account/create_update_payload.yml
|
||||
|
||||
account_user_create_update_payload:
|
||||
$ref: ./request/account_user/create_update_payload.yml
|
||||
|
||||
platform_agent_bot_create_update_payload:
|
||||
$ref: ./request/platform/agent_bot/create_update_payload.yml
|
||||
|
||||
agent_bot_create_update_payload:
|
||||
$ref: ./request/agent_bot/create_update_payload.yml
|
||||
|
||||
@@ -104,36 +89,21 @@ canned_response_create_update_payload:
|
||||
|
||||
custom_attribute_create_update_payload:
|
||||
$ref: ./request/custom_attribute/create_update_payload.yml
|
||||
## contact
|
||||
contact_create:
|
||||
$ref: ./request/contact/create.yml
|
||||
contact_update:
|
||||
$ref: ./request/contact/update.yml
|
||||
|
||||
## Agent
|
||||
agent_create_payload:
|
||||
$ref: ./request/agent/create_payload.yml
|
||||
agent_update_payload:
|
||||
$ref: ./request/agent/update_payload.yml
|
||||
## conversation
|
||||
conversation_message_create:
|
||||
$ref: ./request/conversation/create_message.yml
|
||||
|
||||
## Contact
|
||||
contact_create_payload:
|
||||
$ref: ./request/contact/create_payload.yml
|
||||
contact_update_payload:
|
||||
$ref: ./request/contact/update_payload.yml
|
||||
|
||||
## Conversation
|
||||
conversation_create_payload:
|
||||
$ref: ./request/conversation/create_payload.yml
|
||||
conversation_message_create_payload:
|
||||
$ref: ./request/conversation/create_message_payload.yml
|
||||
|
||||
# Inbox
|
||||
inbox_create_payload:
|
||||
$ref: ./request/inbox/create_payload.yml
|
||||
inbox_update_payload:
|
||||
$ref: ./request/inbox/update_payload.yml
|
||||
|
||||
# Team
|
||||
# Team request Payload
|
||||
team_create_update_payload:
|
||||
$ref: ./request/team/create_update_payload.yml
|
||||
|
||||
# Custom Filter
|
||||
# Custom Filter request Payload
|
||||
custom_filter_create_update_payload:
|
||||
$ref: ./request/custom_filter/create_update_payload.yml
|
||||
|
||||
@@ -158,6 +128,7 @@ category_create_update_payload:
|
||||
article_create_update_payload:
|
||||
$ref: ./request/portal/article_create_update_payload.yml
|
||||
|
||||
|
||||
## public requests
|
||||
public_contact_create_update_payload:
|
||||
$ref: ./request/public/contact/create_update_payload.yml
|
||||
@@ -170,36 +141,37 @@ public_message_update_payload:
|
||||
public_conversation_create_payload:
|
||||
$ref: ./request/public/conversation/create_payload.yml
|
||||
|
||||
## ---------- RESPONSE ------------ ##
|
||||
## ---------- RESPONSE ------------- ##
|
||||
## -------------------------------- ##
|
||||
|
||||
## Contact
|
||||
## contact
|
||||
extended_contact:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/contact'
|
||||
- $ref: '#/definitions/contact'
|
||||
- $ref: ./resource/extension/contact/show.yml
|
||||
contact_base:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/generic_id'
|
||||
- $ref: '#/components/schemas/contact'
|
||||
- $ref: '#/definitions/generic_id'
|
||||
- $ref: '#/definitions/contact'
|
||||
contact_list:
|
||||
type: array
|
||||
description: 'array of contacts'
|
||||
items:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/contact'
|
||||
- $ref: '#/definitions/generic_id'
|
||||
- $ref: '#/definitions/contact'
|
||||
contact_conversations:
|
||||
type: array
|
||||
description: 'array of conversations'
|
||||
items:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/conversation'
|
||||
- $ref: '#/definitions/conversation'
|
||||
- $ref: ./resource/extension/contact/conversation.yml
|
||||
- $ref: ./resource/extension/conversation/with_display_id.yml
|
||||
contact_labels:
|
||||
$ref: ./resource/extension/contact/labels.yml
|
||||
|
||||
## Conversation
|
||||
## conversation
|
||||
conversation_list:
|
||||
$ref: ./resource/extension/conversation/list.yml
|
||||
conversation_show:
|
||||
@@ -209,33 +181,9 @@ conversation_status_toggle:
|
||||
conversation_labels:
|
||||
$ref: ./resource/extension/conversation/labels.yml
|
||||
|
||||
## Report
|
||||
|
||||
## report
|
||||
account_summary:
|
||||
$ref: './resource/reports/summary.yml'
|
||||
agent_conversation_metrics:
|
||||
$ref: './resource/reports/conversation/agent.yml'
|
||||
|
||||
contact_detail:
|
||||
$ref: ./resource/contact_detail.yml
|
||||
message_detailed:
|
||||
$ref: ./resource/message_detailed.yml
|
||||
conversation_meta:
|
||||
$ref: ./resource/conversation_meta.yml
|
||||
conversation_messages:
|
||||
$ref: ./resource/conversation_messages.yml
|
||||
contact_meta:
|
||||
$ref: ./resource/contact_meta.yml
|
||||
contact_inbox:
|
||||
$ref: ./resource/contact_inbox.yml
|
||||
contact_list_item:
|
||||
$ref: ./resource/contact_list_item.yml
|
||||
contacts_list_response:
|
||||
$ref: ./resource/contacts_list_response.yml
|
||||
contact_show_response:
|
||||
$ref: ./resource/contact_show_response.yml
|
||||
contact_conversation_message:
|
||||
$ref: ./resource/contact_conversation_message.yml
|
||||
contact_conversations_response:
|
||||
$ref: ./resource/contact_conversations_response.yml
|
||||
contactable_inboxes_response:
|
||||
$ref: ./resource/contactable_inboxes_response.yml
|
||||
|
||||
@@ -3,29 +3,3 @@ properties:
|
||||
name:
|
||||
type: string
|
||||
description: Name of the account
|
||||
example: 'My Account'
|
||||
locale:
|
||||
type: string
|
||||
description: The locale of the account
|
||||
example: 'en'
|
||||
domain:
|
||||
type: string
|
||||
description: The domain of the account
|
||||
example: 'example.com'
|
||||
support_email:
|
||||
type: string
|
||||
description: The support email of the account
|
||||
example: 'support@example.com'
|
||||
status:
|
||||
type: string
|
||||
enum: ['active', 'suspended']
|
||||
description: The status of the account
|
||||
example: 'active'
|
||||
limits:
|
||||
type: object
|
||||
description: The limits of the account
|
||||
example: {}
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: The custom attributes of the account
|
||||
example: {}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
type: object
|
||||
required:
|
||||
- user_id
|
||||
- role
|
||||
properties:
|
||||
user_id:
|
||||
type: integer
|
||||
description: The ID of the user
|
||||
example: 1
|
||||
role:
|
||||
type: string
|
||||
description: whether user is an administrator or agent
|
||||
example: administrator
|
||||
@@ -1,28 +0,0 @@
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- email
|
||||
- role
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: Full Name of the agent
|
||||
example: 'John Doe'
|
||||
email:
|
||||
type: string
|
||||
description: Email of the Agent
|
||||
example: 'john.doe@acme.inc'
|
||||
role:
|
||||
type: string
|
||||
enum: ['agent', 'administrator']
|
||||
description: Whether its administrator or agent
|
||||
example: 'agent'
|
||||
availability_status:
|
||||
type: string
|
||||
enum: ['available', 'busy', 'offline']
|
||||
description: The availability setting of the agent.
|
||||
example: 'available'
|
||||
auto_offline:
|
||||
type: boolean
|
||||
description: Whether the availability status of agent is configured to go offline automatically when away.
|
||||
example: true
|
||||
@@ -1,18 +0,0 @@
|
||||
type: object
|
||||
required:
|
||||
- role
|
||||
properties:
|
||||
role:
|
||||
type: string
|
||||
enum: ['agent', 'administrator']
|
||||
description: Whether its administrator or agent
|
||||
example: 'agent'
|
||||
availability_status:
|
||||
type: string
|
||||
enum: ['available', 'busy', 'offline']
|
||||
description: The availability status of the agent.
|
||||
example: 'available'
|
||||
auto_offline:
|
||||
type: boolean
|
||||
description: Whether the availability status of agent is configured to go offline automatically when away.
|
||||
example: true
|
||||
@@ -3,28 +3,9 @@ properties:
|
||||
name:
|
||||
type: string
|
||||
description: The name of the agent bot
|
||||
example: 'My Agent Bot'
|
||||
description:
|
||||
type: string
|
||||
description: The description of the agent bot
|
||||
example: 'This is a sample agent bot'
|
||||
description: The description about the agent bot
|
||||
outgoing_url:
|
||||
type: string
|
||||
description: The webhook URL for the bot
|
||||
example: 'https://example.com/webhook'
|
||||
avatar:
|
||||
type: string
|
||||
format: binary
|
||||
description: Send the form data with the avatar image binary or use the avatar_url
|
||||
avatar_url:
|
||||
type: string
|
||||
description: The url to a jpeg, png file for the agent bot avatar
|
||||
example: https://example.com/avatar.png
|
||||
bot_type:
|
||||
type: integer
|
||||
description: The type of the bot (0 for webhook)
|
||||
example: 0
|
||||
bot_config:
|
||||
type: object
|
||||
description: The configuration for the bot
|
||||
example: {}
|
||||
|
||||
@@ -36,6 +36,6 @@ properties:
|
||||
example:
|
||||
attribute_key: content
|
||||
filter_operator: contains
|
||||
query_operator: OR
|
||||
query_operator: nil
|
||||
values:
|
||||
- help
|
||||
|
||||
@@ -3,8 +3,6 @@ properties:
|
||||
content:
|
||||
type: string
|
||||
description: Message content for canned response
|
||||
example: 'Hello, {{contact.name}}! Welcome to our service.'
|
||||
short_code:
|
||||
type: string
|
||||
description: Short Code for quick access of the canned response
|
||||
example: 'welcome'
|
||||
|
||||
+5
-15
@@ -1,21 +1,18 @@
|
||||
type: object
|
||||
required:
|
||||
- inbox_id
|
||||
properties:
|
||||
inbox_id:
|
||||
type: number
|
||||
name:
|
||||
type: string
|
||||
description: name of the contact
|
||||
example: Alice
|
||||
email:
|
||||
type: string
|
||||
description: email of the contact
|
||||
example: alice@acme.inc
|
||||
blocked:
|
||||
type: boolean
|
||||
description: whether the contact is blocked or not
|
||||
example: false
|
||||
phone_number:
|
||||
type: string
|
||||
description: phone number of the contact
|
||||
example: '+123456789'
|
||||
avatar:
|
||||
type: string
|
||||
format: binary
|
||||
@@ -23,16 +20,9 @@ properties:
|
||||
avatar_url:
|
||||
type: string
|
||||
description: The url to a jpeg, png file for the contact avatar
|
||||
example: https://example.com/avatar.png
|
||||
identifier:
|
||||
type: string
|
||||
description: A unique identifier for the contact in external system
|
||||
example: '1234567890'
|
||||
additional_attributes:
|
||||
type: object
|
||||
description: An object where you can store additional attributes for contact. example {"type":"customer", "age":30}
|
||||
example: { 'type': 'customer', 'age': 30 }
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: An object where you can store custom attributes for contact. example {"type":"customer", "age":30}, this should have a valid custom attribute definition.
|
||||
example: {}
|
||||
description: An object where you can store custom attributes for contact. example {"type":"customer", "age":30}
|
||||
@@ -1,44 +0,0 @@
|
||||
type: object
|
||||
required:
|
||||
- inbox_id
|
||||
properties:
|
||||
inbox_id:
|
||||
type: number
|
||||
description: ID of the inbox to which the contact belongs
|
||||
example: 1
|
||||
name:
|
||||
type: string
|
||||
description: name of the contact
|
||||
example: Alice
|
||||
email:
|
||||
type: string
|
||||
description: email of the contact
|
||||
example: alice@acme.inc
|
||||
blocked:
|
||||
type: boolean
|
||||
description: whether the contact is blocked or not
|
||||
example: false
|
||||
phone_number:
|
||||
type: string
|
||||
description: phone number of the contact
|
||||
example: '+123456789'
|
||||
avatar:
|
||||
type: string
|
||||
format: binary
|
||||
description: Send the form data with the avatar image binary or use the avatar_url
|
||||
avatar_url:
|
||||
type: string
|
||||
description: The url to a jpeg, png file for the contact avatar
|
||||
example: https://example.com/avatar.png
|
||||
identifier:
|
||||
type: string
|
||||
description: A unique identifier for the contact in external system
|
||||
example: '1234567890'
|
||||
additional_attributes:
|
||||
type: object
|
||||
description: An object where you can store additional attributes for contact. example {"type":"customer", "age":30}
|
||||
example: { 'type': 'customer', 'age': 30 }
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: An object where you can store custom attributes for contact. example {"type":"customer", "age":30}, this should have a valid custom attribute definition.
|
||||
example: {}
|
||||
@@ -0,0 +1,25 @@
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: name of the contact
|
||||
email:
|
||||
type: string
|
||||
description: email of the contact
|
||||
phone_number:
|
||||
type: string
|
||||
description: phone number of the contact
|
||||
avatar:
|
||||
type: string
|
||||
format: binary
|
||||
description: Send the form data with the avatar image binary or use the avatar_url
|
||||
avatar_url:
|
||||
type: string
|
||||
description: The url to a jpeg, png file for the contact avatar
|
||||
identifier:
|
||||
type: string
|
||||
description: A unique identifier for the contact in external system
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: An object where you can store custom attributes for contact. example {"type":"customer", "age":30}
|
||||
|
||||
+7
-16
@@ -5,29 +5,20 @@ properties:
|
||||
content:
|
||||
type: string
|
||||
description: The content of the message
|
||||
example: 'Hello, how can I help you?'
|
||||
message_type:
|
||||
type: string
|
||||
enum: ['outgoing', 'incoming']
|
||||
description: The type of the message
|
||||
example: 'outgoing'
|
||||
private:
|
||||
type: boolean
|
||||
description: Flag to identify if it is a private note
|
||||
example: false
|
||||
content_type:
|
||||
type: string
|
||||
enum: ['text', 'input_email', 'cards', 'input_select', 'form', 'article']
|
||||
description: Content type of the message
|
||||
example: 'text'
|
||||
enum: ['text', 'input_email', 'cards', 'input_select', 'form' , 'article']
|
||||
example: 'cards'
|
||||
description: 'if you want to create custom message types'
|
||||
content_attributes:
|
||||
type: object
|
||||
description: Attributes based on the content type
|
||||
example: {}
|
||||
campaign_id:
|
||||
type: integer
|
||||
description: The campaign id to which the message belongs
|
||||
example: 1
|
||||
description: attributes based on your content type
|
||||
template_params:
|
||||
type: object
|
||||
description: The template params for the message in case of whatsapp Channel
|
||||
@@ -44,8 +35,8 @@ properties:
|
||||
type: string
|
||||
description: Language of the template
|
||||
example: en_US
|
||||
processed_params:
|
||||
processed_params:
|
||||
type: object
|
||||
description: The processed param values for template variables in template
|
||||
example:
|
||||
1: 'Chatwoot'
|
||||
example:
|
||||
1: "Chatwoot"
|
||||
@@ -1,79 +0,0 @@
|
||||
type: object
|
||||
required:
|
||||
- source_id
|
||||
- inbox_id
|
||||
properties:
|
||||
source_id:
|
||||
type: string
|
||||
description: Conversation source id
|
||||
example: '1234567890'
|
||||
inbox_id:
|
||||
type: integer
|
||||
description: 'Id of inbox in which the conversation is created <br/> Allowed Inbox Types: Website, Phone, Api, Email'
|
||||
example: 1
|
||||
contact_id:
|
||||
type: integer
|
||||
description: Contact Id for which conversation is created
|
||||
example: 1
|
||||
additional_attributes:
|
||||
type: object
|
||||
description: Lets you specify attributes like browser information
|
||||
example:
|
||||
{
|
||||
browser: 'Chrome',
|
||||
browser_version: '89.0.4389.82',
|
||||
os: 'Windows',
|
||||
os_version: '10',
|
||||
}
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: The object to save custom attributes for conversation, accepts custom attributes key and value
|
||||
example: { attribute_key: attribute_value, priority_conversation_number: 3 }
|
||||
status:
|
||||
type: string
|
||||
enum: ['open', 'resolved', 'pending']
|
||||
description: Specify the conversation whether it's pending, open, closed
|
||||
example: open
|
||||
assignee_id:
|
||||
type: integer
|
||||
description: Agent Id for assigning a conversation to an agent
|
||||
example: 1
|
||||
team_id:
|
||||
type: integer
|
||||
description: Team Id for assigning a conversation to a team\
|
||||
example: 1
|
||||
snoozed_until:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Snoozed until date time
|
||||
example: '2030-07-21T17:32:28Z'
|
||||
message:
|
||||
type: object
|
||||
description: The initial message to be sent to the conversation
|
||||
required: ['content']
|
||||
properties:
|
||||
content:
|
||||
type: string
|
||||
description: The content of the message
|
||||
example: 'Hello, how can I help you?'
|
||||
template_params:
|
||||
type: object
|
||||
description: The template params for the message in case of whatsapp Channel
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: Name of the template
|
||||
example: 'sample_issue_resolution'
|
||||
category:
|
||||
type: string
|
||||
description: Category of the template
|
||||
example: UTILITY
|
||||
language:
|
||||
type: string
|
||||
description: Language of the template
|
||||
example: en_US
|
||||
processed_params:
|
||||
type: object
|
||||
description: The processed param values for template variables in template
|
||||
example:
|
||||
1: 'Chatwoot'
|
||||
@@ -3,34 +3,20 @@ properties:
|
||||
attribute_display_name:
|
||||
type: string
|
||||
description: Attribute display name
|
||||
example: 'Custom Attribute'
|
||||
attribute_display_type:
|
||||
type: integer
|
||||
description: Attribute display type (text- 0, number- 1, currency- 2, percent- 3, link- 4, date- 5, list- 6, checkbox- 7)
|
||||
example: 0
|
||||
attribute_description:
|
||||
type: string
|
||||
description: Attribute description
|
||||
example: 'This is a custom attribute'
|
||||
attribute_key:
|
||||
type: string
|
||||
description: Attribute unique key value
|
||||
example: 'custom_attribute'
|
||||
attribute_values:
|
||||
type: array
|
||||
description: Attribute values
|
||||
items:
|
||||
type: string
|
||||
example: ['value1', 'value2']
|
||||
attribute_model:
|
||||
type: integer
|
||||
description: Attribute type(conversation_attribute- 0, contact_attribute- 1)
|
||||
example: 0
|
||||
regex_pattern:
|
||||
type: string
|
||||
description: Regex pattern (Only applicable for type- text). The regex pattern is used to validate the attribute value(s).
|
||||
example: '^[a-zA-Z0-9]+$'
|
||||
regex_cue:
|
||||
type: string
|
||||
description: Regex cue message (Only applicable for type- text). The cue message is shown when the regex pattern is not matched.
|
||||
example: 'Please enter a valid value'
|
||||
|
||||
@@ -3,13 +3,10 @@ properties:
|
||||
name:
|
||||
type: string
|
||||
description: The name of the custom filter
|
||||
example: 'My Custom Filter'
|
||||
type:
|
||||
type: string
|
||||
enum: ['conversation', 'contact', 'report']
|
||||
enum: ["conversation", "contact", "report"]
|
||||
description: The description about the custom filter
|
||||
example: 'conversation'
|
||||
query:
|
||||
type: object
|
||||
description: A query that needs to be saved as a custom filter
|
||||
example: {}
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: The name of the inbox
|
||||
example: 'Support'
|
||||
avatar:
|
||||
type: string
|
||||
format: binary
|
||||
description: Image file for avatar
|
||||
greeting_enabled:
|
||||
type: boolean
|
||||
description: Enable greeting message
|
||||
example: true
|
||||
greeting_message:
|
||||
type: string
|
||||
description: Greeting message to be displayed on the widget
|
||||
example: Hello, how can I help you?
|
||||
enable_email_collect:
|
||||
type: boolean
|
||||
description: Enable email collection
|
||||
example: true
|
||||
csat_survey_enabled:
|
||||
type: boolean
|
||||
description: Enable CSAT survey
|
||||
example: true
|
||||
enable_auto_assignment:
|
||||
type: boolean
|
||||
description: Enable Auto Assignment
|
||||
example: true
|
||||
working_hours_enabled:
|
||||
type: boolean
|
||||
description: Enable working hours
|
||||
example: true
|
||||
out_of_office_message:
|
||||
type: string
|
||||
description: Out of office message to be displayed on the widget
|
||||
example: We are currently out of office. Please leave a message and we will get back to you.
|
||||
timezone:
|
||||
type: string
|
||||
description: Timezone of the inbox
|
||||
example: 'America/New_York'
|
||||
allow_messages_after_resolved:
|
||||
type: boolean
|
||||
description: Allow messages after conversation is resolved
|
||||
example: true
|
||||
lock_to_single_conversation:
|
||||
type: boolean
|
||||
description: Lock to single conversation
|
||||
example: true
|
||||
portal_id:
|
||||
type: integer
|
||||
description: Id of the help center portal to attach to the inbox
|
||||
example: 1
|
||||
sender_name_type:
|
||||
type: string
|
||||
description: Sender name type for the inbox
|
||||
enum: ['friendly', 'professional']
|
||||
example: 'friendly'
|
||||
business_name:
|
||||
type: string
|
||||
description: Business name for the inbox
|
||||
example: 'My Business'
|
||||
channel:
|
||||
type: object
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
description: Type of the channel
|
||||
enum:
|
||||
['web_widget', 'api', 'email', 'line', 'telegram', 'whatsapp', 'sms']
|
||||
example: web_widget
|
||||
website_url:
|
||||
type: string
|
||||
description: URL at which the widget will be loaded
|
||||
example: 'https://example.com'
|
||||
welcome_title:
|
||||
type: string
|
||||
description: Welcome title to be displayed on the widget
|
||||
example: 'Welcome to our support'
|
||||
welcome_tagline:
|
||||
type: string
|
||||
description: Welcome tagline to be displayed on the widget
|
||||
example: 'We are here to help you'
|
||||
widget_color:
|
||||
type: string
|
||||
description: A Hex-color string used to customize the widget
|
||||
example: '#FF5733'
|
||||
@@ -1,82 +0,0 @@
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: The name of the inbox
|
||||
example: 'Support'
|
||||
avatar:
|
||||
type: string
|
||||
format: binary
|
||||
description: Image file for avatar
|
||||
greeting_enabled:
|
||||
type: boolean
|
||||
description: Enable greeting message
|
||||
example: true
|
||||
greeting_message:
|
||||
type: string
|
||||
description: Greeting message to be displayed on the widget
|
||||
example: Hello, how can I help you?
|
||||
enable_email_collect:
|
||||
type: boolean
|
||||
description: Enable email collection
|
||||
example: true
|
||||
csat_survey_enabled:
|
||||
type: boolean
|
||||
description: Enable CSAT survey
|
||||
example: true
|
||||
enable_auto_assignment:
|
||||
type: boolean
|
||||
description: Enable Auto Assignment
|
||||
example: true
|
||||
working_hours_enabled:
|
||||
type: boolean
|
||||
description: Enable working hours
|
||||
example: true
|
||||
out_of_office_message:
|
||||
type: string
|
||||
description: Out of office message to be displayed on the widget
|
||||
example: We are currently out of office. Please leave a message and we will get back to you.
|
||||
timezone:
|
||||
type: string
|
||||
description: Timezone of the inbox
|
||||
example: 'America/New_York'
|
||||
allow_messages_after_resolved:
|
||||
type: boolean
|
||||
description: Allow messages after conversation is resolved
|
||||
example: true
|
||||
lock_to_single_conversation:
|
||||
type: boolean
|
||||
description: Lock to single conversation
|
||||
example: true
|
||||
portal_id:
|
||||
type: integer
|
||||
description: Id of the help center portal to attach to the inbox
|
||||
example: 1
|
||||
sender_name_type:
|
||||
type: string
|
||||
description: Sender name type for the inbox
|
||||
enum: ['friendly', 'professional']
|
||||
example: 'friendly'
|
||||
business_name:
|
||||
type: string
|
||||
description: Business name for the inbox
|
||||
example: 'My Business'
|
||||
channel:
|
||||
type: object
|
||||
properties:
|
||||
website_url:
|
||||
type: string
|
||||
description: URL at which the widget will be loaded
|
||||
example: 'https://example.com'
|
||||
welcome_title:
|
||||
type: string
|
||||
description: Welcome title to be displayed on the widget
|
||||
example: 'Welcome to our support'
|
||||
welcome_tagline:
|
||||
type: string
|
||||
description: Welcome tagline to be displayed on the widget
|
||||
example: 'We are here to help you'
|
||||
widget_color:
|
||||
type: string
|
||||
description: A Hex-color string used to customize the widget
|
||||
example: '#FF5733'
|
||||
@@ -1,18 +1,11 @@
|
||||
type: object
|
||||
properties:
|
||||
app_id:
|
||||
type: integer
|
||||
type: string
|
||||
description: The ID of app for which integration hook is being created
|
||||
example: 1
|
||||
inbox_id:
|
||||
type: integer
|
||||
type: string
|
||||
description: The inbox ID, if the hook is an inbox hook
|
||||
example: 1
|
||||
status:
|
||||
type: integer
|
||||
description: The status of the integration (0 for inactive, 1 for active)
|
||||
example: 1
|
||||
settings:
|
||||
type: object
|
||||
description: The settings required by the integration
|
||||
example: {}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
type: object
|
||||
properties:
|
||||
status:
|
||||
type: integer
|
||||
description: The status of the integration (0 for inactive, 1 for active)
|
||||
example: 1
|
||||
settings:
|
||||
type: object
|
||||
description: The settings required by the integration
|
||||
example: {}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: The name of the agent bot
|
||||
example: 'My Agent Bot'
|
||||
description:
|
||||
type: string
|
||||
description: The description of the agent bot
|
||||
example: 'This is a sample agent bot'
|
||||
outgoing_url:
|
||||
type: string
|
||||
description: The webhook URL for the bot
|
||||
example: 'https://example.com/webhook'
|
||||
account_id:
|
||||
type: integer
|
||||
description: The account ID to associate the agent bot with
|
||||
example: 1
|
||||
avatar:
|
||||
type: string
|
||||
format: binary
|
||||
description: Send the form data with the avatar image binary or use the avatar_url
|
||||
avatar_url:
|
||||
type: string
|
||||
description: The url to a jpeg, png file for the agent bot avatar
|
||||
example: https://example.com/avatar.png
|
||||
@@ -1,51 +1,34 @@
|
||||
type: object
|
||||
properties:
|
||||
title:
|
||||
type: string
|
||||
description: The title of the article
|
||||
example: 'Article Title'
|
||||
slug:
|
||||
type: string
|
||||
description: The slug of the article
|
||||
example: 'article-title'
|
||||
position:
|
||||
type: integer
|
||||
description: article position in category
|
||||
example: 1
|
||||
content:
|
||||
type: string
|
||||
description: The text content.
|
||||
example: 'This is the content of the article'
|
||||
description:
|
||||
type: string
|
||||
description: The description of the article
|
||||
example: 'This is the description of the article'
|
||||
category_id:
|
||||
type: integer
|
||||
description: The category id of the article
|
||||
example: 1
|
||||
author_id:
|
||||
type: integer
|
||||
description: The author agent id of the article
|
||||
example: 1
|
||||
associated_article_id:
|
||||
type: integer
|
||||
description: To associate similar articles to each other, e.g to provide the link for the reference.
|
||||
example: 2
|
||||
status:
|
||||
type: integer
|
||||
description: The status of the article. 0 for draft, 1 for published, 2 for archived
|
||||
example: 1
|
||||
locale:
|
||||
type: string
|
||||
description: The locale of the article
|
||||
example: 'en'
|
||||
meta:
|
||||
type: object
|
||||
description: Use for search
|
||||
example:
|
||||
{
|
||||
tags: ['article_name'],
|
||||
title: 'article title',
|
||||
description: 'article description',
|
||||
}
|
||||
example: { tags: ['article_name'], title: 'article title', description: 'article description' }
|
||||
position:
|
||||
type: integer
|
||||
description: article position in category
|
||||
status:
|
||||
type: integer
|
||||
example: ['draft', 'published', 'archived']
|
||||
title:
|
||||
type: string
|
||||
slug:
|
||||
type: string
|
||||
views:
|
||||
type: integer
|
||||
portal_id:
|
||||
type: integer
|
||||
account_id:
|
||||
type: integer
|
||||
author_id:
|
||||
type: integer
|
||||
category_id:
|
||||
type: integer
|
||||
folder_id:
|
||||
type: integer
|
||||
associated_article_id:
|
||||
type: integer
|
||||
description: To associate similar articles to each other, e.g to provide the link for the reference.
|
||||
|
||||
@@ -1,34 +1,28 @@
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: The name of the category
|
||||
example: 'Category Name'
|
||||
description:
|
||||
type: string
|
||||
description: A description for the category
|
||||
example: 'Category description'
|
||||
description: Category description
|
||||
locale:
|
||||
type: string
|
||||
description: Category locale
|
||||
example: en/es
|
||||
name:
|
||||
type: string
|
||||
description: Category name
|
||||
slug:
|
||||
type: string
|
||||
description: Category slug
|
||||
position:
|
||||
type: integer
|
||||
description: Category position in the portal list to sort
|
||||
example: 1
|
||||
slug:
|
||||
type: string
|
||||
description: The category slug used in the URL
|
||||
example: 'category-name'
|
||||
locale:
|
||||
type: string
|
||||
description: The locale of the category
|
||||
example: en
|
||||
icon:
|
||||
type: string
|
||||
description: The icon of the category as a string (emoji)
|
||||
example: '📚'
|
||||
parent_category_id:
|
||||
portal_id:
|
||||
type: integer
|
||||
account_id:
|
||||
type: integer
|
||||
description: To define parent category, e.g product documentation has multiple level features in sales category or in engineering category.
|
||||
example: 1
|
||||
associated_category_id:
|
||||
type: integer
|
||||
description: To associate similar categories to each other, e.g same category of product documentation in different languages
|
||||
example: 2
|
||||
parent_category_id:
|
||||
type: integer
|
||||
description: To define parent category, e.g product documentation has multiple level features in sales category or in engineering category.
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
type: object
|
||||
properties:
|
||||
archived:
|
||||
type: boolean
|
||||
description: Status to check if portal is live
|
||||
color:
|
||||
type: string
|
||||
description: Header color for help-center in hex format
|
||||
example: '#FFFFFF'
|
||||
description: Header color for help-center
|
||||
example: add color HEX string, "#fffff"
|
||||
config:
|
||||
type: object
|
||||
description: Configuration about supporting locales
|
||||
example: { allowed_locales: ['en', 'es'], default_locale: 'en' }
|
||||
custom_domain:
|
||||
type: string
|
||||
description: Custom domain to display help center.
|
||||
example: chatwoot.help
|
||||
description: Custom domain to display help center.
|
||||
example: https://chatwoot.help/.
|
||||
header_text:
|
||||
type: string
|
||||
description: Help center header
|
||||
@@ -19,20 +26,11 @@ properties:
|
||||
name:
|
||||
type: string
|
||||
description: Name for the portal
|
||||
example: Handbook
|
||||
page_title:
|
||||
type: string
|
||||
description: Page title for the portal
|
||||
example: Handbook
|
||||
slug:
|
||||
type: string
|
||||
description: Slug for the portal to display in link
|
||||
example: handbook
|
||||
archived:
|
||||
type: boolean
|
||||
description: Status to check if portal is live
|
||||
example: false
|
||||
config:
|
||||
type: object
|
||||
description: Configuration about supporting locales
|
||||
example: { allowed_locales: ['en', 'es'], default_locale: 'en' }
|
||||
page_title:
|
||||
type: string
|
||||
description: Page title for the portal
|
||||
account_id:
|
||||
type: integer
|
||||
|
||||
@@ -1,30 +1,24 @@
|
||||
|
||||
type: object
|
||||
properties:
|
||||
identifier:
|
||||
type: string
|
||||
description: External identifier of the contact
|
||||
example: '1234567890'
|
||||
identifier_hash:
|
||||
type: string
|
||||
description: Identifier hash prepared for HMAC authentication
|
||||
example: 'e93275d4eba0e5679ad55f5360af00444e2a888df9b0afa3e8b691c3173725f9'
|
||||
email:
|
||||
type: string
|
||||
description: Email of the contact
|
||||
example: alice@acme.inc
|
||||
name:
|
||||
type: string
|
||||
description: Name of the contact
|
||||
example: Alice
|
||||
phone_number:
|
||||
type: string
|
||||
description: Phone number of the contact
|
||||
example: '+123456789'
|
||||
avatar:
|
||||
avatar_url:
|
||||
type: string
|
||||
format: binary
|
||||
description: Send the form data with the avatar image binary or use the avatar_url
|
||||
description: The url to a jpeg, png file for the user avatar
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: Custom attributes of the customer
|
||||
example: {}
|
||||
description: Custom attributes of the customer
|
||||
@@ -3,4 +3,3 @@ properties:
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: Custom attributes of the conversation
|
||||
example: {}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
type: object
|
||||
properties:
|
||||
content:
|
||||
type: string
|
||||
description: Content for the message
|
||||
example: 'Hello, how can I help you?'
|
||||
echo_id:
|
||||
type: string
|
||||
description: Temporary identifier which will be passed back via websockets
|
||||
example: '1234567890'
|
||||
|
||||
@@ -1,30 +1,6 @@
|
||||
|
||||
type: object
|
||||
properties:
|
||||
submitted_values:
|
||||
type: object
|
||||
description: Replies to the Bot Message Types
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: The name of the submiitted value
|
||||
example: 'My Name'
|
||||
title:
|
||||
type: string
|
||||
description: The title of the submitted value
|
||||
example: 'My Title'
|
||||
value:
|
||||
type: string
|
||||
description: The value of the submitted value
|
||||
example: 'value'
|
||||
csat_survey_response:
|
||||
type: object
|
||||
description: The CSAT survey response
|
||||
properties:
|
||||
feedback_message:
|
||||
type: string
|
||||
description: The feedback message of the CSAT survey response
|
||||
example: 'Great service!'
|
||||
rating:
|
||||
type: integer
|
||||
description: The rating of the CSAT survey response
|
||||
example: 5
|
||||
description: Replies to the Bot Message Types
|
||||
@@ -3,12 +3,9 @@ properties:
|
||||
name:
|
||||
type: string
|
||||
description: The name of the team
|
||||
example: Support Team
|
||||
description:
|
||||
type: string
|
||||
description: The description of the team
|
||||
example: This is a team of support agents
|
||||
allow_auto_assign:
|
||||
type: boolean
|
||||
description: If this setting is turned on, the system would automatically assign the conversation to an agent in the team while assigning the conversation to a team
|
||||
example: true
|
||||
|
||||
@@ -3,20 +3,13 @@ properties:
|
||||
name:
|
||||
type: string
|
||||
description: Name of the user
|
||||
example: 'Daniel'
|
||||
display_name:
|
||||
type: string
|
||||
description: Display name of the user
|
||||
example: 'Dan'
|
||||
email:
|
||||
type: string
|
||||
description: Email of the user
|
||||
example: 'daniel@acme.inc'
|
||||
password:
|
||||
type: string
|
||||
description: Password must contain uppercase, lowercase letters, number and a special character
|
||||
example: 'Password2!'
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: Custom attributes you want to associate with the user
|
||||
example: {}
|
||||
|
||||
|
||||
@@ -3,23 +3,16 @@ properties:
|
||||
url:
|
||||
type: string
|
||||
description: The url where the events should be sent
|
||||
example: https://example.com/webhook
|
||||
subscriptions:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
enum:
|
||||
[
|
||||
'conversation_created',
|
||||
'conversation_status_changed',
|
||||
'conversation_updated',
|
||||
'message_created',
|
||||
'message_updated',
|
||||
'contact_created',
|
||||
'contact_updated',
|
||||
'webwidget_triggered',
|
||||
]
|
||||
enum: [
|
||||
"conversation_created",
|
||||
"conversation_status_changed",
|
||||
"conversation_updated",
|
||||
"message_created",
|
||||
"message_updated",
|
||||
"webwidget_triggered"
|
||||
]
|
||||
description: The events you want to subscribe to.
|
||||
example:
|
||||
- conversation_created
|
||||
- conversation_status_changed
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
type: array
|
||||
description: 'Array of account users'
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
account_id:
|
||||
type: integer
|
||||
description: The ID of the account
|
||||
user_id:
|
||||
type: integer
|
||||
description: The ID of the user
|
||||
role:
|
||||
type: string
|
||||
description: whether user is an administrator or agent
|
||||
@@ -2,34 +2,31 @@ type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
uid:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
available_name:
|
||||
type: string
|
||||
display_name:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
account_id:
|
||||
type: integer
|
||||
availability_status:
|
||||
role:
|
||||
type: string
|
||||
enum: ['agent', 'administrator']
|
||||
confirmed:
|
||||
type: boolean
|
||||
availability_status:
|
||||
type: string
|
||||
enum: ['available', 'busy', 'offline']
|
||||
description: The availability status of the agent computed by Chatwoot.
|
||||
auto_offline:
|
||||
type: boolean
|
||||
description: Whether the availability status of agent is configured to go offline automatically when away.
|
||||
confirmed:
|
||||
type: boolean
|
||||
description: Whether the agent has confirmed their email address.
|
||||
email:
|
||||
type: string
|
||||
description: The email of the agent
|
||||
available_name:
|
||||
type: string
|
||||
description: The available name of the agent
|
||||
name:
|
||||
type: string
|
||||
description: The name of the agent
|
||||
role:
|
||||
type: string
|
||||
enum: ['agent', 'administrator']
|
||||
description: The role of the agent
|
||||
thumbnail:
|
||||
type: string
|
||||
description: The thumbnail of the agent
|
||||
custom_role_id:
|
||||
type: integer
|
||||
description: The custom role id of the agent
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: Available for users who are created through platform APIs and has custom attributes associated.
|
||||
|
||||
|
||||
@@ -9,24 +9,9 @@ properties:
|
||||
description:
|
||||
type: string
|
||||
description: The description about the agent bot
|
||||
thumbnail:
|
||||
type: string
|
||||
description: The thumbnail of the agent bot
|
||||
outgoing_url:
|
||||
type: string
|
||||
description: The webhook URL for the bot
|
||||
bot_type:
|
||||
type: string
|
||||
description: The type of the bot
|
||||
bot_config:
|
||||
type: object
|
||||
description: The configuration of the bot
|
||||
account_id:
|
||||
type: number
|
||||
description: Account ID if it's an account specific bot
|
||||
access_token:
|
||||
outgoing_url:
|
||||
type: string
|
||||
description: The access token for the bot
|
||||
system_bot:
|
||||
type: boolean
|
||||
description: Whether the bot is a system bot
|
||||
description: The webhook URL for the bot
|
||||
|
||||
@@ -1,13 +1,45 @@
|
||||
type: object
|
||||
properties:
|
||||
payload:
|
||||
description: Response payload that contains automation rule(s)
|
||||
oneOf:
|
||||
- type: array
|
||||
description: Array of automation rules (for listing endpoint)
|
||||
items:
|
||||
$ref: '#/components/schemas/automation_rule_item'
|
||||
- type: object
|
||||
description: Single automation rule (for show/create/update endpoints)
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/automation_rule_item'
|
||||
event_name:
|
||||
type: string
|
||||
description: Automation Rule event, on which we call the actions(conversation_created, conversation_updated, message_created)
|
||||
enum:
|
||||
- conversation_created
|
||||
- conversation_updated
|
||||
- message_created
|
||||
example: message_created
|
||||
name:
|
||||
type: string
|
||||
description: The name of the rule
|
||||
example: Add label on message create event
|
||||
description:
|
||||
type: string
|
||||
description: Description to give more context about the rule
|
||||
example: Add label support and sales on message create event if incoming message content contains text help
|
||||
active:
|
||||
type: boolean
|
||||
description: Enable/disable automation rule
|
||||
actions:
|
||||
type: array
|
||||
description: Array of actions which we perform when condition matches
|
||||
items:
|
||||
type: object
|
||||
example:
|
||||
action_name: add_label
|
||||
action_params:
|
||||
- support
|
||||
- sales
|
||||
conditions:
|
||||
type: array
|
||||
description: Array of conditions on which conversation/message filter would work
|
||||
items:
|
||||
type: object
|
||||
example:
|
||||
attribute_key: content
|
||||
filter_operator: contains
|
||||
values:
|
||||
- help
|
||||
query_operator: nil
|
||||
account_id:
|
||||
type: integer
|
||||
description: Account Id
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
description: The ID of the automation rule
|
||||
account_id:
|
||||
type: integer
|
||||
description: Account Id
|
||||
name:
|
||||
type: string
|
||||
description: The name of the rule
|
||||
example: Add label on message create event
|
||||
description:
|
||||
type: string
|
||||
description: Description to give more context about the rule
|
||||
example: Add label support and sales on message create event if incoming message content contains text help
|
||||
event_name:
|
||||
type: string
|
||||
description: Automation Rule event, on which we call the actions(conversation_created, conversation_updated, message_created)
|
||||
enum:
|
||||
- conversation_created
|
||||
- conversation_updated
|
||||
- message_created
|
||||
example: message_created
|
||||
conditions:
|
||||
type: array
|
||||
description: Array of conditions on which conversation/message filter would work
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
values:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
attribute_key:
|
||||
type: string
|
||||
query_operator:
|
||||
type: string
|
||||
filter_operator:
|
||||
type: string
|
||||
example:
|
||||
attribute_key: content
|
||||
filter_operator: contains
|
||||
values:
|
||||
- help
|
||||
query_operator: and
|
||||
actions:
|
||||
type: array
|
||||
description: Array of actions which we perform when condition matches
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
action_name:
|
||||
type: string
|
||||
action_params:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
example:
|
||||
action_name: add_label
|
||||
action_params:
|
||||
- support
|
||||
- sales
|
||||
created_on:
|
||||
type: integer
|
||||
description: The timestamp when the rule was created
|
||||
active:
|
||||
type: boolean
|
||||
description: Enable/disable automation rule
|
||||
@@ -3,18 +3,12 @@ properties:
|
||||
id:
|
||||
type: integer
|
||||
description: ID of the canned response
|
||||
account_id:
|
||||
type: integer
|
||||
description: Account Id
|
||||
short_code:
|
||||
type: string
|
||||
description: Short Code for quick access of the canned response
|
||||
content:
|
||||
type: string
|
||||
description: Message content for canned response
|
||||
created_at:
|
||||
short_code:
|
||||
type: string
|
||||
description: The date and time when the canned response was created
|
||||
updated_at:
|
||||
type: string
|
||||
description: The date and time when the canned response was updated
|
||||
description: Short Code for quick access of the canned response
|
||||
account_id:
|
||||
type: integer
|
||||
description: Account Id
|
||||
|
||||
@@ -1,49 +1,31 @@
|
||||
type: object
|
||||
properties:
|
||||
payload:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
additional_attributes:
|
||||
type: object
|
||||
description: The object containing additional attributes related to the contact
|
||||
availability_status:
|
||||
type: string
|
||||
description: The availability status of the contact
|
||||
email:
|
||||
type: string
|
||||
description: The email address of the contact
|
||||
id:
|
||||
type: integer
|
||||
description: The ID of the contact
|
||||
name:
|
||||
type: string
|
||||
description: The name of the contact
|
||||
phone_number:
|
||||
type: string
|
||||
description: The phone number of the contact
|
||||
blocked:
|
||||
type: boolean
|
||||
description: Whether the contact is blocked
|
||||
identifier:
|
||||
type: string
|
||||
description: The identifier of the contact
|
||||
thumbnail:
|
||||
type: string
|
||||
description: The thumbnail of the contact
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: The custom attributes of the contact
|
||||
example:
|
||||
{ attribute_key: attribute_value, signed_up_at: dd/mm/yyyy }
|
||||
last_activity_at:
|
||||
type: integer
|
||||
description: The last activity at of the contact
|
||||
created_at:
|
||||
type: integer
|
||||
description: The created at of the contact
|
||||
contact_inboxes:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/contact_inboxes'
|
||||
type: object
|
||||
properties:
|
||||
contact:
|
||||
type: object
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
description: Email address of the contact
|
||||
name:
|
||||
type: string
|
||||
description: The name of the contact
|
||||
phone_number:
|
||||
type: string
|
||||
description: Phone number of the contact
|
||||
thumbnail:
|
||||
type: string
|
||||
description: Avatar URL of the contact
|
||||
additional_attributes:
|
||||
type: object
|
||||
description: The object containing additional attributes related to the contact
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: The object to save custom attributes for contact, accepts custom attributes key and value
|
||||
example: { attribute_key: attribute_value, signed_up_at: dd/mm/yyyy }
|
||||
contact_inboxes:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/contact_inboxes'
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
description: ID of the message
|
||||
content:
|
||||
type: string
|
||||
description: Content of the message
|
||||
account_id:
|
||||
type: integer
|
||||
description: ID of the account
|
||||
inbox_id:
|
||||
type: integer
|
||||
description: ID of the inbox
|
||||
conversation_id:
|
||||
type: integer
|
||||
description: ID of the conversation
|
||||
message_type:
|
||||
type: integer
|
||||
description: Type of the message
|
||||
created_at:
|
||||
type: integer
|
||||
description: Timestamp when message was created
|
||||
updated_at:
|
||||
type: string
|
||||
description: Formatted datetime when message was updated
|
||||
private:
|
||||
type: boolean
|
||||
description: Whether the message is private
|
||||
status:
|
||||
type: string
|
||||
description: Status of the message
|
||||
source_id:
|
||||
type: string
|
||||
description: Source ID of the message
|
||||
nullable: true
|
||||
content_type:
|
||||
type: string
|
||||
description: Type of the content
|
||||
content_attributes:
|
||||
type: object
|
||||
description: Attributes of the content
|
||||
sender_type:
|
||||
type: string
|
||||
description: Type of the sender
|
||||
nullable: true
|
||||
sender_id:
|
||||
type: integer
|
||||
description: ID of the sender
|
||||
nullable: true
|
||||
external_source_ids:
|
||||
type: object
|
||||
description: External source IDs
|
||||
additional_attributes:
|
||||
type: object
|
||||
description: Additional attributes of the message
|
||||
processed_message_content:
|
||||
type: string
|
||||
description: Processed message content
|
||||
nullable: true
|
||||
sentiment:
|
||||
type: object
|
||||
description: Sentiment analysis of the message
|
||||
conversation:
|
||||
type: object
|
||||
description: Conversation details
|
||||
properties:
|
||||
assignee_id:
|
||||
type: integer
|
||||
description: ID of the assignee
|
||||
nullable: true
|
||||
unread_count:
|
||||
type: integer
|
||||
description: Count of unread messages
|
||||
last_activity_at:
|
||||
type: integer
|
||||
description: Timestamp of last activity
|
||||
contact_inbox:
|
||||
type: object
|
||||
description: Contact inbox details
|
||||
properties:
|
||||
source_id:
|
||||
type: string
|
||||
description: Source ID of the contact inbox
|
||||
sender:
|
||||
type: object
|
||||
description: Details of the sender
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
description: ID of the sender
|
||||
name:
|
||||
type: string
|
||||
description: Name of the sender
|
||||
available_name:
|
||||
type: string
|
||||
description: Available name of the sender
|
||||
avatar_url:
|
||||
type: string
|
||||
description: URL of the sender's avatar
|
||||
type:
|
||||
type: string
|
||||
description: Type of the sender
|
||||
availability_status:
|
||||
type: string
|
||||
description: Availability status of the sender
|
||||
thumbnail:
|
||||
type: string
|
||||
description: Thumbnail URL of the sender
|
||||
@@ -1,13 +0,0 @@
|
||||
type: object
|
||||
properties:
|
||||
payload:
|
||||
type: array
|
||||
items:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/conversation'
|
||||
- type: object
|
||||
properties:
|
||||
meta:
|
||||
$ref: './extension/contact/conversation.yml#/properties/meta'
|
||||
description: Meta information about the conversation
|
||||
description: List of conversations for the contact
|
||||
@@ -1,48 +0,0 @@
|
||||
type: object
|
||||
properties:
|
||||
additional_attributes:
|
||||
type: object
|
||||
description: The object containing additional attributes related to the contact
|
||||
properties:
|
||||
city:
|
||||
type: string
|
||||
description: City of the contact
|
||||
country:
|
||||
type: string
|
||||
description: Country of the contact
|
||||
country_code:
|
||||
type: string
|
||||
description: Country code of the contact
|
||||
created_at_ip:
|
||||
type: string
|
||||
description: IP address when the contact was created
|
||||
custom_attributes:
|
||||
type: object
|
||||
description: The custom attributes of the contact
|
||||
email:
|
||||
type: string
|
||||
description: The email address of the contact
|
||||
id:
|
||||
type: integer
|
||||
description: The ID of the contact
|
||||
identifier:
|
||||
type: string
|
||||
description: The identifier of the contact
|
||||
nullable: true
|
||||
name:
|
||||
type: string
|
||||
description: The name of the contact
|
||||
phone_number:
|
||||
type: string
|
||||
description: The phone number of the contact
|
||||
nullable: true
|
||||
thumbnail:
|
||||
type: string
|
||||
description: The thumbnail of the contact
|
||||
blocked:
|
||||
type: boolean
|
||||
description: Whether the contact is blocked
|
||||
type:
|
||||
type: string
|
||||
description: The type of entity
|
||||
enum: ["contact"]
|
||||
@@ -1,27 +0,0 @@
|
||||
type: object
|
||||
properties:
|
||||
source_id:
|
||||
type: string
|
||||
description: Source identifier for the contact inbox
|
||||
inbox:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
description: ID of the inbox
|
||||
avatar_url:
|
||||
type: string
|
||||
description: URL for the inbox avatar
|
||||
channel_id:
|
||||
type: integer
|
||||
description: ID of the channel
|
||||
name:
|
||||
type: string
|
||||
description: Name of the inbox
|
||||
channel_type:
|
||||
type: string
|
||||
description: Type of channel
|
||||
provider:
|
||||
type: string
|
||||
description: Provider of the inbox
|
||||
nullable: true
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user