Build a National Rail Bot for Telegram A tutorial published with a downloadable starter kit shows how to build Homebound, a personal Telegram bot that answers train-delay questions by reading a single London Waterloo-to-Reading departure board through a Quickchat AI Agent. The kit's practice board is fixed at 2 June 2026 and demonstrates a booked 17:35 service expected at 17:43, eight minutes late from platform 20 due to a signalling fault near Richmond, with the board timestamped 17:32 BST. The walkthrough requires Python 3.10 or later, a Quickchat AI account with available AI credits, and a Telegram bot token from @BotFather, and it restricts the departure lookup to the Telegram User Id captured from a private chat. Ask your Telegram train bot, “Is the 17:35 from Waterloo to Reading delayed?” On the practice board, yes. It’s due at 17:43, eight minutes late, from platform 20. A signalling fault near Richmond is the reason. The board was updated at 17:32 BST. Those three times tell you which train you asked about, when to expect it and how old the answer is. Homebound’s reply in the Quickchat AI Inbox came from a simulation. The practice board is fixed at 2 June 2026, so you can reproduce the eight-minute delay. You’ll build Homebound , a personal Telegram train delay bot. A Quickchat AI Agent reads one departure board when you ask. Start with the Homebound starter kit https://quickchat.ai/blog-assets/downloads/homebound-rail-kit.zip . The kit works without a rail account. For the bot you’ll need a Quickchat AI account with available AI credits and a Telegram account. 1. Which time answers “Is my train late?” Start with the booked departure time. A train scheduled for 17:35 keeps that identity even when its expected departure changes. Open the practice board https://quickchat.ai/blog-assets/downloads/homebound-rail/board.json and find the first service in trainServices . Its std is the booked time. Its etd holds the estimate. It can also be a status such as On time or Delayed . | Booked at Waterloo | What the practice board says | What to tell the passenger | |---|---|---| | 17:35 | Expected 17:43, platform 20 | Eight minutes late. Keep the signalling fault near Richmond with this train. | | 18:05 | Cancelled, train fault | Say it is cancelled, even though it still has a booked time. | | 18:35 | On time, no platform supplied | Say “platform not announced”. Use a platform number only when it belongs to this departure. | The station clocks already show local time. The board timestamp is in UTC. On 2 June, 16:32 UTC was 17:32 BST in London. For a first result without any accounts, unzip the kit and run this in its folder with Python 3.10 or later. The second command selects the booked 17:35 even though its expected time is 17:43. python3 board.py board.json python3 board.py board.json --at 17:35 2. How do you connect your own Telegram bot? Give Homebound its own Telegram username so you can ask about the train in a direct message. The first exchange also gives you the numeric identity you’ll use to limit access to the departure lookup. 1. Create a Quickchat AI Agent https://app.quickchat.ai/register . If you already have an account, choose Add new AI Agent → Set up manually . Name the Agent Homebound . Under Identity → Main Prompt , paste main-prompt.txt from the kit and save. 2. In Telegram, open the verified @BotFather , send /newbot , choose a display name and an available username ending in bot . BotFather gives you a token. The illustrated BotFather guide https://quickchat.ai/post/how-to-create-a-telegram-bot shows the exchange. 3. In Quickchat AI, open External Apps → Telegram → Your own bot → Connect to Telegram . Enter the token in Bot Token , connect and enable your own bot. Open its chat in Telegram, tap Start , then send an ordinary message such as “Hello, Homebound”. 4. Open that conversation in Inbox → Details → Visitor . Copy Telegram User Id and check that Telegram Chat Type says private . Use this ID for the Action in the next step. BotFather creates the bot identity. The connection form attaches that identity to Homebound. Keep both the Telegram bot token and your rail credential out of the conversation. 3. How does a chat message read the departure board? Homebound needs one read-only HTTP Action. Fix the route in the request so “my train” always means London Waterloo to Reading , and a follow-up about the 18:05 reads the same board. 1. Open Actions & MCPs → Add Action → API Action → Create manually . Set API Action Name to get homebound departures and When to run to AI decides . Leave What to ask the user first empty. 2. For API Endpoint , select GET and paste the practice URL below. Leave Query Params , Headers and Body empty. In API Action Description , paste the description from the kit. 3. Under Advanced settings → Run only when , add both conditions below. Replace YOUR NUMERIC ID with the ID you copied from your private conversation. Save and enable the Action. https://quickchat.ai/blog-assets/downloads/homebound-rail/board.json The question can change from the 17:35 to the 18:05. The request stays fixed, and the Agent looks up the matching scheduled time in the response. telegram user id equals YOUR NUMERIC ID telegram chat type equals private Both checks have to pass. A group message from you has the right ID and the wrong chat type. A direct message from someone else has the right chat type and a different ID. Copy the Homebound Main Prompt and Action description Main Prompt You are Homebound. For a question about London Waterloo to Reading, call get homebound departures. This is a dated practice board. Always label it as practice. Answer the train asked about first. Give its scheduled time, expected time or status, and the board time in Europe/London with its date. Keep the supplied disruption reason. Reply in the requested language and keep station names and local train times unchanged. Read the board flags before the service rows. If areServicesAvailable is false, say that departure information is unavailable. Only say no matching trains when an available board has an empty list. If platformAvailable is false, withhold every platform value even if a row contains one. If a service has no platform, say ‘not announced’. If isCancelled is true, say the train is cancelled. If filterLocationCancelled is true, say this service will skip Reading; it may still run elsewhere. If the lookup fails, say you could not check. API Action Description Read the configured London Waterloo to Reading board when asked about this route. Use only the returned services, scheduled and expected departures, platforms, reasons and board timestamp. Set up the practice Action from ChatGPT or Claude Connect your Quickchat AI account and attach main-prompt.txt and action-recipe.md from the kit. Supply your numeric Telegram ID and use the request below. You can review the saved Action in Quickchat AI before enabling it. ChatGPT connector https://chatgpt.com/plugins/plugin asdk app 6a4656c688748191be4c5247fb0d5dfc · Claude connector https://claude.ai/directory/connectors/app-quickchat-ai · Account setup guide https://quickchat.ai/docs/manage-with-ai Set Homebound’s Main Prompt from the file. Prepare get homebound departures as an inactive GET Action using the practice URL. Require my numeric Telegram user ID and a private chat. Show me the saved settings before running a test. 4. What should the bot say when a train is delayed or cancelled? Send “Is the 17:35 from Waterloo to Reading delayed?” in your private Telegram chat. Look for the 17:43 estimate, platform 20 and the reason. Open the conversation in Inbox , expand the Action call and compare the returned generatedAt with the time in the answer. The message’s own send time only tells you when you asked. Then ask “Which platform for the 18:35?” This train shares a destination with the 17:35. It has no announced platform. Ask “What happened to the 18:05?” and you should hear about the cancellation and the train fault. Finally, ask for the answer in Polish. Our test gave “o 17:43 z peronu 20” for the 17:35. London Waterloo and Reading kept their names. The board still showed 17:32 in London. The 18:05 still has a booked departure time after cancellation. The 18:35 still has a service even though it has no platform. Keep both rows. Our first prompt made a mistake that a happy-path test would miss. We kept platform 20 in the practice row and set the board’s platformAvailable flag to false . Asked for the platform, Homebound still gave us 20. With areServicesAvailable set to false and an empty list, it also told us there were no matching trains. We changed the prompt to read the board flags before the individual train. For this test we deliberately left a platform in the synthetic row and turned off platform information for the board. It is the same train and the same question on both runs. On the second run, Homebound said “Platform information is unavailable.” It also distinguished an unavailable board from an available board with zero matches. To reproduce this in Conversations → Testing , use a separate practice Agent with the same prompt and a credential-free GET Action. Test the withheld-platform board https://quickchat.ai/blog-assets/downloads/homebound-rail/withheld-platform.json , the unavailable board https://quickchat.ai/blog-assets/downloads/homebound-rail/unavailable.json and the empty board https://quickchat.ai/blog-assets/downloads/homebound-rail/empty.json in turn. The simulated visitor has no verified Telegram identity. Use the ungated practice Action there and keep both conditions on Homebound. The kit’s action-recipe.md shows how to run a dataset with one question. To check access, ask the same question from a second Telegram account in a direct message. Then add the bot to a test group and send /start@your bot username from your own account, using the bot’s actual username. Reply to its greeting with the question. Check that the group question reached Inbox , then open Actions & MCPs → View logs and verify that neither attempt sent an HTTP request. In our local tests, both disallowed identities produced zero requests to the fixture. Quickchat AI Telegram channel guide https://quickchat.ai/docs/channels/telegram If Homebound reports 17:43 for the 17:35 and says the 18:35 platform hasn’t been announced, your practice bot is ready. For travel today, check National Rail’s Waterloo to Reading board https://www.nationalrail.co.uk/live-trains/departures/london-waterloo/reading/ . Optional extension for live National Rail departures National Rail’s Darwin system supplies the live data. We tested Homebound with the dated board inside Quickchat AI. Start with the public Waterloo to Reading board https://www.nationalrail.co.uk/live-trains/departures/london-waterloo/reading/ in a browser. Note the scheduled time on one row and the board’s update time. Those are the two values you’ll use to match a reply to the source once the live connection is in place. When we opened the passenger board on 24 November, its 13:48 to Reading showed “On time” and platform 19. Your board will have moved on. Match a booked time from your own session. 1. From National Rail’s Darwin feeds https://www.nationalrail.co.uk/developers/darwin-data-feeds/ , choose LDB Webservice PV , the public-version JSON API. Open Rail Delivery Group’s Live Departure Board product https://raildata.org.uk/dataProduct/P-d81d6eaf-8060-4467-a339-1c833e50cbbe/overview . Its Licence tab lists version 1.1 as free for registered users and names National Rail for attribution. Register and select Subscribe . Check the usage terms attached to your subscription. 2. Sign in and open Specification for your subscription. Select GetDepartureBoard in the request example and set the departure station to WAT London Waterloo . Enter the five query values below. Use the HTTPS endpoint and the exact credential header shown for your account. The published JSON specification https://realtime.nationalrail.co.uk/LDBWS/static/ldbws.json describes the fields and lists localhost as its host. Your subscription supplies the working address. 3. Make one request in the provider’s console. Check for a successful JSON board with crs equal to WAT , the Reading filter and a dated generatedAt . Compare one service with the passenger board while both are open. A board can update between the two reads. numRows=3 filterCrs=RDG filterType=to timeOffset=0 timeWindow=120 The practice board works without a rail account. For live departures, sign in to view the specification. Allow a few working days for the Marketplace to review a new account request. Account request form https://raildata.org.uk/registerPartner 1. Save the verified HTTPS endpoint on the Homebound Action with each query value entered once and both Telegram conditions in place. Then check that the saved Action is switched off. For the kit’s write-only header setup, create a token for this Agent in External Apps → API with write all scope. Quickchat AI makes token creation available on Business and higher plans. The practice build uses no such token. Quickchat AI API reference https://quickchat.ai/docs/api-reference 2. In the unzipped kit, run python3 set rail header.py . Enter the provider origin and header name from your approved request. The helper checks that the Action points at that origin, prompts privately for the credentials and confirms a redacted readback. Replace the practice Main Prompt with the live version in action-recipe.md . Check how to display National Rail attribution alongside the data in your client, then enable the Action. National Rail’s developer guidelines https://assets.nationalrail.co.uk/e8xgegruud3g/GEAgXQtvWvn0myHWMMk5N/45afd9a7f370135b9b399c2e2777fc0f/Developer Guidelines v 06-01.pdf 3. Ask “What are the next trains to Reading?” in your own DM. Compare the booked time, status and platform with National Rail. Match the API’s board timestamp between the successful Action log and the reply. Keep the source date visible if it is old. If the service rejects the credential or rate-limits the request, Homebound should say it could not check and offer the passenger board. An empty list means the available board returned no matching trains in that window. If areServicesAvailable is false, service information is unavailable. If filterLocationCancelled is true for a service, its stop at Reading has been cancelled. Report the stop change separately from a cancellation of the whole train. For a different commute, verify the station codes and try these checks again. Frequently asked questions Do I need a National Rail API key for a Telegram train bot? The practice board works without a key. For live Great Britain departures, subscribe to the public-version Darwin JSON product through Rail Data Marketplace. Use the endpoint and credential from that subscription. Telegram’s BotFather token connects the bot to Telegram. How does the bot tell whether a train is late? Find the train by its scheduled departure. If the expected departure is a later clock time, report both times and their difference. If the feed reports a delay without an estimate, report the delay and leave the number of minutes open. What if National Rail has no platform number? Say the platform has not been announced. Only show a platform when the board permits it and the train has a published value. A platform used by another train or by yesterday’s service is no substitute for an announcement. Can I ask in another language and keep UK train times? Yes. Ask Homebound to translate the explanation and preserve station names and train times. Interpret the dated board timestamp in Europe/London, which uses GMT in winter and BST in summer. Can someone else use my bot’s National Rail allowance? The departure Action checks the numeric Telegram user ID and requires a private chat before dispatch. Test another sender and a group and verify that neither reaches the feed. Keep the provider credential private as well. Will Telegram alert me automatically if my train is delayed? Homebound checks departures when you send a message. Automatic delay alerts would need a separate schedule, a way to detect a change to the same service and a delivery mechanism.