chatwoot / chatwoot

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬
https://www.chatwoot.com/help-center
Other
19.63k stars 3.12k forks source link

[CW-1551] feat: Chat GPT(OpenAI ) Integration with Chatwoot #6436

Closed Isratja45 closed 1 year ago

Isratja45 commented 1 year ago

integrate the conversational AI platform into Chatwoot

CW-1551

Christilut commented 1 year ago

I think the OP is a bit quick but how cool would it be if we could automatically feed the Chatwoot conversation content into your own OpenAI through their API (at the cost of the user). Combine that with feeding extra content like manuals, guides, forums and even Discord chats into OpenAI, the resulting ChatGPT conversations could be a really wonderful opener before handing a conversation off to an agent.

I'm sure other chat services are working real hard on exactly this idea so it would be great if Chatwoot can be ahead of the curve here!

Thoughts?

sojan-official commented 1 year ago

Spec

Exploring ideas for some of the potential implementations of these language models/APIs into Chatwoot.The OpenAI language models provide the following capabilities.

Ref: https://platform.openai.com/docs/introduction/next-steps https://platform.openai.com/docs/models/overview

We could explore building numerous product features leveraging these capabilities.

Text Completion

ref: https://platform.openai.com/docs/guides/completion/inserting-text

These APIs provide us with the option to build various capabilities, sentiment analysis, translations, summarisation etc.

Potential features

Chat completions

ref: https://platform.openai.com/docs/guides/chat

Suited for Agent Bots

OpenAI now has a very specific model, gpt-3.5-turbo which allows exploring the above-mentioned use cases with a Chat style API interface. examples use cases suggested by Open AI

This model is very cost-effective, but at the moment, it doesn't support fine-tuning.

Fine-tuning

ref: https://platform.openai.com/docs/guides/fine-tuning

GPT-3 has been pre-trained on a vast amount of text from the open internet. When given a prompt with just a few examples, it can often intuit what task you are trying to perform and generate a plausible completion. This is often called "few-shot learning."

Fine-tuning improves on few-shot learning by training on many more examples than can fit in the prompt, letting you achieve better results on a wide number of tasks. Once a model has been fine-tuned, you won't need to provide examples in the prompt anymore. This saves costs and enables lower-latency requests.

Fine tuning is not available for Chat GPT APIs

Embedding

https://platform.openai.com/docs/guides/embeddings/what-are-embeddings

Potentially useful for building features like improved versions of search , related conversations , automatic labelling etc

Speech to text

https://platform.openai.com/docs/guides/speech-to-text


Using the API

The openAI API endpoint is relatively straightforward to use with plain HTTP requests of the following format ref: https://platform.openai.com/docs/api-reference/making-requests

curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"model": "text-davinci-003", "prompt": "Say this is a test", "temperature": 0, "max_tokens": 7}'

Where the key parameters are the API_KEY for authorization and the prompt parameter, which dictates how the model responds to various queries.

There are also various libraries available for different language bindings.


Next Steps

JOduMonT commented 1 year ago

I think the OP is a bit quick bu

you tell me if it's too quick but BotPress already did it https://community.botpress.com/t/chatgpt-x-botpress-join-our-webinar-on-march-21st/301

happytapper commented 1 year ago

Could you do this using Zapier and a webhook? I have seen something similar done with High Level SMS. If you figure it out, let me know!

g0rducci commented 1 year ago

what is the best way to use chatgpt on chatwoot?

jiacheo commented 1 year ago

what is the best way to use chatgpt on chatwoot?

Currently you can create a agent bot connect the user to the GPT models. May be pre-fine-tuning is needed for your Business of customer's business.

g0rducci commented 1 year ago

what is the best way to use chatgpt on chatwoot?

Currently you can create a agent bot connect the user to the GPT models. May be pre-fine-tuning is needed for your Business of customer's business.

thank you very much, where i find him ? im searching in chatwoot website but i dont find anything related, thanks forr help me

g0rducci commented 1 year ago

what is the best way to use chatgpt on chatwoot?

Currently you can create a agent bot connect the user to the GPT models. May be pre-fine-tuning is needed for your Business of customer's business.

thank you

eremeye commented 1 year ago

I think the Reply Suggestions feature would be even more useful if it were generated based on information from internal knowledge bases.

While one possible solution could be to use Open AI Plugins, unfortunately this feature is currently not available through the API.

Another potential solution would be to build a custom language model application based on frameworks like LangChain and use retrieval augmented generation techniques to achieve this functionality. This would allow the application to retrieve information from the knowledge base and generate a relevant response to the user.

Refs: https://platform.openai.com/docs/plugins/introduction https://docs.langchain.com/docs/use-cases/qa-docs

sojan-official commented 1 year ago

Update: We are working on a text transformation feature at the moment as the first step for deeper integration.

ref: Rephrase Agent response. [Generate different copies, Change the tone of text into helpful, professional etc.], https://github.com/chatwoot/chatwoot/pull/6957

qkimchi commented 1 year ago

Already starting to see some other chats building this.

Eg you create an agent bot, feed it store information eg CMS, product info, blog posts and knowledge base, and it then answers questions about products, shipping, where is my order, and so forth on it's own using the information it has access to. If it can't answer them can then forward to live agent, or live agent can just take over, or contact form if no agent online.

harismateen commented 1 year ago

@sojan-official - Can I ask the plans for ChatGPT integration with Chatwoot?

Spec

Exploring ideas for some of the potential implementations of these language models/APIs into Chatwoot.The OpenAI language models provide the following capabilities.

Ref: https://platform.openai.com/docs/introduction/next-steps https://platform.openai.com/docs/models/overview

  • Text completion
  • Chat completion
  • Fine-tuning
  • Embeddings
  • Speech to text

We could explore building numerous product features leveraging these capabilities.

Text Completion

ref: https://platform.openai.com/docs/guides/completion/inserting-text

These APIs provide us with the option to build various capabilities, sentiment analysis, translations, summarisation etc.

Potential features

  • [ ] Reply Suggestions Auto-populated reply suggestions for agents generated via the Conversation context, which can be sent by the agent within a couple of clicks. Examples: Gmail / Linkedin reply suggestions
  • [ ] Autocomplete Suggestions Autocomplete suggestions while the agent is typing out the reply based on conversation context. examples: Gmail
  • [ ] Summarization Summarise the large conversation into a gist so that agents can educate themselves about the conversation context in a single glance. Examples: Google Chat conversation summary
  • [ ] Transformation Rephrase Conversations [Write different copies, Change the tone of text into helpful, professional etc.], Translate the text between languages etc.
  • [ ] Bots Bot support agents powered by ChatGPT/GPT3 APIs.
  • [ ] Text Expansion Write short notes or bullet points which will be expanded into full-fledged customer replies or support Center Articles. Examples: Notion AI
  • [ ] Sentiment Analysis System generated CSAT Ratings for conversations where the users haven't provided a feedback rating. This will help the administrators to improve the quality of support provided.

Chat completions

ref: https://platform.openai.com/docs/guides/chat

Suited for Agent Bots

OpenAI now has a very specific model, gpt-3.5-turbo which allows exploring the above-mentioned use cases with a Chat style API interface. examples use cases suggested by Open AI

  • Draft an email or other piece of writing
  • Write Python code
  • Answer questions about a set of documents
  • [ ] Create conversational agents : ( Create Bots in Chatwoot )
  • [ ] Give your software a natural language interface : ( Enhance capabilities of our command + k interface )
  • Tutor in a range of subjects
  • [ ] Translate languages
  • Simulate characters for video games and much more

This model is very cost-effective, but at the moment, it doesn't support fine-tuning.

Fine-tuning

ref: https://platform.openai.com/docs/guides/fine-tuning

GPT-3 has been pre-trained on a vast amount of text from the open internet. When given a prompt with just a few examples, it can often intuit what task you are trying to perform and generate a plausible completion. This is often called "few-shot learning."

Fine-tuning improves on few-shot learning by training on many more examples than can fit in the prompt, letting you achieve better results on a wide number of tasks. Once a model has been fine-tuned, you won't need to provide examples in the prompt anymore. This saves costs and enables lower-latency requests.

  • These APIs will allow us to fine-tune the model with data specific to the customer so that we can provide more accurate AI responses.

Fine tuning is not available for Chat GPT APIs

Embedding

https://platform.openai.com/docs/guides/embeddings/what-are-embeddings

Potentially useful for building features like improved versions of search , related conversations , automatic labelling etc

Speech to text

https://platform.openai.com/docs/guides/speech-to-text

  • [ ] Generate transcriptions for audio messages in Chatwoot so that agents can quickly glance at the summary without listening to the whole audio.
  • [ ] Will be helpful for features like conversation summarization in case of conversations with audio messages

Using the API

The openAI API endpoint is relatively straightforward to use with plain HTTP requests of the following format ref: https://platform.openai.com/docs/api-reference/making-requests

curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"model": "text-davinci-003", "prompt": "Say this is a test", "temperature": 0, "max_tokens": 7}'

Where the key parameters are the API_KEY for authorization and the prompt parameter, which dictates how the model responds to various queries.

There are also various libraries available for different language bindings.

Next Steps

  • [ ] Add a GPT Integration to the integration page so that customers can configure their OpenAI API keys into Chatwoot
  • [ ] Identify the UI/UX for these features. A lot the features in text completion could be baked into our editor component.
  • [ ] Pick out specific use cases into separate issues, prototype / build the features
sojan-official commented 1 year ago

Update: We have added a reply suggestion and conversation summary option as well. These features will be available on chatwoot cloud already and will be available in the v2.17.0 release.

ref: https://github.com/chatwoot/chatwoot/pull/7029

Here is a quick preview of the functionality:

https://github.com/chatwoot/chatwoot/assets/73185/5a463be2-b5bb-4a98-bc35-b4614511d927

caoramos commented 1 year ago

Great feature! But there is a issue with usage besides English Language. What is happening is that some replies and the summarize function is returning always in english, besides the conversation language. What I suggest is that in prompt you should include the commando to output in X language, being X the language set by the admin. That will fix all issues with usage worldwide. That command should be inserted in all prompts.

That issue is happening because the prompt is being made in code in english and usually the OpenAi API will return in the prompt language, or the language sent and command in prompt.

sojan-official commented 1 year ago

Great feature! But there is a issue with usage besides English Language. What is happening is that some replies and the summarize function is returning always in english, besides the conversation language. What I suggest is that in prompt you should include the commando to output in X language, being X the language set by the admin. That will fix all issues with usage worldwide. That command should be inserted in all prompts.

That issue is happening because the prompt is being made in code in english and usually the OpenAi API will return in the prompt language, or the language sent and command in prompt.

will be fixed in : https://github.com/chatwoot/chatwoot/pull/7092

sojan-official commented 1 year ago

ref: https://github.com/chatwoot/chatwoot/pull/7162

Generate embedding on support articles to be passed as context for GPT-based Chatbot

sojan-official commented 1 year ago

Closing this issue since we have the integration in place. We will take further enhancements for the integration in subsequent issues.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.