I'm trying to build a Slack bot, in which I want bot to ask details from the user, like for example:
Question 1: Please enter your name
Question 2: Please enter your email id
Question 3: Please enter your address
Slackbot is calling an API, for which I added the API URL in Events and Subscriptions so that if a message comes, the API gets called
In the API response along with message, am also returning a field, which am expecting from Slackbot to return back again in next API request(whenever the API is called again for the same user).
Note: The field is required because on the basis of that am maintaining the user state in the backend
Is there any way to achieve this?
You will have to store the user state in either cache or database.
Using 'Redis' cache is an easy to implement solution.
You can use hash (key-value pair)to store data. Store slackID as key and state(can be a JSON object) as value.
Related
I have a react app that during signup, user will enter their email and while typing API calls will be made on each keypress (if email is valid) to check if the email has previously been registered and send back a success response if it is not.
ISSUE: The problem I have is the speed of the API connection is not always reliable as in a slow network, for instance, if user types "user#gmail.com", "user#gmail.co" will be checked for and the success response will be for that email "user#gmail.com", hence they won't be able to verify it later on.
SOLUTION I TRIED: use a controlled input field and on every server response, replace the text inputed by the user with the email that the last verification was made for so users can see what email was just verified but it sucks as if users go back to change a letter or something it starts misbehaving and moving the cursor.
I'd appreciate any suggestions.
How are you performing the API call? If you use something like tanstack/react query (https://tanstack.com/query/latest) and have the query key be derived from the current input email address, you should be able to rely on using the query result to determine when the API call has finished for the current input.
for example,
const validEmailQuery = useQuery([currEmailInput], /* fetch logic etc here */)
I am using STRIPE as my payment processor, in an REACT + nodeJS app. I already have something that already works, but I would like some feedback, maybe I'm doing something wrong.
So... I have this Redirect-To-Checkout functionality thats made available by STRIPE, basically I redirect the user to this STRIPE page where all card-data (sensitive information) is processes in order for the payment to full-fill.
What I do in my nodeJS server part is the following:
Once the user acces the redirect to check-out page, I already create a PendingOrder, with the products selected by client (Here I save some information based on client/stripe payment-intent, in order to check in later steps)
Once webhook gives me the 'payment_intent.succeeded' I check for the payment-intent information to see if it exists in my PendingOrder collection, then proceed to add in to ConfirmedOrders and remove it from PendingOrders.
I have to do this whole process because Stripe no longer gives me access to some information I require when the user is checking-out his order(such as observation that the user has based on the type of service he chooses).
Are there any down-sides to this approach or is there any other way to do it?
Thanks in advance!
You’re not really far from the best practices that Stripe recommends here. The only thing that I would change is listening to checkout.session.completed instead of the payment_intent.succeeded event. As of the latest API version, a PaymentIntent is no longer created upfront so a better to way to handle order fulfillment is to either store the Checkout Session ID (e.g. cs_live_xxx) or you could add some metadata when creating the Checkout Session and use that instead to identify the order.
I have to do this whole process because Stripe no longer gives me access to some information I require when the user is checking-out his order
As for this, I’m not sure what you mean, you can always use your app with the success page customization described here alongside webhooks. I wouldn’t use that to fulfill the order though since the user might close the page before the redirection completes which means that the fulfillment wouldn’t be done in that case. As such, webhooks are essential to order fulfillment.
Can someone please share the postman to fetch TEAM roster or user profile information. I am referring to https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/get-teams-context?tabs=json
The Url you need is this: [serviceUrl] + "/v3/conversations/{teamId}/members/"
and it is based on two variables: the "teamId" is obviously different per team. However, the first part of the address (called the ServiceUrl) can also vary between teams, based on where they might be hosted, and you need both.
It sounds like, from the link you sent, that you already have a bot? If so, your bot can retrieve both of these required parameters. One way is that, whenever a user sends a message to the bot, to get the ServiceUrl and TeamId that are sent in the incoming "activity" object that. However, if you want it even earlier than this (i.e. before a user even sends a message to the bot), have a look at the conversationUpdate event here which will fire right when the bot is first added to the conversation.
Does that help?
I am trying to wrap my head around using Dialogflow for developing and integrating an SMS chatbot with our custom CRM. The creation of an Intent is pretty powerful and straight forward. However, I am trying to understand best practices for something. If I have an intent used to return the price of a service at a certain location, I can model that very easily within dialog flow. However, when an SMS message comes in, it will be from a new customer or a known existing customer for a certain location. For existing customers, we already know the location and therefore don't want them to have to specify the location value in the intent. Prior to sending the inbound SMS message to the client API to match the intent, how can I pre-set the "location" parameter value in the intent so it does exists even if that inbound SMS message did not include it? For example a known customer in Dallas would just have to say "how much is a xxx" instead of "how much is a xxx in Dallas".
Can you use the API to set a parameter value prior to calling the API to try and match the intent? If so, how do you get do that without a session ID? The reason the "location" is needed is because when we get to the fulfillment, the prices for the same service are different based on the location so I will need to be known but we don't want to make existing customers say the location.
Maybe another option is to have a Location intent with an event that we can trigger through the API. this would have an output context on it called location and fulfillment that sets the parameter value. But even then I struggle with understanding how to pass in values like location, phone number, etc into dialogflow from the calling application so dialogflow has those parameter values to use in fulfillment.
Reading documentation, watching videos and starting to test client API v2
This is certainly possible. What you would want to do is use the Dialogflow API for this. Here you can find the languages for which Google has created client libraries: https://cloud.google.com/dialogflow/docs/reference/libraries/overview
As soon as you have any 'if' in your code you should use the fulfillment: https://dialogflow.com/docs/fulfillment
How I would handle this:
Client sends SMS
You check in your back-end if this user is known. If known -> don't ask location, else you ask the location
Match the user query against the Dialogflow client library
Dialogflow will return the intent if (any) is matched
You should define and implement any logic before calling the Dialogflow library.
I need to find a method to use excel to send a direct message to slack user like we use MAilto in with subject and body function to send the user email,
for example (WhatsaApp)
api.whatsapp.com/send?phone=XXYYYYYYYYYY&text=This is my message
Well if i understand correctly, you want to get info from excel and send this info to a user, well that's possible in one way, you have to be able to read excel, which i don't recommend.
i recommend Google spreadsheet for that. anyway lets not get off-topic.
then you need to know how to send message to slack, Do you know ?
i will assume not, so to send messages there is two ways,
Webhooks
Web API
method URL = https://slack.com/api/chat.postMessage
to Send Through Web API, you have to pass the following arguments:
token The Oauth2 Token you will get from slack when configuring your bot or app, Or you can use Legacy tokens instead
channel The place you want to send the message, Channel ID if it is a channel, or User ID if it is a User.
text As the name say, the message you want to send
as_user Whether you want to send the message as your name or as a Custom name, This a boolean method, Means its Only True or False
Note: To configure a custom name its in another argument we will reach.
attachments A JSON-based array of structured attachments, presented as a URL-encoded string.
username The name you want to appear as the sender of the message, only works if as_user is false, if as_user is true, it will ignore this argument.
Hope this help.
and please next time share a code so we can help, here there is not just 'I need...'
its a place where you share code and then ask 'I need...' so we can help
I have solved the issue already
Creating an APP and using the chat.postmessage