Skip to content

An example that talks to a real channel #4

Description

@luantaraschi

examples/ has two files: webhook.ts, a synthetic feed through the runtime, and
serverless.ts, driving the core from a stateless handler. Both show the mechanism.
Neither shows a real channel.

The first question somebody has after the README is what this looks like against an
actual API. An example that answers it end to end would show:

  • a webhook handler calling runtime.ingest({ conversationId, messageId, text }) with
    the ids the channel gives it
  • runtime.typing({ conversationId }) fed from the channel's composing event, which is
    the whole point of that feature
  • a turn handler sending one reply back

WhatsApp Cloud API and Telegram are both reasonable targets. Telegram is easier to try
without a business account.

What it has to keep

  • No new dependencies. fetch is in Node 20 and that is all either API takes.
  • Readable without credentials. Somebody should learn the shape by reading the file
    without signing up for anything, so the token comes from an environment variable and
    the file says what it expects.
  • Name the API version it was written against, and keep it in examples/, which is not
    part of the published package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions