IBM Watson Assistant:技能如何使用WA API的V2获得对session_id的访问 [英] IBM Watson Assistant: How can Skill gain access to session_id using V2 of WA API's

查看:105
本文介绍了IBM Watson Assistant:技能如何使用WA API的V2获得对session_id的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IBM Watson Assistant的V2 API要求您获取session_id,然后在对Assistant的后续调用中使用它,以便在调用之间保留全局上下文值.查看与助手关联的预览"链接网页,该请求似乎包含一个值对象和一个session_id,该值对象包含技能的有效负载的所有预期部分.

The V2 APIs for IBM Watson Assistant ask that you get a session_id and then use it in subsequent calls to the Assistant in order for global context values to be preserved across calls. Looking at the Preview link webpage we associated with our Assistant, it appears the request contains both a value object containing all the expected parts of the payload for a Skill, and a session_id.

我想以自己的技能访问此session_id,并将其传递给可能希望在其URI中利用V2 API for Skills的云函数.这可能吗?换句话说,Skills JSON内容中的哪一个引用将获得对session_id值的访问权限?

I would like to access this session_id in my skill to pass it along to cloud functions that may want to leverage the V2 API's for Skills in their URI's. Is this possible? In other words, what would one reference in the Skills JSON content to gain access to the session_id value?

我假设预览"链接导致使用V2 API到助手"(看来有一个中介服务于预览链接"网页并向实际的助手发出请求),并且我进一步假设设置了context.global值因为预览链接应该重用session_id?

I am assuming the Preview link results in use of V2 API's to the Assistant (it appears there is an intermediary serving the Preview Link webpage and making requests to the actual Assistant) and I'm further assuming that setting context.global values in my Skill will cause them to be echoed back by the Assistant since the Preview Link should reuse the session_id?

技能如何向助手提供反馈,告知他们可以删除session_id(例如,对话已结束),从而迫使预览"链接网页获得对新session_id的访问权限?

How can a Skill provide feedback to the Assistant that the session_id can be deleted (e.g., the conversation has ended) forcing the Preview link webpage to gain access to a new session_id?

推荐答案

您可以使用context[variableName]$variableName访问上下文变量.请参阅有关用于访问IBM中对象的表达式的文档Watson Assistant .

You can access context variables using either context[variableName] or $variableName. See the documentation on expressions for accessing objects in IBM Watson Assistant.

session_id (如果存在)(取决于接口)是系统变量(context.system.session_id)的一部分.我只是尝试通过添加以下响应文本来在预览中访问和打印它:

The session_id, if present (this depends on the interface), is part of the system variables (context.system.session_id). I just tried accessing and printing it in the preview by adding the following response text:

My session ID: <? $system.session_id ?>

<? ?>用于评估文本中的表达式.

The <? ?> is used to evaluate the expression within in the text.

我在我的对话工具和V2 API中对其进行了测试会话ID可以很好地打印为响应.

I tested it with the V2 API in my conversation tool and the session ID is nicely printed as response.

这篇关于IBM Watson Assistant:技能如何使用WA API的V2获得对session_id的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆