I am trying to setup a webhook for my Telegram Bot. I want the webhook to also include the optional data from the method language_code of the user. The plan is to use this webhook to monitor interaction from users and incorporate AI to translate responses based on the users language_code.
I have tried using Postman with this code snippet:
import requests
bot_token = “6441459268:AAH5GOrsALi20nJbioarEgr8v-7hzcpjIKU” # Replace with your bot ID that you got from botfather
webhook_url = “https://hook.eu2.make.com/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
payload_data = {
‘url’: webhook_url
}
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)
{
It threw this error: Cloud Agent Error: Couldn’t resolve host. Make sure the domain is publicly accessible or select a different agent.
After that I asked the AI Assistant for help, but Im not sure I setup the scenario correctly.
Here are the screenshots of the Scenario
Any help would be appreciated.
Thanks