Skip to content

Access a session context from a custom API endpoints #315

@rachidbch

Description

@rachidbch

My application makes use of custom API endpoints to create webhooks that are triggered by external applications.
When a webhook is trigered the application is able to identify:

  • The user that should be informed of the event.
  • Its session id

Unfortunately I haven't found a document way to send a message to that user from the API endpoint handler so that the user can see the message on Chainlit web ui.

Inside the API endpoint handler, there's no Context defined and Chainlit doesn't offer a documented way the context of a session even if the session_id is known.

For the time beeing, I use an horrible hack to work around this problem.

What is the recommended way to summon a the context of a specific session so that we can use the standard Chainlit API to send and receive messages from a user.

Of course the webhook could be triggered while the target user is not connected to the Web UI, but that should be trivial to deal with at the application level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions