Skip to content
Content

How do I build a personal AI assistant people text on iMessage?

Build it as an AI SDK app on your own server and connect it to iMessage with Keiki: your Next.js route runs the model and the assistant's tools, and Keiki receives each text and delivers the reply.

How do I build a personal AI assistant people text on iMessage?

Build it as an AI SDK app on your own server and connect it to iMessage with Keiki: your Next.js route runs the model and the assistant's tools, and Keiki receives each text and delivers the reply. The open-source imessage-personal-assistant starter does this with reminders, web search and memory in about 150 lines of app code.

Key takeaways

  • Put your product in iMessage with Keiki: a self-hosted personal assistant people text to set reminders, search the web and remember things.
  • Your code, your model, your servers. Keiki only handles the channels.
  • The open-source imessage-personal-assistant repo is a working example you can fork.

What the assistant needs

A personal assistant people text has three jobs beyond chatting: remember what they tell it, look things up, and come back later on its own. The starter gives the model four channel-neutral tools for that: set_reminder, web_search, remember and recall. Each one is scoped to the conversation, so one person's notes never show up in another's thread.

The whole iMessage layer is one handler from @onkeiki/ai-sdk:

export const POST = createKeikiHandler({
  waitUntil,
  onTurn: async ({ turn, client, messages, tools, prepareStep, abortSignal }) => {
    if (turn.silent) return deliverReminders(turn, client)
    return streamText({ model, messages, tools: { ...(await tools()), ...assistantTools(turn) }, stopWhen: stepCountIs(8), prepareStep, abortSignal })
  },
})

Getting it running

Fork Mail-0/imessage-personal-assistant, deploy it, and run npx @onkeiki/cli init to point a Keiki agent at /api/keiki. Attach an iMessage line to the agent and text it. Your code, your model, your servers. Keiki only handles the channels.

FAQ

Can the assistant text someone first when a reminder is due? Yes, within an existing conversation. A scheduler calls the app's /api/reminders route, which sends Keiki a notice for that person. Keiki opens a silent turn, and the app texts the reminder through the turn client. The line's outbound rules still apply, so a line that needs the person to reply first can refuse it.

Do I need a database to try it? No. The starter keeps reminders and memories in process memory so it runs with nothing else installed. Before real use, replace the four functions in lib/store.ts with your own database, because memory resets on restart and isn't shared between serverless instances.

Can I pick the model and the search provider? Yes. Any AI SDK provider works by changing one line in lib/agent.ts. Web search is a small provider map: set SEARCH_PROVIDER to exa or tavily with its key, or add your own provider.