I am using IBM Watson APIs to create intents and user examples and I want to know how to track the training status after creating a new intent and user examples.
To track the status from within the UI, open the "Try it out" panel. It will display "Watson is training". When complete it will stop.
Programatically, you can use the Workspace API to query the workspace. For example in Python.
from watson_developer_cloud import ConversationV1
url = "https://gateway-fra.watsonplatform.net/conversation/api"
username = "USERNAME"
password = "PASSWORD"
workspace_id = '2d5e7dd4-19fe-4ab3-9c3e-f2eff48c9ca4'
conv = ConversationV1(
username=username,
password=password,
version='2017-05-26',
url=url
)
response = conv.get_workspace(workspace_id=workspace, export=False)
print('Status is: {}'.format(response['status']))
Related
I want to create a bot that posts messages on channels / groups,
the user sends the group address for example: #group_name, and I need to get the ID, title
I work with telebot library
#bot.message_handler(commands=['addgroup'])
def add_group(message):
msg = bot.send_message(message.chat.id, 'Send group link without #')
bot.register_next_step_handler(msg, add)
def add(message):
url = "telegram.me/" + message.text
keyboard = types.InlineKeyboardMarkup()
keyboard.add(types.InlineKeyboardButton("##HERE I NEED GROUP NAME##", url=url))
msg = bot.send_message(message.chat.id, "Add this group?", reply_markup=keyboard)
bot.register_next_step_handler(msg, check_group)
....
How can I get this information?
Let's read telegram docs...
getChat
Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.).
Returns a Chat object on success.
Parameters:
chat_id - unique identifier for the target chat or username of the target supergroup or channel (in the format #channelusername).
So,
chat = bot.get_chat('#username')
P.S.: register_next_step_handler is antipattern, use aiogram's FSM instead.
I'm trying to set up the slackr package in R to allow me to post to Slack through RStudio, but it seems the connection isn't working.
I've installed the package, set up the required App in my Slack Workspace, have a webhook and access tokens, manually granted all of Scopes needed in Slack, set up the config file and have confirmed via the cmd line that this works by sending a message to the channel through that successfully. Unfortunately nothing is working via R.
slackr_msg(paste("test"),
,channel = "#it-reports")
slackr_ims(api_token="xoxb-...")
When run the above both produce Error: Join columns must be present in data. x Problem with 'id'. which I can't find anybody else experiencing. It sounds like an issue with the user, but the app is in the channel, has permission to access all public channels, and this error appears regardless of whether I try and send it via my logged in account or just from the bot. When I just try and return something simple like listed channels with slackr_channels I get NULL. I've tried both OAuth Access Token and Bot User OAuth Access Token with all permissions needed in the scope but neither are letting me access Slack.
I'm not sure you still need an answer, but in case anyone else is looking - I've run into the same issue. I think the underlying method that your slack channel name "#my_excellent_named_channel" is converted to the channel id is deprecated.
"https://slack.com/api/channels.list" has been changed to "https://slack.com/api/conversations.list" in the methods.
I couldn't find a better way than brute forcing my channel id because I only need to publish to a notifications channel.
nextCursor=""
for (j in c(1:10)){
resp<-GET(url = "https://slack.com/api/conversations.list",
query = list(token=YOUR_BOT_TOKEN,
cursor=nextCursor
))
foo=fromJSON(content(resp, as="text"))
for (i in c(1:100)){
if(foo$channels[[i]]$name %like% 'my_excellent_named_channel'){
print(paste(nextCursor, "\n"))
print(paste(i,foo$channels[[i]]$name,"\n"))
print(paste(foo$channels[[i]]$id))
}
}
nextCursor=foo$response_metadata[[1]]
}
You'll probably need to run through a few more than the 10 top level iterations, but if you go too fast it locks you out. I then just exchanged the channel name in my config file for the channel id, and rewrote the functions to avoid the conversion.
Here's slackMsg (conversion of slackrMsg)
slackMsg=function (txt = "", channel = Sys.getenv("SLACK_CHANNEL"), username = Sys.getenv("SLACK_USERNAME"),
icon_emoji = Sys.getenv("SLACK_ICON_EMOJI"), api_token = Sys.getenv("SLACK_API_TOKEN"),
...)
{
if (api_token == "") {
stop("No token specified. Did you forget to call slackr_setup()?",
call. = FALSE)
}
if (icon_emoji != "") {
icon_emoji <- sprintf(", \"icon_emoji\": \"%s\"", icon_emoji)
}
output <- paste0(txt, collapse = "\n\n")
loc <- Sys.getlocale("LC_CTYPE")
Sys.setlocale("LC_CTYPE", "C")
on.exit(Sys.setlocale("LC_CTYPE", loc))
resp <- POST(url = "https://slack.com/api/chat.postMessage",
body = list(token = api_token, channel = channel,
username = username, icon_emoji = icon_emoji, text = output,
as_user = TRUE, link_names = 1, ...))
warn_for_status(resp)
return(invisible())
}
Don't forget to give your bot chat.write permissions in your Slack App.
I try to make a push notification for my google assistant app.
I used the sendNotification Code form the google developer site: https://developers.google.com/actions/assistant/updates/notifications
I am coding Java.
Everything is working, expect getting the correct user id.
When I hardcode my user it works, but how do I get the user id in the code?
I tried following code:
Argument arg_userId = request.getArgument(ConstantsKt.ARG_UPDATES_USER_ID);
String userId = request.getUser().getUserId();
--> I get "java.lang.reflect.InvocationTargetException"
String userId = arg_userId.getRawText();
--> same Exception
There are two problems with the approach you're taking to get the notification ID:
The ID attached to the user object is deprecated and probably unavailable.
This wasn't the ID you wanted anyway.
In the response where the user finalizes the notification, that response includes an ID which you should get and store. Since you're using Java, the code might look something like this:
ResponseBuilder responseBuilder = getResponseBuilder(request);
Argument permission = request.getArgument(ConstantsKt.ARG_PERMISSION);
if (permission != null) {
Argument userId = request.getArgument(ConstantsKt.ARG_UPDATES_USER_ID);
// code to save intent and userID in your db
responseBuilder.add("Ok, I'll start alerting you.").endConversation();
} else {
responseBuilder.add("Ok, I won't alert you.");
}
return responseBuilder.build();
Trying to get my head around how CyberSource works..
In CyberSource, the Secure Acceptance Flexible Token API can be used to tokenize a credit card on client-side for processing for future processing.
That part is easy enough. There's plenty of documentation and a few packages that do it.
How do I then use that token to create a charge with the CyberSource Payments API ?
All examples i've found show how to tokenize the card on client, and how to charge an untokenized card (i.e. card data is sent to server) but I can't find an example that show how to use the Flexible token to create a charge (or pre-auth).
In most other gateways like Stripe, it's pretty clear in documentations but CyberSource doesn't seem to provide that.
Am I missing something?
I'm using Node but happy with solutions in other languages.
https://developer.cybersource.com/api-reference-assets/index.html#flex
https://developer.visa.com/capabilities/cybersource/reference
Ok, thanks to #rhldr for pointing out to this particular documentation.
The answer is in this page https://developer.cybersource.com/api/developer-guides/dita-flex/SAFlexibleToken/FlexMicroform/GetStarted.html under "Using the Token".
Note: Some of the other documentations (not sure why they have some many variations of the docs), like this one don't mention this at all.
See the RESTPaymentAPI section. It needs to be provided as a customerId field.
"paymentInformation": {
"customer": {
"customerId": "7500BB199B4270EFE05340588D0AFCAD"
}
}
Here's a minimal example of how it can be implemented on the API side
var cybersourceRestApi = require('cybersource-rest-client');
var configuration = require('./cybersource/config.js');
var configObject = new configuration();
var instance = new cybersourceRestApi.PaymentsApi(configObject);
var clientReferenceInformation = new cybersourceRestApi.Ptsv2paymentsClientReferenceInformation();
clientReferenceInformation.code = 'test_payment';
var processingInformation = new cybersourceRestApi.Ptsv2paymentsProcessingInformation();
processingInformation.commerceIndicator = 'internet';
var amountDetails = new cybersourceRestApi.Ptsv2paymentsOrderInformationAmountDetails();
amountDetails.totalAmount = "100.00";
amountDetails.currency = 'USD';
var orderInformation = new cybersourceRestApi.Ptsv2paymentsOrderInformation();
orderInformation.amountDetails = amountDetails;
var paymentInformation = new cybersourceRestApi.Ptsv2paymentsPaymentInformation();
// THIS IS THE IMPORTANT BIT
var customer = new cybersourceRestApi.Ptsv2paymentsPaymentInformationCustomer()
customer.customerId = token
paymentInformation.customer = customer
var request = new cybersourceRestApi.CreatePaymentRequest();
request.clientReferenceInformation = clientReferenceInformation;
request.processingInformation = processingInformation;
request.orderInformation = orderInformation;
request.paymentInformation = paymentInformation;
if (!authoriseOnly) {
request.processingInformation.capture = true;
}
Code based on the CyberSource nodejs REST samples: https://github.com/CyberSource/cybersource-rest-samples-node
More info. Once you know where to look, it's actually explained in a few places.
Example, go to https://developer.cybersource.com/cybs-dev-api-ref/index.html#payments-process-a-payment, expand the "REQUEST FIELD DESCRIPTION" underneath and go to
customer
.. customerId
Unique identifier for the customer's card
and billing information.
When you use Payment Tokenization or Recurring Billing and you include
this value in your request, many of the fields that are normally
required for an authorization or credit become optional.
NOTE When you use Payment Tokenization or Recurring Billing, the value
for the Customer ID is actually the Cybersource payment token for a
customer. This token stores information such as the consumer’s card
number so it can be applied towards bill payments, recurring payments,
or one-time payments. By using this token in a payment API request,
the merchant doesn't need to pass in data such as the card number or
expiration date in the request itself.
See "Payment Tokenization," page 222, and "Recurring Billing," page
225.
Below is the code i am using to achieve this functionality, and i have successfully posted it to my facebook wall from my website but i am not able to post to my facebook page?
How can i get page access token using FaceBookClient() in c# SDK?
var client = new FacebookClient();
dynamic token = client.Get("oauth/access_token", new
{
client_id = ConfigurationManager.AppSettings["FacebookAPI"].ToString(),
client_secret = ConfigurationManager.AppSettings["FacebookAPIKey"].ToString(),
grant_type = "client_credentials"
});
client.AccessToken = token.access_token;
dynamic parameters = new ExpandoObject();
parameters.title = detail.Title;
parameters.message = GetDescription(detail.Description, detail.Content);
parameters.link = "http://test.com/blog" + detail.RelativeLink;//HttpContext.Current.Request.IsLocal ? "http://test.com/blog" + detail.RelativeLink : HttpContext.Current.Request.Url.Authority + "" + detail.RelativeLink;
var result = client.Post(ConfigurationManager.AppSettings["FacebookPageID"].ToString() + "/feed", parameters);
Please read the docs at
https://developers.facebook.com/docs/graph-api/reference/v2.3/page/feed#publish
It's clear that you can't use an App Access Token for posting to a Page, because a Post always needs to be related to a profile.
A user access token with publish_actions permission can be used to publish new posts on behalf of that person. Posts will appear in the voice of the user.
A page access token with publish_pages permission can be used to publish new posts on behalf of that page. Posts will appear in the voice of the page.