Slack API: Is there a way to determine which user clicked on a button in an interactive message? - slack

I am new to Slack's API, so bear with me. I have a slack button that contains a simple webhook link which, when clicked, updates a record somewhere on my site. However, I need to determine which user clicked the button and send this info back to my site in order to fill out an updated_by field with the user's name. The only way I see to do this is to somehow update the post request body with a variable containing the user's name?

You need to handle interaction with the buttton.
https://api.slack.com/reference/interaction-payloads/block-actions
The payload received contains the SlackId of the user who clicked the button.

Related

Passing description from browser in elsa

In document workflow, after I reject/approve the document in the mail, I want it to take to the browser where I can add a comment in the comment box and then pass that comment back to the employee through email. How can it be done?
I have tried adding comments in console and pass it through mail.How can it be done in UI designer?
#vahidnaderi is spot-on:
In the workflow from where you send the email containing the approve/reject link(s), have these links point to a custom webpage you create.
This webpage contains 3 fields and a submit button:
A radiolist with an "approve" and "reject" radiobuttons
A "comments" textarea.
A "workflowinstanceid" hidden field that stores the workflow instance ID.
When the form is submitted to your backend application, you trigger a signal ("approve" or "reject") for the appropriate workflow instance ID and provide the comment as input.
Your workflow will resume and the received comment will be available as input to the first activity that comes after the "signal received" activity.
That activity should either be the "send email" activity or a "set variable" activity in case you want access to the received comment later in the workflow.
From the "send email" activity, you can now access the comment you wish to include with the email.
Obviously, you're completely free to do things differently. For example, perhaps you want a separate page for "approve" and another page for "reject".
The key takeaway here is that you provide your own web UI. This web UI then interacts with your application backend (i.e. by submitting a form to a controller), which then interacts with Elsa services to e.g. trigger workflows.

How can i provide a delete URL to a message to the user in slack?

I want my bot to post a message to a user which has a "delete" link to a particular message posted by that user. For e.g.
"Hi #someuser , you have posted an inappropriate message. Click >>here<< to delete it."
When the user clicks on "here" it will open up the slack delete message UI?
I have the message ts and channel ID.
I know i can do this via chat.delete api call (have the link point to my backend and then issue the chat.delete api call).
But i was wondering if there is a way to point user to the "delete message" window via a direct link in the message itself.
You can not add to or change the existing message of another user. Only delete a message (with admin rights).
What you can do though is send the guy a direct message from your app including the link (or button) to delete the message. Just send a message to the user ID of the user via chat.postMessage.
Or you can send the guy an ephemeral message into the channel, that only he will be able to see with chat.postEphermal.
To create a user experience similar to Slack's delete pop-up for messages I would suggest the following:
Include a "Delete" button in your message to the user with the
danger style, so it is shown in red color.
Include a confirmation pop-up with a copy of the message text.

Mailchimp API - send update notification for existing subscribers

I have the following workflow using the Mailchimp API:
User is signing up on a form and uses the button "I want to opt in for the newsletter"
The User is posted to the Mailchimp API with status pending and receives a double-opt-in email
The User clicks on the confirm button and his status is changing to ```subscribed``
Now there is a chance, the user is coming back to another form in my app, but clicks again on the button "I want to opt in for the newsletter"
Now I have two possibilities:
My script is checking weather the user already exists on the list, in this case -> ignore and do nothing
My script triggers a Mailchimp "Update Details" Mailing which asks the user to update its details
1st case is easily doable with the Mailchimp API.
2nd case I know is possible via Mailchimp Widgets but I have not found anything in the API docu to trigger this update mailing.
I know about the different status: https://developer.mailchimp.com/documentation/mailchimp/guides/manage-subscribers-with-the-mailchimp-api/ but nothing is reflecting this particular case ("User already subscribed").
I'd like to know how I can do that and how I can trigger an "update details" mailing via the API.
As far as I know and from what it sounds like you've seen as well there isn't a pre-built option or endpoint in place to trigger MC's update profile email.
But because this version of their email is essentially just a link to the existing subscribers list profile, one of the following workarounds might be worth a shot.
1) Use their API automation workflow option to send existing subscribers an email with their update profile link using the merge tag:
*|UPDATE_PROFILE|*
Doc on that Automation API endpoint: https://developer.mailchimp.com/documentation/mailchimp/reference/automations/emails/queue/
Doc on update profile: http://kb.mailchimp.com/campaigns/design/add-an-update-profile-link
Alternatively if you'd like to try and serve subscribers their profile link right on your form after your script check in #2 that to could be done after retrieving:
the subscribers unique_email_id
From: https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members_subscriber_hash
and appending that hashed id to end of the lists specific Update profile URL as the value for e=
Which would lead them to their existing pre-filled update profile form:
E.g: http://mailchimp.{USX}.list-manage.com/profile?u=839fhdd4dd38abf344924fa&id=f29uundc48d&e={unique_email_id}
Your list specific URL sans the e= value can be obtained from using the update profile merge tag in their Campaign builder and using preview or sending yourself a test email.

Track button views and clicks as events in google analytics

I am trying to place a button that will be inside email and I want to track button views and clicks (Google Analytics events). Can you tell me if that is possible and how to do that?
You can't technically track a button click from an email, but what you can do is control where the button links to.
If you set the button's URL to point to your servers, you can intercept the link, send a hit to Google Analytics using the Measurement Protocol, and then redirect the user to where the button was originally pointing.
Alternatively, you could append custom campaign parameters to the end of the URL (utm_medium, utm_source, etc.). This would allow you to know what source the hit came from. Here's some information on custom campaigns:https://support.google.com/analytics/answer/1033863?hl=en
This is able to track button views by using Measurement protocol, and using UTM tagging to track sessions come from this button (but not actual clicks).

Is it possible to add a 'pending' subscriber to Mailchimp via the API?

Here's what I'd like to do:
User completes sign up form on my app
My app sends the input data (email address, name, etc) to Mailchimp via the API, but with a status of 'pending'
My app sends an email to the user asking them to confirm their email address (essentially emulating the Mailchimp confirmation email)
User clicks link in confirmation email, which takes them back to a confirmation page in my app
My app updates the user's status in Mailchimp to 'subscribed' via the API
Essentially, I want to emulate Mailchimps standard confirmation process, but sending the emails from my own app.
The part that I don't know how to do (or don't know if it's possible) is the part where I add a new subscriber with a status of 'pending'.
Here's some further info that's not strictly relevant but may be of interest...
Why don't I just use the standard Mailchimp confirmation email?
The confirmation email needs to contain extra info, unique to each user, that Mailchimp will not have access to.
Why don't I collect all the data locally and then send it all to Mailchimp once the user has confirmed their email address?
For reasons I won't go into, the number and type of required fields will be unknown. At the point when the sign up form is displayed, I will request the list of fields from Mailchimp and display the necessary fields. It is possible that, between the time when the user initially completes the form and the time when the user confirms via email, the required fields will have been changed. If I try to submit the previously collected data to Mailchimp after the required fields have been changed, it will cause an error.
So I need to collect and submit all data to Mailchimp at the same time. And then simply 'switch on' that user in Mailchimp once (s)he has confirmed.
I hope I've provided enough info. If not, happy to provide more or clarify any points.
Thanks!
The internal "pending" status is not able to be managed manually like that. You can subscribe them using double opt-in and then later force them onto the "subscribed" list, but you can't stop them from getting MailChimp's own confirmation email.
One possible work-around would be to add an interest group or merge field that is populated by your system once you've confirmed the email address. You'd then create a saved segment for only confirmed users and make sure you only ever send to that segment and never the whole list.
Another possibility, if you use API v3.0 (which is currently only in beta), is to add them to your list as unsubscribed and then switch their status to "subscribed" once you've confirmed them. If you do this, be very careful that you're not re-subscribing users who unsubscribed or you could wind up in trouble.
This workflow is definitely 100% possible in the current (V3) of the API. Just set the "status" field on a member to "pending" and then to "subscribed".

Resources