Open Mitra-Electronics opened 9 months ago
@unicodeveloper For example, in the Triggering Notifications section in the Python Quickstarts page, the example is given as follows:
from novu.api import EventApi
EventApi().trigger(
name="test", # The trigger ID of the workflow. It can be found on the workflow page.
recipients="123",
payload={}, # Your Novu payload goes here
)
But in the default Novu Account Activation Development Workflow, the above example doesn't work, even after entering the correct Novu API key and the correct workflow ID.
After looking into the source code, I was able to fix the error
event_api.trigger(
name="account-activation",
recipients={
"subscriberId": "650af3f587135ffdc3325599",
"phone": "<ReplaceWithData>",
"email": "<ReplaceWithData>"
}, # type: ignore
payload={}, # Your Novu payload goes here
)
The above code works, but when I enable type checking in VS Code in a Python file, it shows a type error. The subscriber was created by default, I didn't create it.
Sorry for the confusion @Mitra-Electronics. We'll get the quickstarts page updated, it was an error. It should have been:
event_api = EventApi("https://api.novu.co/api/", "<NOVU_API_KEY>")
event_api.trigger(
name="<YOUR_TEMPLATE_NAME>",
recipients="<YOUR_SUBSCRIBER_ID>",
payload={}, # Your Novu payload goes here
)
@unicodeveloper would you like me to make the update in the documentation for you?
@unicodeveloper I would like to update the docs for you...
@Mitra-Electronics Can you throw more light on this?
We have the Python Quickstart, and Python Cookbook. Please check them out and let me know what you think.