简体   繁体   English

自定义 alexa 技能中的两个 api 调用

[英]two api calls in custom alexa skill

I've asked this question here , but it may be a little too in depth for everyone to read through, but i suppose my basic question could be reduced to:我在这里问过这个问题,但对于每个人来说阅读可能有点太深入了,但我想我的基本问题可以简化为:

is it possible to do two separate API calls within the same piece JS code when writing a custom alexa skill?编写自定义 alexa 技能时,是否可以在同一块 JS 代码中执行两个单独的 API 调用?

Here's my logic这是我的逻辑

  1. call steam api,调用蒸汽api,
  2. get details from my friends list从我的朋友列表中获取详细信息
  3. return details to alexa将详细信息返回给 alexa

4.create new API url with returned friends IDs 4.使用返回的好友ID创建新的API url

5.call new URL to get friends online status and names 5.调用新网址获取好友在线状态和姓名

6.return these details to alexa to sort and determine online status 6.将这些详细信息返回给alexa以排序和确定在线状态

7.construct speech response 7.构建语音响应

8.say response 8.说回应

I've got it as far as constructing the API url with the friends IDs but it appears that my second API call either isn't working or i'm just not accessing it properly.就使用朋友 ID 构建 API url 而言,我已经掌握了它,但似乎我的第二个 API 调用要么不起作用,要么我没有正确访问它。

any thoughts would be helpful.任何想法都会有所帮助。

Yes, your code can do anything you want (including multiple external API calls) in the process of handling an Alexa request, but you can only return one response to Alexa in fulfillment its request.是的,在处理 Alexa 请求的过程中,您的代码可以做任何您想做的事情(包括多个外部 API 调用),但您只能向 Alexa 返回一个响应以完成其请求。

The steps could be itemized like this这些步骤可以像这样逐项列出

  1. Receive request from Alexa,收到来自 Alexa 的请求,
  2. Do whatever processing you want, including multiple external API calls, but don't take too long as the user is waiting!做任何你想做的处理,包括多个外部 API 调用,但不要花太长时间,因为用户正在等待!
  3. Formulate your response and return it to Alexa as the response to #1.制定您的回复并将其返回给 Alexa 作为对 #1 的回复。
  4. Continue processing, eg.继续处理,例如。 to save some session or user data, but you can't send any more data to Alexa because you've already responded to its request.保存一些会话或用户数据,但您不能再向 Alexa 发送任何数据,因为您已经响应了它的请求。

Does that clear things up?这能解决问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM