Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Closed
Isratja45 opened this issue Feb 11, 2023 · 18 comments
Closed

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

Isratja45 opened this issue Feb 11, 2023 · 18 comments
Assignees
Labels

Comments

@Isratja45
Copy link

Isratja45 commented Feb 11, 2023

integrate the conversational AI platform into Chatwoot

CW-1551

@Christilut
Copy link

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 sojan-official changed the title OpenAI + Chatwoot built by OpenAI, ChatGPT is amazing. feat: Chat GPT(OpenAI ) Integration with Chatwoot Mar 7, 2023
@sojan-official
Copy link
Member

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

@JOduMonT
Copy link

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
Copy link

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
Copy link

what is the best way to use chatgpt on chatwoot?

@jiacheo
Copy link

jiacheo commented Mar 28, 2023

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
Copy link

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
Copy link

g0rducci commented Apr 4, 2023

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

@sojan-official sojan-official changed the title feat: Chat GPT(OpenAI ) Integration with Chatwoot [CW-1551] feat: Chat GPT(OpenAI ) Integration with Chatwoot Apr 18, 2023
@eremeye
Copy link

eremeye commented Apr 18, 2023

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
Copy link
Member

sojan-official commented Apr 20, 2023

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.],
#6957

sojan-official added a commit that referenced this issue Apr 24, 2023
…6957)

ref: #6436
fixes: https://linear.app/chatwoot/issue/CW-1552/ability-to-rephrase-text-in-the-editor-using-gpt-integration

---------

Co-authored-by: Sojan <sojan@pepalo.com>
Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
sojan-official added a commit that referenced this issue Apr 28, 2023
Adds additional endpoints for OpenAI integration which will allow
- Reply Suggestions
- Summarization

ref: #6436
fixes: https://linear.app/chatwoot/issue/CW-1596/backend-for-generating-conversation-summary
@qkimchi
Copy link

qkimchi commented May 4, 2023

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
Copy link

harismateen commented May 10, 2023

@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
Copy link
Member

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: #7029

Here is a quick preview of the functionality:

ai.mp4

@caoramos
Copy link

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
Copy link
Member

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 : #7092

@sojan-official
Copy link
Member

ref: #7162

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

@sojan-official
Copy link
Member

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

@sojan-official sojan-official modified the milestones: 📮 May 30 - June 5, 🎎 May 23 - May 29 May 31, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2023
@sojan-official sojan-official removed this from the 🎎 May 23 - May 29 milestone Aug 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

13 participants