adnanbhanji / EU-Chatbot-Reco-System

MIT License
0 stars 1 forks source link

Integrate Chatbot with WhatsApp #11

Closed adnanbhanji closed 6 months ago

adnanbhanji commented 7 months ago

Develop the integration layer for the chatbot to function within WhatsApp. This involves setting up communication protocols that allow the chatbot to receive and send messages through WhatsApp, ensuring a seamless user experience as if chatting with a regular contact. The integration should handle user inputs and responses efficiently, maintaining the natural flow of conversation.

Responsible for establishing and maintaining the data pipeline between the chatbot system and WhatsApp's APIs.

smorenolasa1 commented 7 months ago

To connect GPT4 to Watsapp, we first had to create a message API sandbox for WhatsApp by setting up a vonage messages API sandbox. We then had to create the webhooks to recevie the messages forwarded by the sandbox. For this part we downloaded ngrok and then run ngrok http 8080, so that it gives you the forwarding URL. We then put this URL in the inbound webhook. Captura de pantalla 2024-02-08 1502013

image

smorenolasa1 commented 7 months ago

We then had to connect to the Flask server to print incoming requests from the sandbox. For this, we use the port 8080 since we used it before to give us the forwarding url. Then, to connect to ChatGPT, we had to obtain an OpenAI API Key. We create a config.py to put our vonage accounts(with our sandbox number, and our base encoded credentials, we get from encoding our voice API key and voice API secret), and our openai key.

smorenolasa1 commented 7 months ago

Then, we had to create a conneciton between ChatGPT and WhatsApp to send and receive the messages. For this we first create an app.py to set up the flask server to print the incoming requests from the sandbox. We then create a commands.py(here we have to provide a string value that we got from our sandbox) that receives the message we sent from the sandbox, it then forwards the question, collects the answer, and sends it back to the whatsapp user. image

smorenolasa1 commented 7 months ago

Finally, we run our app.py in the terminal to test that it correctly integrated ChatGPT in Whatsapp. Here, we got some errors, since we our openai API quota had exceeded. After fixing this, we could send messages to chatGPT from our whatsapp. image image

adnanbhanji commented 7 months ago

Perfect, we have the communication working between the end user and bot, we now need to finetune it to our CO2 emmision report.

KhaledAkel commented 7 months ago

Perfect, we have the communication working between the end user and bot, we now need to finetune it to our CO2 emmision report.

so we need to tell chatgpt before any new conversation to act like an expert in CO2 emission reports in general. I think that would be the approach.

smorenolasa1 commented 7 months ago

We fixed the issue with the chatbot not being able to create images: image