async function convertToSkypeMessage()

in skype/server.js [88:156]


async function convertToSkypeMessage(turnContext, responses){
  const replies = [];
  if (Array.isArray(responses)) {
    const filteredResponses = await filterResponses.filterResponses(responses, 'SKYPE');
    filteredResponses.forEach((response)=> {
      let reply = {type: ActivityTypes.Message};
      switch (response.message) {
        case 'text': {
          reply.text = response.text.text[0];
        }
          break;

        case 'image': {
          reply.attachments = [(CardFactory.heroCard(
              '',
              CardFactory.images([response.image.imageUri])
          ))];
        }
          break;

        case 'card': {
          const buttons = response.card.buttons;
          let skypeButtons = [];
          if (Array.isArray(buttons) && buttons.length > 0) {
            buttons.forEach((button) => {
              if (button.postback.startsWith('http')) {
                skypeButtons.push({
                  type: 'openUrl',
                  title: button.text,
                  value: button.postback
                });
              } else {
                skypeButtons.push({
                  type: 'postBack',
                  title: button.text,
                  value: button.postback
                });
              }
            });
            reply.attachments = [(CardFactory.heroCard(
                response.card.title,
                response.card.subtitle,
                CardFactory.images([response.card.imageUri]),
                skypeButtons))];
          }
        }
          break;

        case 'quickReplies': {
          reply = MessageFactory.suggestedActions(
              response.quickReplies.quickReplies, response.quickReplies.title);
        }
          break;

        case 'payload': {
          console.log(response);
          const protoPayload = response.payload.fields.skype.structValue;
          reply = protoToJson.structProtoToJson(protoPayload);
        }
          break;

        default:
          break;
      }
      replies.push(reply);
    });
  }
  return replies;
}