admin 管理员组文章数量: 1086019
I am building a slack bot with an IBM Watson X Assistant. I am sending some details to IBM Watson in the context in my python code, and I am wondering how I access these values in the "Actions" section of the watsonx assistant. I have this working currently in the dialog section of watson, but I am trying to move to using just actions.
Please see code snippet below of the section of my code which sends the message from my slack bot to the assistant. The commented out section is the old code that works in the dialog version of this journey. And the new uncommented code is me trying to do similar in an action instead. I was referring to this document for the structure of this context:
I have also attached a screenshot below of the 2 watson assistants, the left being the actions only one, and the right being the one that uses dialog too. Is there another way I should be pulling these variables from the context to set in my action?
Is what I am trying to do possible? Am I doing something wrong? Or are actions more limited when it comes to this?
Thanks, Claire
watsonx action vs dialog
Here is the code snippet which I have tried:
##################################################################################
# Message
##################################################################################
response = assistant.message_stateless(
assistant_id=ibmAssistantID,
user_id=user_id_generated,
#
input={
'message_type': 'text',
'text': sanitized_text,
'options': {
'return_context': True
}
},
context={
"skills": {
"action skill": { # Use "action skill" instead of "main skill"
"skill_variables": {
"slackEmailAddress": user_email,
"slackUserId": slack_userid,
"currentTimeStamp": thread_ts,
"slackWorkspaceEnv": slack_workspace_env
}
}
},
# context={
# 'skills': {
# 'main skill': {
# 'user_defined': {
# 'slackEmailAddress': user_email,
# 'currentTimeStamp': thread_ts,
# 'slackUserId': slack_userid,
# 'slackWorkspaceEnv': slack_workspace_env,
# 'cleanup_session': False # Set a default value to 'False'
# }
# }
# },
**user_context.get(user_id_generated, {})
}
).get_result()
本文标签: ibm watsonIBM WatsonX AssistantAccessing Context in Actionspython Slack botStack Overflow
版权声明:本文标题:ibm watson - IBM WatsonX Assistant - Accessing Context in Actions - python Slack bot - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744094839a2532708.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论