mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-22 14:05:23 +00:00
Add `reply_suggestions` and `summary_generation` options for OpenAI integration Fixes: https://linear.app/chatwoot/issue/CW-1595/frontend-for-generating-conversation-summary Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Co-authored-by: Sojan Jose <sojan@pepalo.com>
32 lines
618 B
JavaScript
32 lines
618 B
JavaScript
/* global axios */
|
|
|
|
import ApiClient from '../ApiClient';
|
|
|
|
class OpenAIAPI extends ApiClient {
|
|
constructor() {
|
|
super('integrations', { accountScoped: true });
|
|
}
|
|
|
|
processEvent({ type = 'rephrase', content, tone, conversationId, hookId }) {
|
|
let data = {
|
|
tone,
|
|
content,
|
|
};
|
|
|
|
if (type === 'reply_suggestion' || type === 'summarize') {
|
|
data = {
|
|
conversation_display_id: conversationId,
|
|
};
|
|
}
|
|
|
|
return axios.post(`${this.url}/hooks/${hookId}/process_event`, {
|
|
event: {
|
|
name: type,
|
|
data,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|
|
export default new OpenAIAPI();
|