The subscription for welcome email bot is not trig...
# support
n
Hi, I am facing an issue with the reset password bot integration with the subscription to send a custom email for the reset password. Can anyone help me with this
@rahul1, can you please suggest some solution
r
@nikulkhatik - can you please provide more details about the problem you are expereiencing?
n
I have created a bot as a project admin
As suggested in the Medplum document
I Integrated this in foo-medical for patients to reset their password
Got a success message from the server api but did not get an email to reset the password
And also there is no log in the subscription for the event
r
Ok i can help debug. Are you able to look at the "Events" tab for the Bot to confirm that it is being triggered? https://www.medplum.com/docs/bots/monitoring-bots
n
Let me check
No there is no event
Not in bot or subscription
r
Ok thank you
This means that the Subscription is not being triggered. Can you paste the JSON for your subscription resource?
n
Copy code
{
  "resourceType": "Subscription",
  "status": "active",
  "reason": "New Password Change Request",
  "criteria": "PasswordChangeRequest",
  "channel": {
    "type": "rest-hook",
    "endpoint": "Bot/228cacfc-2dbc-400b-99a6-f3e09bccc06c"
  },
  "id": "5b69a11c-3a21-496f-8316-82a5a04e7a00",
  "meta": {
    "versionId": "8bb351ce-5685-417e-b63c-1e48f23640c7",
    "lastUpdated": "2023-10-16T14:22:03.673Z",
    "author": {
      "reference": "Practitioner/df1ff53b-dae0-433e-a95f-a4b388713f14",
      "display": "Nikul Khatik"
    },
    "project": "6e37f80a-1221-4e5b-841e-a85f9a734abc",
    "compartment": [
      {
        "reference": "Project/6e37f80a-1221-4e5b-841e-a85f9a734abc"
      }
    ]
  }
}
r
And can you confirm that
PasswordChangeRequests
are being generated? They should appear as just another resource type in the Medplum app (though you may need to be logged into the SuperAdmin) project to see it
n
ok
Yes it's created
The event found in both bot and subscription
r
> The event found in both bot and subscription Sorry, I didn't understand this last sentence
n
r
Ok, so there was and Event?
n
Yes
r
Ok, this means the Bot did run. If you look at the
outcomeDesc
line in this event, you'll see that it encountered an error of
403: Forbidden
n
yes, I see
r
Is this Bot set to run as a project admin?
n
Yes
Copy code
{
  "meta": {
    "project": "6e37f80a-1221-4e5b-841e-a85f9a734abc",
    "versionId": "e2ce7640-4375-46bb-b8ad-7ff25a5d5207",
    "lastUpdated": "2023-10-16T14:52:41.203Z",
    "author": {
      "reference": "Practitioner/df1ff53b-dae0-433e-a95f-a4b388713f14",
      "display": "Nikul Khatik"
    },
    "compartment": [
      {
        "reference": "Project/6e37f80a-1221-4e5b-841e-a85f9a734abc"
      }
    ]
  },
  "resourceType": "ProjectMembership",
  "profile": {
    "reference": "Bot/228cacfc-2dbc-400b-99a6-f3e09bccc06c",
    "display": "Lumba - Staging Reset Password"
  },
  "id": "4af3be3a-6108-482d-8db7-41d628e46f96",
  "admin": true,
  "project": {
    "reference": "Project/6e37f80a-1221-4e5b-841e-a85f9a734abc",
    "display": "Lumba Staging"
  },
  "user": {
    "reference": "Bot/228cacfc-2dbc-400b-99a6-f3e09bccc06c",
    "display": "Lumba - Staging Reset Password"
  }
}
r
hmmm ok - I will try to reproduce this error and get back to you. It is possible that our example bot code has a bug in it
n
ok
r
Hi @nikulkhatik, I've identified the source of the 403 Error. Line 12 in the example Bot reads the
User
resource. This should be accessible for all "patient" users, but it was not. This PR will fix that error: https://github.com/medplum/medplum/pull/3051
183 Views