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