Skip to content
Content

How do I add AI customer support over iMessage?

Add AI customer support over iMessage by running a support agent in your own app and connecting it to Keiki, which handles the iMessage line, delivery and the team inbox.

How do I add AI customer support over iMessage?

Add AI customer support over iMessage by running a support agent in your own app and connecting it to Keiki, which handles the iMessage line, delivery and the team inbox. The agent answers from your help content, and when it can't, it hands the thread to a person on your team without the customer leaving the conversation.

Key takeaways

  • Put your product in iMessage with Keiki: a support agent that answers from your FAQ and hands the conversation to your team inbox when it needs a person.
  • Your code, your model, your servers. Keiki only handles the channels.
  • The open-source imessage-support-agent repo is a working example you can fork.

How it works

Keiki sends each inbound message to your server as a signed turn. With the @onkeiki/ai-sdk handler, a Next.js route runs your own model, with a search_knowledge tool that reads a small FAQ file, plus the tools Keiki provides for the turn. When the agent's Human handoff feature is on, those include escalate, which opens a handoff in the Handoffs queue of your Keiki inbox.

export const POST = createKeikiHandler({
  waitUntil,
  onTurn: async ({ instructions: keikiInstructions, messages, tools, prepareStep, abortSignal }) => {
    const keikiTools = await tools()
    return streamText({
      model,
      instructions: [instructions('escalate' in keikiTools), keikiInstructions].filter(Boolean).join('\n\n'),
      messages,
      tools: { ...keikiTools, ...supportTools },
      stopWhen: stepCountIs(8),
      prepareStep,
      abortSignal,
    })
  },
})

The open-source imessage-support-agent repo is this setup, ready to fork: deploy it, run npx @onkeiki/cli init to point an agent at /api/keiki, turn on Human handoff and attach an iMessage line. Your code, your model, your servers. Keiki only handles the channels.

What the customer sees

A customer texts a question and gets a short answer drawn from your FAQ. If the answer isn't there, or they ask for a person, the agent says a teammate will reply and escalates with a summary. While nobody has claimed the handoff, the agent keeps helping and can close it itself. Once a teammate claims it, the agent goes quiet and the teammate replies in the same thread.

FAQ

Do I need to write a separate help center for the agent? No. Start with a markdown file of questions and answers. When it grows, change the search tool to call the help center search you already have; the rest of the app stays the same.

Where do handed-off conversations go? To the Handoffs queue in the Keiki inbox, and to any Slack channel, email address or webhook you set as an escalation route. The customer keeps texting the same number.

Can I use a model other than OpenAI? Yes. The model call runs in your app through the Vercel AI SDK, so any AI SDK provider works. Change one line in lib/agent.ts.