curl --request POST \
--url https://app.thinnest.ai/api/v1/agents/{id}/channels/telegram \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"token": "7412958803:AAH3kZq9xR2mVt8LpW4nYc6bD1fS0gJe5uQ"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({token: '7412958803:AAH3kZq9xR2mVt8LpW4nYc6bD1fS0gJe5uQ'})
};
fetch('https://app.thinnest.ai/api/v1/agents/{id}/channels/telegram', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://app.thinnest.ai/api/v1/agents/{id}/channels/telegram"
payload = { "token": "7412958803:AAH3kZq9xR2mVt8LpW4nYc6bD1fS0gJe5uQ" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"agent": "ag_5c4a5f93-2b1e-4d7a-9f60-8e2d1c3b4a71",
"web": {
"id": "ch_0e6b2f71-3c9d-4a58-b1e7-5d2a8f4c9b30",
"connected": true,
"publicKey": "pk_9fQ2xLm7Rt4vWb8KcN3hYd6sJ1pZ",
"previousKeyExpiresAt": null
},
"whatsapp": {
"id": null,
"connected": false,
"phoneNumber": null,
"flagged": false,
"messagingLimit": null,
"blockingNotices": 0
},
"telegram": {
"id": "ch_5b2e9c18-4f7a-4d3e-a6b0-8c1d7e2f9a54",
"connected": true,
"username": "SkylineHomesBot",
"webhookFailed": false
},
"voice": {
"id": "ch_c3f80b2e-6d14-47a9-8e5b-1f9a2c7d4e06",
"answersCalls": true,
"phoneNumber": null,
"surfaces": [
"web",
"whatsapp"
]
}
}Connect Telegram Bot
Connects a Telegram bot to the agent with the token @BotFather gave you: the token is checked with Telegram, stored encrypted and never shown again, and Telegram is told where to deliver messages. Telegram needs a paid plan, and a bot can belong to one agent only. Telegram calls back on the address this request arrived on, so call the public API address. A build key may do this.
curl --request POST \
--url https://app.thinnest.ai/api/v1/agents/{id}/channels/telegram \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"token": "7412958803:AAH3kZq9xR2mVt8LpW4nYc6bD1fS0gJe5uQ"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({token: '7412958803:AAH3kZq9xR2mVt8LpW4nYc6bD1fS0gJe5uQ'})
};
fetch('https://app.thinnest.ai/api/v1/agents/{id}/channels/telegram', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://app.thinnest.ai/api/v1/agents/{id}/channels/telegram"
payload = { "token": "7412958803:AAH3kZq9xR2mVt8LpW4nYc6bD1fS0gJe5uQ" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"agent": "ag_5c4a5f93-2b1e-4d7a-9f60-8e2d1c3b4a71",
"web": {
"id": "ch_0e6b2f71-3c9d-4a58-b1e7-5d2a8f4c9b30",
"connected": true,
"publicKey": "pk_9fQ2xLm7Rt4vWb8KcN3hYd6sJ1pZ",
"previousKeyExpiresAt": null
},
"whatsapp": {
"id": null,
"connected": false,
"phoneNumber": null,
"flagged": false,
"messagingLimit": null,
"blockingNotices": 0
},
"telegram": {
"id": "ch_5b2e9c18-4f7a-4d3e-a6b0-8c1d7e2f9a54",
"connected": true,
"username": "SkylineHomesBot",
"webhookFailed": false
},
"voice": {
"id": "ch_c3f80b2e-6d14-47a9-8e5b-1f9a2c7d4e06",
"answersCalls": true,
"phoneNumber": null,
"surfaces": [
"web",
"whatsapp"
]
}
}Authorizations
Headers
Developers only: the customer workspace this request acts in — its org_… id from POST /customers. Leave it out to act in your own workspace. Refused with 404 (Workspace not found.) when the id is unknown, is not one of your customers, or is not an org_… id; 410 when that customer was deleted (restore it with POST /customers/{id}/restore until it is erased); 403 when the key belongs to one customer workspace (it cannot act as another); 400 when your workspace is not a developer workspace. /customers/* and GET /customers/usage are your own workspace's and refuse the header with 400: call them without it.
"org_3fKq9TzQ1mN8vB2xR7cLpA"
Body
Response
Connected. The agent's channels, naming the bot by its username.
Where an agent answers. A channel never set up has id: null.