OpenSourceOrg / dotOrg

Public tracker of opensource.org issues
GNU General Public License v3.0
10 stars 3 forks source link

OpenSource.org | Spreadsheet-to-text Zapier connection #116

Open toncijajic opened 2 months ago

toncijajic commented 2 months ago

OpenSource wants to use Zapier to publish from a spreadsheet automatically to the Press Mentions. We should help set up that connection - or figure out another (easier, if existing) way to do it.

Details

Quoting Ariel's request below:

I want to use Zapier to create new posts from a spreadsheet we use to track press mentions.

So far I've been able to create new empty press mentions, as the fields that are mandatory don't seem to get populated correctly.

I've installed the Zapier plugin in the staging site and added this code (now I've commented it just in case) to functions.php, but fields weren't getting populated either:

function expose_acf_fields_to_rest_api() {
    $acf_fields = array(
        'date_of_publication',
        'article_url'
    );

    foreach ($acf_fields as $field_name) {
        register_rest_field('press-mentions',
            $field_name,
            array(
                'get_callback'    => function( $post_arr ) use ( $field_name ) {
                    return get_field( $field_name, $post_arr['id'] );
                },
                'update_callback' => function( $value, $post_arr ) use ( $field_name ) {
                    return update_field( $field_name, $value, $post_arr['id'] );
                },
                'schema'          => null,
            )
        );
    }
}
add_action('rest_api_init', 'expose_acf_fields_to_rest_api');
georgestephanis commented 2 months ago

Just noting as I'm investigating here that it looks like the code was being added via the wp-admin theme file editor here:

https://open-source-initiative-development.mystagingwebsite.com/wp-admin/theme-editor.php?file=functions.php&theme=osi

It would likely be worth advising Ariel that working with the theme editor there is inherently risky as any deployments from GitHub could potentially wipe out the changes if there are any deploys of that file from the development branch. If it's just for quick testing, that's probably fine, just so long as they're aware of the risks of losing changes unexpectedly.

georgestephanis commented 2 months ago

Do we have any access to the Zapier account or working with Ariel to understand how the integration is done?

Also, if this is the only thing they're using Zapier for, there's a number of ways to do Spreadsheet to WordPress integrations, depending on what sort of spreadsheet they're starting with -- whether Google Sheets or Microsoft Excel or maybe LibreOffice or some other data source?

I'm happy to just look at debugging the Zapier pathway, but I'm also happy to talk through the entire flow of what they'd like the final UI to feel like.

securityjedi commented 2 months ago

Hi @georgestephanis,

In response to your question,

Also, if this is the only thing they're using Zapier....

The partner confirmed this was the sole reason for using Zapier on the website.

I've replied to the partner asking them for the data source of the spreadsheet data. We'll update this thread.

Regards,

georgestephanis commented 2 months ago

So if it's just Google Sheets, there's much simpler ways to integrate the two.

We could do something custom in Google Apps script in the spreadsheet as an API client, but the simplest way is likely a plugin like this:

https://wordpress.org/plugins/wpgsi/

They have an example integration which looks precisely like what we're attempting to set up:

https://www.youtube.com/watch?v=84gTttWN4vo

I've not looked at the plugin's code personally, but if that feels like a good solution, I'm happy to do a code review, unless there's a better channel to build the integration with.

georgestephanis commented 2 months ago

@toncijajic @securityjedi I spoke with @ahegyes about this and he suggested evaluating if we could make the integration work with make.com -- otherwise looking at the plugin, but the post id integration may get a bit tricky depending on how manual it needs to be with the first sync.

Can you check with the partner to see their preference?

securityjedi commented 2 months ago

@georgestephanis - I've sent an email to the partner. I'll update this thread when they respond.

securityjedi commented 2 months ago

Noting there was no response to my previous email. I've sent a follow-up email now.

securityjedi commented 1 month ago

Quick update: The partner did not respond to my previous email, so I've followed up once again today.

securityjedi commented 1 month ago

We received word from the partner, they've asked for time to review and test the possibilities we've mentioned.

I'll update this thread when we hear back from them.