Amazon Chime SDK calling "CallAndBridge" action from outside of SMA lambda

huangapple go评论59阅读模式
英文:

Amazon Chime SDK calling "CallAndBridge" action from outside of SMA lambda

问题

The Amazon Chime SDK action CallAndBridge routes the incoming call to a user.
CallAndBridge操作将传入的呼叫路由到用户。

The CallAndBridge action is returned from the SMA Lambda.
CallAndBridge操作是从SMA Lambda返回的。

Is there a way to send the action of type CallAndBridge not from the SMA Lambda function, either some REST API or something else?
是否有一种方式可以发送类型为CallAndBridgeaction,而不是通过SMA Lambda函数,可以使用REST API或其他方式吗?

I have different flow where I need to perform some action on the incoming call and once the action that I perform is successful based on some external events, I need to call the CallAndBridge action to the Amazon Chime SDK.
我有不同的流程,我需要对传入的呼叫执行某些操作,一旦我执行的操作基于一些外部事件成功,我需要调用Amazon Chime SDK的CallAndBridge操作。

From the documentation I don't see any way of doing this.
根据文档,我看不到任何这样做的方式。
https://docs.aws.amazon.com/chime-sdk/latest/dg/call-and-bridge.html

英文:

The Amazon Chime SDK action CallAndBridge routes the incoming call to a user.
The CallAndBridge action is returned from the SMA Lambda.

Is there a way to send the action of type CallAndBridge not from the SMA Lambda function, either some REST API or something else?

I have different flow where I need to perform some action on the incoming call and once the action that I perform is successful based on some external events, I need to call the CallAndBridge action to the Amazon Chime SDK.

From the documentation I don't see any way of doing this.
https://docs.aws.amazon.com/chime-sdk/latest/dg/call-and-bridge.html

答案1

得分: 1

You can achieve this by using UpdateSipMediaApplicationCall (see the doc)

Basically, what you need to do is;

  • Run your flow externally and then call UpdateSipMediaApplicationCall with your custom payload. (You can expose this code as a REST API if you want, and call it from SMA)
  • This will trigger your SMA with the payload you passed
  • In your SMA, handle new invocation (the type will be CallUpdateRequested)
  • Read your custom payload, run your business logic in SMA or return any action you want like CallAndBridge

your-external-worker.js


// This is the general idea, it might not be syntactically correct

import { ChimeSDKVoice, Endpoint } from "aws-sdk"

const endpoint = new Endpoint("https://voice-chime.YOUR-REGION.amazonaws.com")
const chimeSDK = new ChimeSDKVoice(endpoint: endpoint)

if (myConditionSatisfied) {
  const params: UpdateSipMediaApplicationCallRequest = {
    SipMediaApplicationId: 'your-sma-id',
    TransactionId: 'your-transaction-id'
    Arguments: {
      myCustomParam: 'letsTriggerCallAndBridge'
    }

  }
  await chimeSDK.updateSipMediaApplicationCall(params).promise()
}

your-sma.js


if (event.invocationType === 'CallUpdateRequested') {
  if (event.actionData.Parameters.Arguments['myCustomParam'] === 'letsTriggerCallAndBridge') {
    return actions.callAndBridge()
  }
}
英文:

> Is there a way to send the action of type CallAndBridge not from the SMA Lambda function, either some REST API or something else?

You can achieve this by using UpdateSipMediaApplicationCall (see the doc)

Basically, what you need to do is;

  • Run your flow externally and then call UpdateSipMediaApplicationCall with your custom payload. (You can expose this code as a REST API if you want, and call it from SMA)
  • This will trigger your SMA with the payload you passed
  • In your SMA, handle new invocation (the type will be CallUpdateRequested)
  • Read your custom payload, run your business logic in SMA or return any action you want like CallAndBridge

your-external-worker.js


// This is the general idea, it might not be syntactically correct

import { ChimeSDKVoice, Endpoint } from "aws-sdk"

const endpoint = new Endpoint("https://voice-chime.YOUR-REGION.amazonaws.com")
const chimeSDK = new ChimeSDKVoice(endpoint: endpoint)

if (myConditionSatisfied) {
  const params: UpdateSipMediaApplicationCallRequest = {
    SipMediaApplicationId: 'your-sma-id',
    TransactionId: 'your-transaction-id'
    Arguments: {
      myCustomParam: 'letsTriggerCallAndBridge'
    }

  }
  await chimeSDK.updateSipMediaApplicationCall(params).promise()
}

your-sma.js


if (event.invocationType === 'CallUpdateRequested') {
  if (event.actionData.Parameters.Arguments['myCustomParam'] === 'letsTriggerCallAndBridge') {
    return actions.callAndBridge()
  }
}

Hope that helps, let me know if you need further explanation

huangapple
  • 本文由 发表于 2023年5月11日 16:55:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76225817.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定