Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass profile resource into Bots #2790

Open
rahul1 opened this issue Sep 7, 2023 · 2 comments
Open

Pass profile resource into Bots #2790

rahul1 opened this issue Sep 7, 2023 · 2 comments
Labels
bots Features and fixes related to bots and automation

Comments

@rahul1
Copy link
Member

rahul1 commented Sep 7, 2023

Use Case

User driven: https://discord.com/channels/905144809105260605/1142177596856082533/1142177596856082533

When using a bot using 3rd party APIs like Stripe, the developer would like make sure they have the Patient resource of the bot invoker, to make sure they bill the correct account.

Proposal

The Bot "Run As User" feature sets the access token of the MedplumClient that is passed in, but does not set the profile resource. The proposal is to set both the accessToken and profileResource in the MedplumClient before passing it into the handler function

@rahul1 rahul1 added the bots Features and fixes related to bots and automation label Sep 7, 2023
@codyebberson
Copy link
Member

Quick and dirty workaround: In the bot, run this at the beginning

await medplum.setActiveLogin(medplum.getActiveLogin());

For us to fix this the "right way" has a few hops:

  1. We need a way to setProfile in MedplumClient. That doesn't currently exist (without horribly ugly hacks).
  2. We need to publish a new version of @medplum/core
  3. Then we can update the executeBot pathways to use setProfile

Because of the "bot lambda layer" pattern, we need a published version of @medplum/core first :(

@rahul1
Copy link
Member Author

rahul1 commented Sep 7, 2023

Not burning, happy to wait for the new version, but appreciate the workaround

@rahul1 rahul1 added this to the Milestone Quality milestone Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bots Features and fixes related to bots and automation
Projects
Status: No status
Development

No branches or pull requests

2 participants