This project is a Flask-based chatbot integrated with Dialogflow and Telegram to perform currency conversion. It uses the Exchange Rate API for real-time currency exchange rates and is deployed on Render for hosting.
- Converts an amount from one currency to another using real-time exchange rates.
- Integrated with Dialogflow for NLP capabilities.
- Connected to Telegram to provide a conversational interface.
- Deployed on Render for easy access.
- Python 3.7+
- Flask Framework
- Dialogflow Agent
- Exchange Rate API Key
- Render Account
- Telegram Bot Token
git clone <repository_url>
cd <repository_folder>
pip install -r requirements.txt
Replace the placeholder API key in fetch_conversion_factor with your Exchange Rate API key:
api_key = "YOUR_EXCHANGE_RATE_API_KEY"- Create a new Dialogflow agent.
- Define an intent to extract:
unit-currency.currencyunit-currency.amountcurrency-name
- Configure webhook to point to your Render app URL.
- Create a Telegram bot using the BotFather.
- Link your Telegram bot to Dialogflow via a webhook.
python app.py
- Create a new web service in your Render account.
- Connect your Git repository.
- Add the following environment variables:
EXCHANGE_RATE_API_KEY- Other required keys (e.g., Telegram bot token).
- Deploy and retrieve the Render app URL for Dialogflow webhook.
- Exchange Rate API: Provides real-time currency conversion rates.
- Endpoint Example:
https://v6.exchangerate-api.com/v6/<API_KEY>/pair/USD/EUR
/: Handles POST requests from Dialogflow, processes the input, and responds with the converted amount.
fetch_conversion_factor(source, target): Fetches the conversion rate between two currencies using the Exchange Rate API.
{
"queryResult": {
"parameters": {
"unit-currency": {
"currency": "USD",
"amount": 100
},
"currency-name": "EUR"
}
}
}{
"fulfillmentText": "100 USD is 92 EUR"
}-
Invalid API Key:
- Ensure your API key is correct and valid.
-
Missing Dialogflow Parameters:
- Ensure the intent captures all required parameters (
unit-currencyandcurrency-name).
- Ensure the intent captures all required parameters (
-
Conversion Factor Not Found:
- Check the API response structure and ensure the
conversion_ratefield exists.
- Check the API response structure and ensure the
-
Deployment Issues:
- Verify the webhook URL and environment variable configurations.
