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

Additional integrations that trigger built-in craft actions. #1876

Open
benfeather opened this issue May 8, 2024 · 4 comments
Open

Additional integrations that trigger built-in craft actions. #1876

benfeather opened this issue May 8, 2024 · 4 comments

Comments

@benfeather
Copy link

What are you trying to do?

Craft cms has several built-in actions, such as:

CleanShot 2024-05-08 at 14 59 35@2x
Docs

It would be great if we could create integrations in Formie that are mapped to these actions.

What's your proposed solution?

I imagine it would work similarly to the "Entries" integration that Formie has, where a form can trigger the creation of a user or entry.

Using an example from the table above:

users/login
This integration would log the user in and return the res from the login action.
The GQL response could be something like:

{
  "data": {
    "id": 123
  },
  "errors": [],
  "response": {
    // The action response
  }
}

We would likely need the ability to map form fields to the action inputs. Using the users/login action as an example:
map an "Email" field to "loginName"

Additional context

The benefits of using a Formie integration instead of a regular POST request to the action include:

  • A "log" of activity, i.e. a new submission for each login, reset password etc.
  • Trigger other integrations, e.g. trigger a CRM integration and update the user's last active date whenever the user logs in.
  • Use the Formie anti-spam measures, such as captcha integrations.
@engram-design
Copy link
Member

Interesting! So the reason I haven't pursued something like this is that some actions seem overkill to route through Formie, like the login action. We have the save entry/user as part of the Entry/User integration, and the register/login can be done without pointing to Formie. It seemed (to me) a bit overkill to generate a submission based on every time someone logs in, but that's something I suppose can be up to you!

Other actions might not be useful in the real-world, this sort of thing starts to delve into actions of other plugins or modules, which could certainly be useful.

I think this is a great idea. Whether this becomes a generic "Action" integration (a controller action of your choosing) or just a few common ones like the ones listed above, I'll consider it. I'm leaning towards the former to give people lots of flexibility.

@benfeather
Copy link
Author

I like the idea of a generic "Action" integration. That opens up a ton of possibilities.

Having a submission for every login might not be useful for everyone, but being able to trigger other actions when the user logs in could be useful.

It also keeps all of the form logic in one place, rather than overriding it on the frontend (currently, I have Formie render the login form and override the submit function to post the data to the login action).

@benfeather
Copy link
Author

benfeather commented May 9, 2024

Just another thought.

The action triggers should execute before Formie sends the response. This way, the action response data can be included.

The current integrations get added to Craft's job queue, which works well, but for an action integration the response data is important.

@engram-design
Copy link
Member

Another good point, and ties into how we might go about solving the #1152 issue for something like registering a user where you do need it to run outside of the queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants