I'm attempting to configure a webhook for my Telegram Bot. My goal is to have the webhook capture the optional language_code
data from users. This webhook will be used to track user interactions and integrate AI for translating responses based on the user's language_code
.
I've experimented with Postman using the following code snippet:
```python
import requests
bot_token = “6441459268:AAH5GOrsALi20nJbioarEgr8v-7hzcpjIKU” # Replace with your bot ID from BotFather
webhook_url = “ https://hook.eu2.callin.io/pp0mlsvkfv3pqc8t56bx9tasfsua0kpl ” # Replace with your webhook link
API endpoint URL for setting the webhook
url = f’ https://api.telegram.org/bot{bot_token}/setWebhook ’
Prepare the payload for the API call
payloaddata = {
‘url’: webhookurl
}
Make the API call using the ‘requests’ library
response = requests.post(url, json=payload_data)
Check the response status and process the result
if response.ok:
result = response.json()
if result[‘ok’]:
print(‘Webhook set successfully!’)
else:
print(‘Failed to set webhook:’, result[‘description’])
else:
print(‘Failed to set webhook. Status code:’, response.status_code)
print(‘Error message:’, response.text)
```
This resulted in the following error: Cloud Agent Error: Couldn’t resolve host. Make sure the domain is publicly accessible or select a different agent.
I consulted with the AI Assistant for assistance, but I'm uncertain if my scenario setup is correct.
Here are screenshots of the scenario:
Any assistance would be greatly appreciated.
Thanks