← Forward Deployed Engineering Lesson 8 of 12

Shipping it

Where it runs

The agent works on your laptop. Now it has to run all day, every day, for real parents.

Putting it somewhere real users can reach is called deploying it. Before you do, know every piece a message passes through, because each one can fail.

Follow one message through the live system
  1. WhatsAppA parent sends a message. WhatsApp passes it to Northstar's web address.
  2. serverYour code, on a server that's always on, receives it and hides personal details.
  3. modelYour code calls the model, which may ask for tools: fees or slots.
  4. checksThe guardrails check the reply.
  5. WhatsAppThe reply goes back to the parent.
  6. sheetThe lead and the chat are saved to the lead tracker.

Each piece needs a key. Where do keys go?

Keep keys secret

Your code proves who it is to WhatsApp and to the model company with secret codes called API keys. Anyone with the key can spend Northstar's money or read its messages.

So keys never go in the code, in a chat or on GitHub. They're stored on the server, in settings the code reads when it starts, called environment variables.

Sort each habit

Keys aren't the only secret.

Protect personal data

Enquiries carry phone numbers, emails and family stories. Kevin's first worry was exactly this.

Send the model only what it needs to answer. A phone number never helps it answer a fee question, so replace it with a placeholder before the call. India's data protection law, the DPDP Act, also expects you to collect and share as little as you need.

Switch on the protections and see what the model receives

Practise hiding data.

✏️ Practice 8.1

Remember:
To show a number to staff without revealing it, keep only the last 4 digits: 9999901239 → ******1239.
share = count ÷ total × 100%
1. How does 9999901264 look when masked this way?
2. A chat has 12 messages. You send the model only the last 6, plus the state. What share of messages is not sent, in %?
3. With phone numbers hidden on every message, how many of last month's 2,500 enquirers' numbers reached the model?

Keep the cost down

Models come in sizes. Big ones handle hard questions well but cost much more per call. Most enquiries are easy: fees, campuses, timings.

So send easy questions to a small, cheap model, and only hard ones to the big model. Sending each request to the right model is called routing.

Change the numbers and watch the monthly bill
Enquiries a month
Sent to small model

Example prices: ₹0.60 per call on the big model, ₹0.05 on the small one. 3 calls per enquiry.

Ready to switch it on? Not all at once.

Roll out slowly

Don't switch it on for everyone on day one. Start small, watch closely, then grow.

And keep one switch that turns the agent off and sends every chat back to counsellors, in seconds. Going back to the old way like that is called a rollback.

Step through Northstar's rollout
  1. week 1Counsellors chat with it themselves, trying to break it.
  2. week 2Live at night only, 9 pm to 8 am. Counsellors read every chat next morning.
  3. week 3All hours, for 1 in 4 chats. Compare first-reply times with the rest.
  4. week 4Everyone, if the numbers hold. The off switch stays ready.

Work out the bill yourself.

✏️ Practice 8.2

Remember:
monthly cost = enquiries × calls per enquiry × cost per call
1. 2,500 enquiries, 3 calls each, all on the big model at ₹0.60 a call. Monthly cost, in rupees?
2. The same, all on the small model at ₹0.05 a call?
3. With 80% routed to the small model and 20% to the big one?

Do it for real

Now get it ready for real users. In the notebook you'll scan for leaked keys, hide phone numbers and emails, and work out what routing saves.

Then you'll put the agent behind a web address with logging, run it in shadow mode, and build the switch that rolls it out, or back.

Get it ready to ship in Google Colab

Colab runs Python in your browser for free. Replay mode needs no key. About 45 minutes.

Then check what stuck.

Lesson test

Five questions, all on new examples.

Question 1You notice an API key was pushed to a public GitHub repo an hour ago. What do you do first?
Question 2A bank's bot answers "what's your savings interest rate?". The message arrives with the customer's account number. Should it go to the model?
Question 3A travel bot's bill is too high, and most questions are simple, like "what time is check-in?". What helps most?
Question 4A hospital's new booking bot is ready. What's the safest launch?
Question 51,000 chats a month, 2 calls each, ₹0.50 a call. What's the monthly cost?

What's next?

This leaves a question
It's live. What happens on day two?
Lesson 9 answers it.

Before you go on, an optional extra: Enterprise clients. Single sign-on, keeping clients' data apart, security reviews and webhooks. Big clients and interviewers both ask about these.